Mean-Reversion from May TASC
Posted: Mon Apr 29, 2019 7:34 am
Here is the code from the May TASC Mean-Reversion
Under the parameter tab
LN1 Double 10 0 100
LN2 Double 100 0 1000
Under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z: (C - sma)/dev,Width2,ColorBlack;
FillRgn(Z<= -1,Z,-1),Brush#5000FF00;
FillRgn(Z>=1,Z,1),Brush#50FF0000;
Here is the code for the long entry
Use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:(z < -1) & (sma > lma),Width2,ColorGreen;
here is the code for the long exit
use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:z > -0.5,Width2,Color Blue;
Here is the code for the sell short
use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:(z > 1) & (sma < lma),Width2,ColorRed;
Here is the code for the short exit
use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:z < 0.5,Width2,ColorViolet;
Under the parameter tab
LN1 Double 10 0 100
LN2 Double 100 0 1000
Under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z: (C - sma)/dev,Width2,ColorBlack;
FillRgn(Z<= -1,Z,-1),Brush#5000FF00;
FillRgn(Z>=1,Z,1),Brush#50FF0000;
Here is the code for the long entry
Use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:(z < -1) & (sma > lma),Width2,ColorGreen;
here is the code for the long exit
use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:z > -0.5,Width2,Color Blue;
Here is the code for the sell short
use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:(z > 1) & (sma < lma),Width2,ColorRed;
Here is the code for the short exit
use the same parameter tab
under the script tab
sma:= MA(c,LN1);
lma:= MA(c,LN2);
dev:= std(c,LN1);
z:= (C - sma)/dev,Width2,ColorBlack;
Event:z < 0.5,Width2,ColorViolet;