break even stop loss for multiple position s
Forums › ProRealTime English forum › ProOrder support › break even stop loss for multiple position s
- This topic has 5 replies, 2 voices, and was last updated 5 years ago by Nicolas.
-
-
12/22/2018 at 6:10 PM #87599code for multiple positions12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485//-------------------------------------------------------------------------// Main code : MySystem(159)//-------------------------------------------------------------------------// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedx=3if not onmarket and time>=080000 and time<=210000 then// Conditions to enter long positionsindicator1 = Average[7](high)c1 = (close >= indicator1)IF c1 THENBUY 1 PERPOINT AT lowest[3](low)+2 limitENDIF// Conditions to enter short positionsindicator2 = Average[7](high)c2 = (close <= indicator2)IF c2 THENSELLSHORT 1 PERPOINT AT highest[3](high)-x limitENDIFendifif longonmarket then// Conditions to enter long positionsindicator1 = Average[7](high)c1 = (close >= indicator1)IF c1 THENBUY 1 PERPOINT AT lowest[3](low)+2 limitENDIFendifif shortonmarket then// Conditions to enter short positionsindicator2 = Average[7](high)c2 = (close <= indicator2)IF c2 THENSELLSHORT 1 PERPOINT AT highest[3](high)-x limitENDIFendifstartBreakeven = 10//how much pips/points in gain to activate the breakeven function?PointsToKeep = 1//how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)set stop loss 10set target profit 500//reset the breakevenLevel when no trade are on marketIF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF shortonmarket AND tradeprice(1)-close>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENexitshort AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---
I want to use the above for n amount/pt
will this work? if not what changed I need to make
the idea when not market conditions c1 met open long and if the market moves in my favor, move the stop loss to break even
add one more position move the stop loss to break keep adding till amount/pt “n” is reached
01/02/2019 at 4:15 PM #8789901/02/2019 at 4:40 PM #8790501/03/2019 at 3:10 PM #8795201/03/2019 at 3:22 PM #87956let me explain in details
say buy 1 perpoint at close+x stop
if position is moved in my favour , the code moves to break even( based on points to keep)
upto this point it works fine
*****************************
If I add one more position the this also need to be moved to break even if the profit is my favor based on the number of points to keep
01/04/2019 at 1:54 PM #87989Ok, but that’s not possible to set individual stoploss this way. Once a pending order is triggered it closes all the orders at the same time.
It could be managed with partial closure, but it is still not possible with a real account, but only in backtesting.
-
AuthorPosts
Find exclusive trading pro-tools on