Code Snippet – Recover to Break-even
Forums › ProRealTime English forum › ProOrder support › Code Snippet – Recover to Break-even
- This topic has 2 replies, 2 voices, and was last updated 6 years ago by GraHal.
Tagged: Break Even, BreakEven
-
-
01/23/2018 at 3:24 PM #60331
Anybody please have / could code a code snippet to achieve the following in an Auto-Trade.
Please feel free to add / amend / improve the spec …- Loss > X points
- Recover back to Y% of Loss?
- Exit trade if momentum < Z at Y% of Loss.
The logic in my mind / experience is that if the loss > x points and there is then a good run up / down (back to breakeven / near) then the trade is likely to retrace again so I exit, breathe a sigh of relief and go make a coffee! 🙂
Above logic is more suited to short term trades / intraday.
I recall this being discussed and have searched on here with no success.
Thank You
GraHal
PS I am working on a solution myself, but any suggestions would be appreciated and would then be here for the benefit of others … until we get the ‘snippet repository’?? 🙂01/23/2018 at 8:19 PM #60347Hi Grahal, how you doing? Have been taking a break from the site but couldn’t resist having a go at this. I haven’t tested it but it should be there or thereabouts, any questions give me a shout.
1234567891011121314151617181920212223ONCE PercentofMAE = 0.8 // 80% as decimalONCE MinimumMomentum = 10ONCE MaxAEPermitted = 50 // Max loss to reach to trigger conditions// MaxAE needs to be set to 0 when opening a positionif longonmarket thenif close < positionprice thenLossNow = abs(close - positionprice)MaxAE = MAX(MaxAE,LossNow)if MaxAE > MaxAEPermitted thenc1 = LossNow < MaxAE*PercentofMAEc2 = Momentum[12](close) < MinimumMomentumif c1 and c2 thensell at marketendifendifendifelsif shortonmarket thenif close > positionprice then// ...endifendif3 users thanked author for this post.
01/23/2018 at 10:39 PM #60353 -
AuthorPosts
Find exclusive trading pro-tools on