Skip to content
S&P 5007,818.93up +0.58%Nasdaq27,599.89up +0.45%Dow51,521.28up +0.49%DAX25,449.19up +0.77%GBP/USD1.3261down −0.11%EUR/GBP0.8479down −0.01%Brent101.74up +1.15%Gold4,180.5down −0.16%Bitcoin85,321down −0.26%Prices at 02:26
ChartsView

Mogalef Bands code Metastock

More
13 years 11 months ago - 13 years 11 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 11 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
Powered by Kunena Forum
Use the arrow keys to move and Enter to openSearch every page

Share tips