Var:indzona1,valLong,valshort,miorsi,last;
Var:miaentryshort,miaentrylong,valentry;
var: go,cnt;
installstoploss(INTICK,20,"STOP",CHECKMax +EXITONLYIFCLOSEON);
installtrailingProfit(INTICK, 10, 5, "trailing",CHECKMax +EXITONLYIFCLOSEON);
installtakeProfit(INTICK, 20, "take",CHECKMax +EXITONLYIFCLOSEON);
miorsi = MOMENTUM(C,100,D);
///////////////////////////////////////////////////////////////////////////////////
if C[3] > C[10] and L < L[1] and L[1] < L[2] then
miaentrylong =1;
colorbar(fuchsia);
else
miaentrylong = 0;
endif;
if C[3] < C[10] and H > H[1] and H[1] > H[2] then
miaentryshort=1;
colorbar(blue);
else
miaentryshort =0; endif;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if miaentrylong[1] =1 and miaentrylong[2]= 0 and miaentrylong[3] = 0 then valLong = llv (l, 2); endif;
if miaentrylong[1] =1 and miaentrylong[2] = 0 and miaentrylong[3] = 0 then valShort = hhv (h, 2); endif;
if miaentryshort[1] =1 and miaentryShort[2] = 0 and miaentryShort[3] = 0 then valShort = hhv (h, 2); endif;
if miaentryshort[1] =1 and miaentryShort[2] = 0 and miaentryShort[3] = 0 then valLong = llv (l, 2); endif;
if vallong < vallong[1] then valentry = valshort; endif;
if valshort > valshort[1] then valentry = vallong; endif;
///////////////////////////////////////////////////////////////////////////////////
plotchart(valentry,0,black,solid,2);
IF LastOpIsStop = true THEN GO=1; ELSE GO=0;ENDIF;
CNT=CNT+1;
IF POSITIONDIR=0 AND CNT<=10 THEN
if H[1] >= valentry[1] and C < valentry and miorsi < 0 then ENTERSHORT (NEXTBAR, ATOPEN);endif;
if L[1] <= valentry[1] and C > valentry and miorsi > 0 then ENTERLONG (NEXTBAR, ATOPEN);endif;ENDIF;
if go = 1 and BarSince (positiondir=0)>3 then
if H[1] >= valentry[1] and C < valentry and miorsi < 0 then ENTERSHORT (NEXTBAR, ATOPEN);endif;
if L[1] <= valentry[1] and C > valentry and miorsi > 0 then ENTERLONG (NEXTBAR, ATOPEN);endif;
endif;
if go = 0 and BarSince (positiondir=0)>1 then
if H[1] >= valentry[1] and C < valentry and miorsi < 0 then ENTERSHORT (NEXTBAR, ATOPEN);endif;
if L[1] <= valentry[1] and C > valentry and miorsi > 0 then ENTERLONG (NEXTBAR, ATOPEN);endif;endif;
IF positiondir=1 and C < valentry and miorsi < 0 then exitlong(nextbar, atopen);endif;
IF positiondir=-1 and C > valentry and miorsi > 0 then exitshort(nextbar, atopen);endif;