Multiple ATR trailing stops
9 replies
nolte
7 years ago #115119
I’m trying to create an EA that uses multiple ATR stop losses.
1: Stop trails up to breakeven, using “fast ATR” stop loss, and holds.
2: Stop trails up farther when “slow ATR” is greater than breakeven.
3: Stop moves back and trails up using “trend ATR” once “trend ATR” is greater than breakeven.
I’ve tried to follow the Trailing Stop Simulation the best possible, the problem is it will only move the stop loss using whole numbers, 102, 103, 104… ect. Any help would be appreciated.
tomas262
7 years ago #136941
Change variable type for stop prices from “int” to “double”. It should help
nolte
7 years ago #136953
Thank you tomas, that solved the whole number problem.
Now there’s a new problem, the simplest way to explain it is with an example:
GBP/USD stoploss should be at 1.9206, my EA is trying to place it at .00019206. With the JPY pairs it is placing it at 1.0232 instead of 102.32.
I have double checked my settings and conditions and I just don’t see anything wrong. It seems to be following all the conditions correctly because 1.9206 is the correct stoploss, it just has the decimal places for the pips wrong (see the picture). Thank you for your help!
tomas262
7 years ago #137017
Ok, will check it and let you know
tomas262
7 years ago #137025
I have noticed that you also define stop-loss incorrectly. The stop range is supposed to be in pips but when you multiply ATR x factor it is like 0.002 x 2. The result is not in pips. You would have to use ConvertToPips(ATR x factor) to get SL pips range value
nolte
7 years ago #137064
I will make the changes and check it.
nolte
7 years ago #137103
I made the changes but it doesn’t seem to work right, the only way it works correctly is (ATR x factor).
tomas262
7 years ago #137170
Ok, will try to do changes to make it work
tomas262
7 years ago #137320
Hello,
the problem is when you set price for “Move SL To” as “Fixed Price”. There is a bug that causes the calculated price to be multiplied. Hence the incorrect final price.
To solve this you need to define price using formula as shown in edited example of yours. Look at the attachment.
nolte
7 years ago #137366
Thank you, I’ll check it out.
Viewing 9 replies - 1 through 9 (of 9 total)