Hello,
I need help in the coding of a trailing stop strategy.
As a hypothetical example I am risking 200 (1xATR) pips stop loss to take profit at 800 (4xATR) pips limit order. Q: What is the code to trail my stop to break even after the price has moved 400 (2xATR) pips in my favour?
Thank you
You can test this simple code example, for a long order: (I assume “400” is in points, not money).
if not onmarket then
breakeven=0
endif
if longonmarket then
if close-tradeprice(1)>=400 then
breakeven = 1
endif
if breakeven then
sell at tradeprice(1) stop
endif
endif
This may have been better posted in the ProOrder Forum as it is auto trading related rather here which is for indicator related topics.
Just pointing it out as I spotted that this is only your third topic started and you might not have worked out where the best place to go for help is yet! 🙂
Good spot @Vonasi ! You are a moderator who does not know himself! Interested?
Good spot @vonasi ! You are a moderator who does not know himself! Interested?
I’m flattered but not sure what it would really involve. Do you have my email address on record to email me to chat about it?
If you are serious that is!