Automatically Move To Break even Code
Forums › ProRealTime English forum › ProOrder support › Automatically Move To Break even Code
- This topic has 13 replies, 5 voices, and was last updated 4 years ago by deletedaccount051022.
Tagged: BreakEven, positionperf
-
-
08/13/2020 at 12:30 PM #14150608/13/2020 at 1:07 PM #141509
Not tested:
12345678910111213If not OnMarket thenNewSL = 0EndifIf NewSL = 0 and PositionPerf > 0 ThenPips = close * PositionPerf / pipvalueIf Pips >= 20 ThenNewSL = tradepriceEndifEndifIf NewSL > 0 ThenSELL at NewSL STOPEXITshort at NewSL STOPEndifno matter whether you’re Long or Short.
08/13/2020 at 1:10 PM #141510Sorry, line 5 should read:
1Pips = tradeprice * PositionPerf / pipvalue08/13/2020 at 1:12 PM #141511Many examples in the lists below:
08/13/2020 at 1:30 PM #14151508/13/2020 at 1:43 PM #141517No matter where.
08/13/2020 at 1:53 PM #141519Thanks but I’m still having some trouble,
Does this look right,
12345678910111213141516171819202122232425262728293031323334// Conditions to enter long positionsIF NOT LongOnMarket AND YourConditions THENBUY 1 CONTRACTS AT MARKETENDIF// Conditions to exit long positionsIf LongOnMarket AND YourConditions THENSELL AT MARKETENDIF// Conditions to enter short positionsIF NOT ShortOnMarket AND YourConditions THENSELLSHORT 1 CONTRACTS AT MARKETENDIF// Conditions to exit short positionsIF ShortOnMarket AND YourConditions THENEXITSHORT AT MARKETENDIF// Stops and targets : Enter your protection stops and profit targets hereIf not OnMarket thenNewSL = 0EndifIf NewSL = 0 and PositionPerf > 0 ThenPips = tradeprice * PositionPerf / pipvalueIf Pips >= 20 ThenNewSL = tradepriceEndifEndifIf NewSL > 0 ThenSELL at NewSL STOPEXITshort at NewSL STOPEndif08/13/2020 at 3:03 PM #141522For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! << 🙂
Actually my correct code should be written as (after testing it on Dax):
12345678910111213If not OnMarket thenNewSL = 0EndifIf NewSL = 0 and PositionPerf > 0 ThenPips = tradeprice * PositionPerfIf Pips >= 20*pipsize ThenNewSL = tradepriceEndifEndifIf NewSL > 0 ThenSELL at NewSL STOPEXITshort at NewSL STOPEndif1 user thanked author for this post.
08/14/2020 at 2:51 AM #141557Thanks Roberto,
However, I’m still getting a code invalid response. Is there something I’m missing?
12345678910111213141516171819202122232425262728293031323334// Conditions to enter long positionsIF NOT LongOnMarket AND YourConditions THENBUY 1 CONTRACTS AT MARKETENDIF// Conditions to exit long positionsIf LongOnMarket AND YourConditions THENSELL AT MARKETENDIF// Conditions to enter short positionsIF NOT ShortOnMarket AND YourConditions THENSELLSHORT 1 CONTRACTS AT MARKETENDIF// Conditions to exit short positionsIF ShortOnMarket AND YourConditions THENEXITSHORT AT MARKETENDIF// Stops and targets : Enter your protection stops and profit targets hereIf not OnMarket thenNewSL = 0EndifIf NewSL = 0 and PositionPerf > 0 ThenPips = tradeprice * PositionPerfIf Pips >= 20*pipsize ThenNewSL = tradepriceEndifEndifIf NewSL > 0 ThenSELL at NewSL STOPEXITshort at NewSL STOPEndifI appreciate your time in helping me.
08/14/2020 at 7:07 AM #14157308/14/2020 at 7:53 AM #14157708/14/2020 at 12:29 PM #141626This code works fine (I tested it on Dax and EurUsd, Daily TF):
1234567891011121314151617181920212223242526272829DEFPARAM CumulateOrders = falseONCE MA = 100 //100ONCE t = 0 //0 = smaONCE N = 50 * pipsize //50IF NOT LongOnMarket AND close crosses over average[MA,t] THENBUY 1 CONTRACTS AT MARKETENDIFIf Not SHortOnMarket AND close crosses under average[MA,t] THENSELLSHORT 1 CONTRACT AT MARKETENDIFIf not OnMarket thenNewSL = 0EndifIf NewSL = 0 and PositionPerf > 0 ThenPips = (tradeprice * PositionPerf)If Pips >= N ThenNewSL = tradepriceEndifEndifIf NewSL > 0 ThenSELL at NewSL STOPEXITshort at NewSL STOPEndifSET TARGET pPROFIT 700 //700-pip goal//GraphOnPrice TradePrice coloured(0,0,255,255) AS "BE TradePrice"GraphOnPrice TradePrice + N coloured(255,0,0,255) AS "Activation"GraphOnPrice TradePrice + Pips coloured(0,128,0,255) AS "Temp profit"graph positionperfAppending GraphOnPrice and Graph at the end of your code greatly enhances debugging.
1 user thanked author for this post.
08/17/2020 at 5:01 AM #14179408/20/2020 at 3:31 PM #142141This is really helpful – super grateful!
-
AuthorPosts
Find exclusive trading pro-tools on