DEFPARAM CumulateOrders = false
//INDICATORS//
mm3= exponentialaverage[200*3]
mm2= exponentialaverage[200*1.5]
mm1= exponentialaverage[200*1]
PARABOLIC = SAR[0.001,0.001,0.2]
C1 = PARABOLIC>HIGH //RED SAR = SHORT
C2 = PARABOLIC<LOW //GREEN SAR = LONG
Spread = 1.1
//
//MONEY MGT//
Equity = (Strategyprofit+20000)
Risk = round(Equity/100000)
Losses = positionperf(1)<0 and positionperf(2)<0 and positionperf(3)<0
streak = positionperf(1)>0 and positionperf(2)>0 and positionperf(3)>0
if losses then
n = max(abs(round(max(3+risk-2,risk-2))),2)
elsif not losses then
n = max(abs(round(max(3+risk,risk))),2)
endif
if streak then
n = max(abs(round(max(5+risk,risk))),2)
endif
//
T1 = (barindex-tradeindex>=3)
T2 = (barindex-tradeindex>=3)
//ENTER LONG//
if (mm1>mm2 and mm2>mm3) and c2 AND T1 then
buy n contract at breakeven+spread*pipsize limit
breakeven = parabolic
if T2 and longonmarket then
sellshort at breakeven+spread*pipsize stop
endif
endif
//ENTER SHORT//
if (mm1<mm2 and mm2<mm3) and c1 and T1 then
sellshort n contract at breakeven-spread*pipsize limit
breakeven = parabolic
if T2 and shortonmarket then
exitshort at breakeven-spread*pipsize stop
endif
endif