ChartsView - Stock Trading Community

Mogalef Bands code Metastock

More
13 years 4 months ago - 13 years 4 months ago #504 by remo
{ USER }
Pd1:=Input("Regression Periods",3,100,3);
Pd2:=Input("Standard Deviation Periods",3,100,7);
Pd3:=Input("Standard Deviations",1,5,2);
{ DEFINE }
AP:=(H+L+O+2*C)/5; { Price }
LR:=LinearReg(AP,Pd1); { Moving Regression line }
SD:=Stdev(LR,Pd2); { Standard Deviation }
{ LATCH }
x:=If(PREV=0, { initial or reset }
LR, { store }
If(LR>PREV+Pd3*ValueWhen(1,PREV=0,SD) { over }
OR LR<PREV-Pd3*ValueWhen(1,PREV=0,SD), { under }
0, { reset }
PREV)); { keep }
{ BANDS }
Middle:=ValueWhen(1,Ref(x,-1)=0,x); { Get LR value from point in time }
SD:=ValueWhen(1,Ref(x,-1)=0,SD); { Get SD value from point in time }
{ PLOT }
Middle+Pd3*SD; { Top - Green }
Middle-Pd3*SD; { Bottom - Red }
Middle; { Blue }
LR; { White }
Last edit: 13 years 4 months ago by remo.
The following user(s) said Thank You: Libero

Please Log in or Create an account to join the conversation.

Moderators: remo
Time to create page: 0.088 seconds
Powered by Kunena Forum