hi,
i am trying to set stoploss from the tradeprice (close) to the previous candle low but it keeps changing. how do i fix it?
if not onmarket and longconditions and buyentry then
buy 1 contracts at market
endif
longstoploss = (close - low[1])*10000
longtarget = longstoploss
set stop ploss longstoploss
set target pprofit longtarget
thank you
Move line 5 to in between line 2 and 3, just after BUY.
You should use PipSize, not 10000, to make your code portable. You can remove that multiplication if you also remove the leading “p” from PLOSS and PPROFIT.
Each time your code is read, your lines 5 and 6 are recalculated, just place them where they are only read just one time when you launch your order.