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’?? 🙂
Hi 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.
ONCE PercentofMAE = 0.8 // 80% as decimal
ONCE MinimumMomentum = 10
ONCE MaxAEPermitted = 50 // Max loss to reach to trigger conditions
// MaxAE needs to be set to 0 when opening a position
if longonmarket then
if close < positionprice then
LossNow = abs(close - positionprice)
MaxAE = MAX(MaxAE,LossNow)
if MaxAE > MaxAEPermitted then
c1 = LossNow < MaxAE*PercentofMAE
c2 = Momentum[12](close) < MinimumMomentum
if c1 and c2 then
sell at market
endif
endif
endif
elsif shortonmarket then
if close > positionprice then
// ...
endif
endif
Hi AS, nice one! great to see you back!
Many thanks, looks good!
I’ll let you know how it goes.
Cheers
GraHal