Professional Documents
Culture Documents
Mean Reversion
Mean Reversion
SetPositionSize(1,spsShares);
SetChartOptions( 0, chartShowArrows | chartShowDates );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle |
ParamStyle( "Style" ) | GetPriceStyle() );
SetBarsRequired(10000,0);
FastEMAPeriod = Param("FastEMAPeriod",15,1,100,1);
SlowEMAPeriod =Param("SlowEMAPeriod",180,1,200,1);
per1= 15;
per2= 2;
EMA1= EMA(C,FastEMAPeriod);
EMA2= EMA(C,SlowEMAPeriod);
Buy=Sell=Short=Cover=Null;
sl=sls=tgt=tgts=0;
for(i=200; i<BarCount; i++)
{
if(sl==0 AND uptrend[i] AND supp[i])
{ Buy[i]=1; sl= Ll[i]; tgt= H[i];}
if((L[i]<sl OR ress[i]) AND sl>0)
{ if(L[i]<sl)SellPrice[i]= sl; Sell[i]= 1; sl=tgt=0;}