Hi
Is possible to put in code stop loss variables betwen 100 and 500 or just stop loss that loss not excess 100 any trade
Please help my any idea ??
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
Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Thank you 🙂
You can set a stop loss at 100$ with:
set stop $loss 100
But since you are using dynamic position size, the stoploss size in points could be very tight sometimes (if position size is big).