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/09/2019 at 9:00 AM
#98031
I had a quick look at it and this should now prevent our stop loss getting too close. Not tested so if anyone can confirm it works as it should then please let me know.
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 38 39 40 41 42 43 |
//Vonasi Trailing Stop v3 //20190509 sl = 144 //Stop loss distance slmove = 5 //Price move needed to move stop minstop = 10 //Minimum stop distance allowed sl = max(sl, minstop) 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 = min(high - sl, close - minstop) endif if shortonmarket and low + sl < slprice - slmove then slprice = max(low + sl, close + minstop) endif sell at slprice stop exitshort at slprice stop |