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

Re[2]: [RT] Band Study (better explained)



PureBytes Links

Trading Reference Links

Hello Jim,

JW> There was no study attachment or description  in  the original message.
JW> Jim


Below is the raw text for the Omega easy language code.



vars:bandup(0),banddn(0),av(0);

av=average(c,21);
bandup=av*1.025;
banddn=av*0.975;var:

aa(0),bb(0),cc(0),dd(0);

if c > bandup and c[2]<bandup then value1=1;
if value1= 1 then begin plot4(h+5,"break");
aa=aa+1;

Print(File("C:\xitami\root\mod\SPBand.txt"),d:6:0,", ",c:3:2,", C>UpperBand",", ","L>MiddleBand, ",aa:0," Days");
print(d:6:0,", ",c:3:2,", C>UpperBand",", ","L>MiddleBand, ",aa:0," Days");end;
if l<=av then value1=0;
if l<=av then aa=0;

if c < banddn and c[2]>banddn then value2=1;
if value2= 1 then begin plot4(l-5,"break");
bb=bb+1;

Print(File("C:\xitami\root\mod\SPBand.txt"),d:6:0,", ",c:3:2,", C<LowerBand",", ","H<MiddleBand, ",bb:0," Days");
print(d:6:0,", ",c:3:2,", C<LowerBand",", ","H<MiddleBand, ",bb:0," Days");end;
if h>=av then value2=0;
if h>=av then bb=0;

plot1(av,"21MA");
plot2(bandup,"bandup");
plot3(banddn,"banddn");




The below MetaStock code was contributed from HHP


This should come close (unless I've botched something, in which I'll be
sure to hear about it) :). It's made up of two indicators and an
Expert.
IMPORTANT: Make sure both indicators have the same parameters. Change
the default values to suit yourself.

{Name: %Bands}
Pds:= Input("EMA Periods?",1,1000,21);
Pct:= Input("Percentage Bands?",0.1,10,5);
MA:= Mov(C,Pds,E);
TBnd:= MA*(1+Pct/100);
LBnd:= MA*(1-Pct/100);
MA;TBnd;LBnd;

{Name: %BandsCount}
Pds:= Input("EMA Periods?",1,1000,21);
Pct:= Input("Percentage Bands?",0.1,10,5);
MA:= Mov(C,Pds,E);
TBnd:= MA*(1+Pct/100);
LBnd:= MA*(1-Pct/100);

IUp:= (H > TBnd) * Ref((H <= TBnd),-1);
CntUp:= IUp + BarsSince(IUp=1) * (H > TBnd);

IDn:= (L < LBnd) * Ref((L >= LBnd),-1);
CntDn:= IDn + BarsSince(IDn=1) * (L < LBnd);
CntUp; -CntDn;

EXPERT
{Name: %Bands}

Symbols tab.
{Name: %BandUp}
FmlVar("% BandsCount","CNTUP") >= 1
{Graphic: Dot, Small, Green, Above price plot}

Symbols tab.
{Name: %BandDn}
FmlVar("% BandsCount","CNTDN") >= 1
{Graphic: Dot, Small, Magenta, Below price plot}



I found a problem with the %Bands formulas posted yesterday. No matter
what optional parameters are entered for EMA length or % bandwidth, the
Expert appears to read only the default values. As a result, when using
other than default parameters, the coloured dots appear in inappropriate
places. If the coloured dots are considered unnecessary the Expert can
simply be detached.

Alternatively, below is a hard-coded version. There is no screen to
enter optional parameters. Instead, plot the %Bands formula,then
right-click on one of the bands, select '%Bands Properties', then the
'Formula' tab, and change the parameters in the first two lines of the
%Bands formula; click 'OK'. Or make the change in the Formula Editor. 
The values need to be entered only once, in the %Bands formula; the
%BandsCount formula and the Expert will take their values from that. 
For regular use, get the display to your liking, then create a template.

{NAME: %Bands}

Pds:= 21; {ENTER EMA LENGTH}

Pct:= 2.5; {ENTER PERCENT BANDWIDTH}

MA:= Mov(C,Pds,E);
TBnd:= MA*(1+Pct/100);
LBnd:= MA*(1-Pct/100);
MA; TBnd; LBnd;


{NAME: %BandsCount}

{USE WITH %BANDS FORMULA}

TBnd:= FmlVar("%Bands","TBND"); 
IUp:= (H > TBnd) * Ref((H <= TBnd),-1);
CntUp:= IUp + BarsSince(IUp=1) * (H > TBnd);

LBnd:= FmlVar("%Bands","LBND"); 
IDn:= (L < LBnd) * Ref((L >= LBnd),-1);
CntDn:= IDn + BarsSince(IDn=1) * (L < LBnd);
CntUp; -CntDn;


EXPERT

{Name: %Bands}

Symbols tab.
{NAME: %BandUp}
FmlVar("%BandsCount","CNTUP") >= 1
Graphic tab: Dot, Small, Green, Above price plot

Symbols tab.
{NAME: %BandDn}
FmlVar("%BandsCount","CNTDN") >= 1
Graphic tab: Dot, Small, Magenta, Below price plot



To unsubscribe from this group, send an email to:
realtraders-unsubscribe@xxxxxxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/