Forums › ProRealTime English forum › ProOrder support › Trailing stops remaining static when there are multiple positions › Reply To: Trailing stops remaining static when there are multiple positions
05/08/2019 at 2:52 PM
#97966
This should do it. At the end of the bar that it opens a trade on it adjusts the stop loss based on the actual position price before then checking to see if it needs to move it again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
sl = 144 slmove = 5 if longonmarket and sladj then slprice = positionprice - sl sladj = 0 endif if shortonmarket and sladj then slprice = positionprice + sl sladj = 0 endif if not onmarket and (your long entry conditions) then buy 1 contract at market slprice = close - sl sell at slprice stop sladj = 1 endif if not onmarket and your short entry conditions) then sellshort 1 contract at market slprice = close + sl exitshort at slprice stop sladj = 1 endif if longonmarket and high - sl > slprice + slmove then slprice = high - sl endif if shortonmarket and low + sl < slprice - slmove then slprice = low + sl endif sell at slprice stop exitshort at slprice stop |