Skip to content
S&P 5007,722.60up +0.60%Nasdaq26,477.81up +1.18%Dow52,377.57up +0.03%DAX25,570.61down −0.08%GBP/USD1.3286down −0.17%EUR/GBP0.8375up +0.16%Brent110.74up +1.22%Gold4,067.0down −0.19%Bitcoin81,427up +0.78%Prices at 09:59
ChartsView

Mogalef Bands code Metastock

More
14 years 3 days ago - 14 years 3 days 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: 14 years 3 days ago by remo.
The following user(s) said Thank You: Libero

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

Moderators: remo
Powered by Kunena Forum
Use the arrow keys to move and Enter to openSearch every page

Share tips