Rank: Newbie
Groups: Registered, Registered Users Joined: 8/25/2012(UTC) Posts: 8
|
hi,
what i'm looking for is how to draw two horizontal and parallel lines centred on the weighted regression line of (O+H+L+2*C)/5 and separated from it by 2*standard deviation to catch the volatility.
The bands will redraw each time the regression line of is out of the bands following the trend and stay the same if the regline is inside the bands.
i have tried to program that with the code bellow but it's not perfect. As said by wabbit, it can be done by MDK writing an external function, but i don't know how to do it :-( .
tx again for helping me
Code:
F:=LinearReg((O+H+L+2*C)/5,3);
Et:=Stdev(F,7);
bh:=F+(2*Et);
bb:=F-(2*Et);
t1:=If(Cum(1) less than 8,bh,If(fless than PREV,If(f less than Ref(bb,-1),bh,PREV),bh));
t2:=If(Cum(1)less than 16,bb,If(t1 different than Ref(t1,-1),t1-2*(t1-f),If(f greather than PREV,PREV,bb)));
t1:=If(t2 different than Ref(t2,-1),t2+2*(f-t2),If(f greather than PREV,bh,PREV));
t2:=If(Cum(1) less than 16,bb,If(t1 different than Ref(t1,-1),t1-2*(t1-f),If(f greather than PREV,PREV,bb)));
t2;t1;(t1+t2)/2;
The initial and real code from Prorealtime for Mogalef Bands is the following:
Code:
CP=(open+high+low+2*close)/5
F=LinearRegression[3](CP)
E=std[7](F)
if barindex less than 8 then
Mediane = undefined
BandeHaute = undefined
BandeBasse = undefined
Else
BandeHaute = F+(E*2)
BandeBasse = F-(E*2)
if F less than BandeHaute[1] and F greather than BandeBasse[1] then
BandeHaute=BandeHaute[1]
BandeBasse=BandeBasse[1]
endif
Mediane =(BandeHaute+BandeBasse)/2
Endif
Return BandeHaute , Mediane , BandeBasse
problems with greather and less than signs !!!
|