Problem with setting a break even level
Forums › ProRealTime English forum › ProOrder support › Problem with setting a break even level
- This topic has 6 replies, 3 voices, and was last updated 3 years ago by
Nicolas.
Viewing 7 posts - 1 through 7 (of 7 total)
-
-
05/08/2022 at 8:58 AM #192872123456789101112131415161718192021IF (c1 AND a2 ) AND ST<2 AND Not ShortOnMarket AND Not Daysforbidden And timeEnterBefore AND timeEnterAfter THENSELLSHORT 2 Perpoint AT c2 limitST=ST+1ENDIF// Conditions to exit short positionsIF SHORTONMARKET AND close < tradeprice - 6 THEN // if the price moves 5pts in my favour...if countofshortshares = 2 thenExitshort 1 PERPOINT at market //close half of the trade//SoldHalf = 1breakevenlevel = tradeprice //...calculate the level for a stop 5pts below the trade open price...endifIf COUNTOFSHORTSHARES=1 thenExitshort 1 PERPOINT at breakevenlevel limitendifEndif// Stops and targetsSET STOP ploss 8SET TARGET pPROFIT 14graph tradepricegraph breakevenlevel
I have an algo that closes half my position and sets a breakeven level .
My problem is that the instruction to exit at the break even level is ignored and exit happens at the stop level
105/08/2022 at 9:17 AM #19287605/08/2022 at 9:35 AM #192878It’s due to narrow SL and TP, try changing both to, say, 40 or 50 andit’ll work.
1 user thanked author for this post.
05/08/2022 at 9:59 AM #19287905/08/2022 at 11:25 AM #192883Yes, there were a couple of additional issues:
- use STOP instead of LIMIT to exit, as you are placing a pending order to exit at WORSE price
- use a variable (I named it FLAG) to signal that an exit at breakeven has been triggered, as it must be placed each new bar until hit (or TP is hit, of course); the exit order must be outside the conditional IF…ENDIF block.
I tested this code on Dax, 4h TF:
12345678910111213141516171819202122232425IF close crosses under average[100] and not onmarket THENSELLSHORT 2 Perpoint AT marketflag = 0ENDIF// Conditions to exit short positionsIF SHORTONMARKET AND close < tradeprice - 6 THEN // if the price moves 5pts in my favour…if countofshortshares = 2 thenExitshort 1 PERPOINT at market //close half of the trade//SoldHalf = 1breakevenlevel = tradeprice //…calculate the level for a stop 5pts below the trade open price…endifIf COUNTOFSHORTSHARES=1 thenflag = 1endifEndifIF flag = 1 thenExitshort 1 PERPOINT at breakevenlevel stopendif// Stops and targetsSET STOP ploss 500 //8SET TARGET pPROFIT 500 //14//graphonprice tradeprice(1)graphonprice breakevenlevel coloured(255,0,0,255)graph close < (tradeprice - 6)1 user thanked author for this post.
05/08/2022 at 12:20 PM #19288505/09/2022 at 8:11 AM #192913Keep in mind that you can now use the SET STOP BREAKEVEN instruction which is the best way to ask the broker your stoploss at breakeven
2 users thanked author for this post.
-
AuthorPosts
Viewing 7 posts - 1 through 7 (of 7 total)
Find exclusive trading pro-tools on
Similar topics: