[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Beginner Questions



PureBytes Links

Trading Reference Links




I had originally 
planned to take this off line as it is old hat to many of the regulars but 
several have asked me to keep it here so I will. If you have seen this before 
just hit delete and sorry for the waste of bandwidth.
<FONT face=Arial 
size=2> 
I use QP for my EOD, 
you may need to make some adjustments for your data source. The code below 
creates a series of composites from which several indicators and explorations 
can be developed. 
<FONT face=Arial 
size=2> 
I place the code in 
AA then select a watch list of stocks to study. Personally I prefer to select a 
a Universe based on criteria which includes min ave vol , institutional 
interest, minimum price and a few fundamentals. You may decide to use the 
S&P, the Nas 100 or a different basket all together. 
<FONT face=Arial 
size=2> 
Set n=1day and 
select the watch list. Scan this list to create the 
composites.....
<FONT 
face=Arial color=#000000 size=2> 
Buy<FONT color=#282828 
size=2>=0<FONT color=#282828 
size=2>;
newhigh=<FONT 
face=Arial>H><FONT 
size=2>Ref(HHV<FONT 
size=2>(H<FONT 
size=2>,10),-<FONT 
size=2>1); <FONT 
face=Arial color=#000000>//stocks making new high<FONT 
color=#282828 size=2>
newlow=<FONT 
face=Arial>L<<FONT 
size=2>Ref(LLV<FONT 
size=2>(L<FONT 
size=2>,10),-<FONT 
size=2>1); <FONT 
face=Arial color=#000000>//Stocks making new low<FONT 
color=#282828 size=2>
up=<FONT 
face=Arial>C><FONT 
size=2>Ref(C<FONT 
face=Arial>,-1<FONT color=#282828 
size=2>);
dn=<FONT 
face=Arial>C<<FONT 
size=2>Ref(C<FONT 
face=Arial>,-1<FONT color=#282828 
size=2>);
upvol=<FONT 
size=2>IIf(up,<FONT 
size=2>V/<FONT 
size=2>C,<FONT 
size=2>0<FONT face=Arial 
color=#000000>);
dnvol=<FONT 
size=2>IIf(dn,<FONT 
size=2>V/<FONT 
size=2>C,<FONT 
size=2>0<FONT face=Arial 
color=#000000>);
//x=SectorID(0);<FONT 
color=#282828 size=2>
sym=<FONT 
size=2>"~"+SectorID<FONT 
size=2>(1<FONT 
face=Arial color=#000000>);
isym=<FONT 
size=2>"~i"+SectorID<FONT 
size=2>(1<FONT 
face=Arial color=#000000>);
Ad=<FONT 
size=2>"~AD"+SectorID<FONT 
size=2>(1<FONT 
face=Arial color=#000000>);
AddToComposite<FONT 
face=Arial>(C<FONT 
face=Arial>,sym ,"C"); 
//adds 
Close data to sector
AddToComposite<FONT 
face=Arial>(V<FONT 
face=Arial>/1000<FONT 
size=2>,sym,"V"); <FONT 
color=#008000 size=2>// adj vol 
overflow
AddToComposite<FONT 
face=Arial>(1<FONT 
size=2>,sym,"O"); <FONT 
color=#008000 size=2>//counts 
stocks
AddToComposite<FONT 
face=Arial>(IIf<FONT 
size=2>(newhigh,1,<FONT 
size=2>0),sym,"H"<FONT 
size=2>);<FONT face=Arial 
color=#000000>//counts new highs
AddToComposite<FONT 
face=Arial>(IIf<FONT 
size=2>(newlow,1,<FONT 
size=2>0),sym,"L"<FONT 
size=2>);<FONT face=Arial 
color=#000000>//Counts new Lows<FONT color=#282828 
size=2>
//creates a master index of stocks under 
study
AddToComposite<FONT 
face=Arial>(C<FONT 
face=Arial>,"~Universe" 
,"c"<FONT 
face=Arial color=#000000>); 
AddToComposite<FONT 
face=Arial>(V<FONT 
face=Arial>/1000<FONT 
size=2>,"~Universe" ,<FONT 
size=2>"v"<FONT face=Arial 
color=#000000>); 
AddToComposite<FONT 
face=Arial>(1,<FONT 
size=2>"~Universe" ,"O"<FONT 
size=2>); <FONT face=Arial 
color=#000000>//counts stocks 
AddToComposite<FONT 
face=Arial>(newhigh,"~Universe"<FONT 
size=2>,"H"<FONT 
face=Arial color=#000000>);
AddToComposite<FONT 
face=Arial>(Newlow,"~Universe"<FONT 
size=2>,"L"<FONT 
face=Arial color=#000000>);
//creates master index of OHLC data 

AddToComposite<FONT 
face=Arial>(C<FONT 
face=Arial>,"~Index"<FONT 
size=2>,"C"<FONT 
face=Arial color=#000000>);
AddToComposite<FONT 
face=Arial>(O<FONT 
face=Arial>,"~Index"<FONT 
size=2>,"O"<FONT 
face=Arial color=#000000>);
AddToComposite<FONT 
face=Arial>(H<FONT 
face=Arial>,"~Index"<FONT 
size=2>,"H"<FONT 
face=Arial color=#000000>);
AddToComposite<FONT 
face=Arial>(L<FONT 
face=Arial>,"~Index"<FONT 
size=2>,"l"<FONT 
face=Arial color=#000000>);
AddToComposite<FONT 
face=Arial>(1,<FONT 
size=2>"~index","V"<FONT 
size=2>);<FONT face=Arial 
color=#000000>//counts stocks in index<FONT color=#282828 
size=2>
//creates index by 
sector
AddToComposite<FONT 
face=Arial>(C<FONT 
face=Arial>,isym,"C"<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
AddToComposite<FONT 
face=Arial>(O<FONT 
face=Arial>,isym,"O"<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
AddToComposite<FONT 
face=Arial>(H<FONT 
face=Arial>,isym,"H"<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
AddToComposite<FONT 
face=Arial>(L<FONT 
face=Arial>,isym,"L"<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
AddToComposite<FONT 
face=Arial>(1<FONT 
size=2>,isym,"V"<FONT color=#282828 
size=2>); <FONT color=#008000 
size=2>
//creates advance /decline by sector 
composite
AddToComposite<FONT 
face=Arial>(up,Ad,"C"<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
AddToComposite<FONT 
face=Arial>(dn,Ad,"O"<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
AddToComposite<FONT 
face=Arial>(upvol,Ad,"H"<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
AddToComposite<FONT 
face=Arial>(dnvol,Ad,"L"<FONT 
color=#282828>);


Now we 
have customized sector indexes for your universe. Place this code in IB to plot 
the appropriate sector index along side any stock. Note the count tells you how 
many stocks went into the construction of the given 
index....<SPAN 
class=558072306-24042004>
<SPAN 
class=558072306-24042004>//sector index with count
symbol=<FONT 
face=Arial>"~i"+SectorID(1<FONT 
color=#000000>);
SetForeign<FONT 
color=#282828><FONT face=Arial color=#000000 
size=2>(symbol);
//the Ti3 
average
function<FONT 
color=#282828> 
T3(price,periods,s)
{
e1=<FONT face=Arial 
size=2>EMA<FONT face=Arial color=#000000 
size=2>(price,periods);
e2=<FONT face=Arial 
size=2>EMA<FONT face=Arial color=#000000 
size=2>(e1,Periods);
e3=<FONT face=Arial 
size=2>EMA<FONT face=Arial color=#000000 
size=2>(e2,Periods);
e4=<FONT face=Arial 
size=2>EMA<FONT face=Arial color=#000000 
size=2>(e3,Periods);
e5=<FONT face=Arial 
size=2>EMA<FONT face=Arial color=#000000 
size=2>(e4,Periods);
e6=<FONT face=Arial 
size=2>EMA<FONT face=Arial color=#000000 
size=2>(e5,Periods);
c1=-s*s*s;
c2=<FONT face=Arial 
size=2>3*s*s+3<FONT face=Arial color=#000000 
size=2>*s*s*s;
c3=-<FONT face=Arial 
size=2>6*s*s-3*s-3<FONT face=Arial color=#000000 
size=2>*s*s*s;
c4=<FONT face=Arial 
size=2>1+3*s+s*s*s+3<FONT face=Arial color=#000000 
size=2>*s*s;
<FONT face=Arial color=#000000 
size=2>Ti3=c1*e6+c2*e5+c3*e4+c4*e3;
return<FONT 
color=#282828> ti3;
}<FONT 
color=#0000ff>
Plot<FONT 
face=Arial>(t3(C/V<FONT 
face=Arial>,25,.715),"T3(20)",colorYellow<FONT 
face=Arial>,1|styleThick<FONT face=Arial 
color=#000000>);
Plot<FONT 
face=Arial>(t3(C/V<FONT 
face=Arial>,10,.74),"T3(10)",colorBlue<FONT 
face=Arial>,1|styleThick<FONT face=Arial 
color=#000000>);
PlotOHLC<FONT 
size=2>(O/V<FONT 
face=Arial>,H/V<FONT 
face=Arial>,L/V<FONT 
face=Arial>,C/V," 
Sector",colorWhite,64<FONT 
color=#000000>);
GraphXSpace<FONT 
color=#282828>=3<FONT 
color=#282828>;
Title<FONT 
color=#282828>=SectorID<FONT 
color=#282828>(1<FONT 
color=#282828>)+" Sector "<FONT 
color=#282828>+ V+" 
Count"+ "\n "<FONT 
color=#282828>+WriteVal<FONT 
color=#282828>(ROC<FONT 
color=#282828>(C,<FONT 
color=#ff00ff>1),<FONT 
color=#ff00ff>1.2)+<FONT 
color=#ff00ff>"%"<FONT face=Arial 
size=2> ;
 
Here 
is an indicator that plots the appropriate induistry group for your stock. QP 
posts industry group updates on Saturday so I plot this indicator in Weekly 
bars...
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial 
color=#000000>//industry groups
L1=<FONT 
size=2>"!ID00"+IndustryID<FONT 
size=2>(0<FONT 
face=Arial color=#000000>);
L2=<FONT 
size=2>"!ID0"+IndustryID<FONT 
size=2>(0<FONT 
face=Arial color=#000000>);
L3=<FONT 
size=2>"!ID"+IndustryID<FONT 
size=2>(0<FONT 
face=Arial color=#000000>);
industry=<FONT 
face=Arial>WriteIf(<FONT 
size=2>IndustryID(0) 
<10,l1,<FONT 
size=2>WriteIf(IndustryID<FONT 
size=2>(0)><FONT 
size=2>9 AND<FONT 
face=Arial> IndustryID<FONT 
size=2>(0)<<FONT 
size=2>100<FONT face=Arial 
color=#000000>,l2,L3));
SetForeign<FONT color=#282828 
size=2>(industry);<FONT 
color=#0000ff size=2>
TimeFrameSet<FONT 
face=Arial>(inWeekly<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
Plot<FONT 
size=2>(C<FONT 
size=2>,IndustryID(<FONT 
size=2>1),<FONT 
size=2>colorWhite,<FONT 
size=2>64<FONT face=Arial 
color=#000000>);
Plot<FONT 
size=2>(MA(<FONT 
size=2>C,<FONT 
size=2>20),""<FONT 
size=2>,colorBlue<FONT 
size=2>,1<FONT 
face=Arial color=#000000>);
Plot<FONT 
size=2>(MA(<FONT 
size=2>C,<FONT 
size=2>50),""<FONT 
size=2>,colorYellow<FONT 
face=Arial>,1<FONT color=#282828 
size=2>);
Title<FONT color=#282828 
size=2>="Industry Group = "<FONT 
color=#282828 size=2>+IndustryID<FONT 
color=#282828 size=2>(1<FONT 
color=#282828 size=2>)+ " ("<FONT 
color=#282828 size=2>+industry+")"<FONT 
color=#282828 size=2>+"\n Today "<FONT 
color=#282828 size=2>+WriteVal<FONT 
color=#282828 size=2>(ROC<FONT 
color=#282828 size=2>(C<FONT color=#282828 
size=2>,1<FONT color=#282828 
size=2>),1.2<FONT color=#282828 
size=2>)+"%"<FONT color=#282828 
size=2>;
GraphXSpace<FONT 
color=#282828 size=2>=3<FONT 
color=#282828 size=2>;
 
<FONT face=Arial color=#0000ff 
size=2>When I made the composites I collected advance decline data as well. This 
indicator utilizes that information...
<FONT face=Arial color=#0000ff 
size=2> 
<FONT color=#008000 
size=2> 
//Sector AD Jayson 
Casavant
GraphXSpace<FONT 
color=#282828 size=2>=15<FONT 
color=#282828 size=2>;
pds=<FONT 
size=2>Param("Smoothing 
Periods",11<FONT 
size=2>,1,<FONT 
size=2>20,1<FONT 
color=#282828 size=2>);
Ad=<FONT 
size=2>"~AD"+SectorID<FONT 
size=2>(1<FONT 
face=Arial color=#000000>);
ADissues=<FONT 
face=Arial>Foreign(Ad,<FONT 
size=2>"C"<FONT face=Arial 
color=#000000>);
Dissues=<FONT 
size=2>Foreign(Ad,"O"<FONT 
color=#282828 size=2>);
Advol=<FONT 
size=2>Foreign(Ad,"h"<FONT 
size=2>);<FONT face=Arial 
color=#000000>// High vol
Dvol=<FONT 
size=2>Foreign(Ad,"l"<FONT 
size=2>);<FONT face=Arial 
color=#000000>//low vol
addecvol=<FONT 
face=Arial>EMA(<FONT 
size=2>Sum(advol,pds),pds)-<FONT 
size=2>EMA(Sum<FONT 
color=#282828 size=2><FONT face=Arial 
color=#000000>(dvol,pds),pds);
Plot<FONT 
size=2>(addecvol,"AD VOL",<FONT 
size=2>IIf(addecvol>0<FONT 
size=2>,5,<FONT 
size=2>4),2<FONT 
color=#282828 size=2>);<FONT 
color=#0000ff size=2>
Plot<FONT 
size=2>(EMA(adissues,pds)-<FONT 
size=2>EMA(dissues,pds),<FONT 
size=2>"A/d",1<FONT 
size=2>,1|<FONT 
size=2>styleOwnScale<FONT 
face=Arial color=#000000>);
<FONT face=Arial 
color=#000000>//Plot(EMA(dissues,pds),"Decliners",4,1);<FONT 
color=#0000ff size=2>
PlotGrid<FONT 
size=2>(0,<FONT 
size=2>colorWhite<FONT face=Arial 
color=#000000>);
 
Title<FONT color=#282828 
size=2>=SectorID<FONT color=#282828 
size=2>(1)+ 
" Sector Advance/Decline"<FONT 
color=#282828 size=2>+"\n Advancing Issues 
" +<FONT color=#0000ff 
size=2>WriteVal(<FONT color=#0000ff 
size=2>EMA(Adissues,pds),<FONT 
color=#ff00ff size=2>1.0)+<FONT 
color=#ff00ff size=2>" Declining Issues "<FONT color=#282828 
size=2>+WriteVal<FONT color=#282828 
size=2>(EMA<FONT color=#282828 
size=2>(dissues,pds),1.0<FONT 
color=#282828 size=2>);
 
<FONT face=Arial color=#0000ff 
size=2>Please note that each of the indicators plot the appropriate 
secor/industry group charts based on the stock you select. OPen a chart for CSCO 
and the Information Sector A/D will plot as will the information sector and the 
comp-networks industry group....
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>Regards,
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>Jayson
 
 
 
 

 
 
 
 
 
 





Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.