Urgent: ATR Stop Loss values wrong
-
Urgently need help with this one its my last step before my EA being completed
Heres the problem
In this real example the ATR value = 0.00228
1.27712 (Candle High) + 0.00228 (ATR value) should = 1.27940
But as you can see here in this image

My stop loss is 8 points below what it should be mathematically.This is my current settings

-
Are you completely sure that formula is correct?
-
@Alfie
Your manual calculation was based on actual price.Your formula price was based on candle price.
The 8-points is apparently bid-ask spread.
Check if the candle price is bid/ask/buy/sell price
-
@Alfie
The candle price is sell price (as checked in MT5).That is why you got your expected price in sell order but not in buy order.
-
@sktsec Oh ok thanks, and how do I change that? if you need a shared link let me know
-
This is my current settings

i think the difference is because the block calculate for stop loss the high (or low) value of candle ID 1 while the adjust field add (or subtract) the exact value of ATR in the same moment as the order is opened (so ATR value on candle ID0)
-
That makes sense, I will often use ID1 just so current candle doesn't affect values.
-
@jstap Yes me too. But i want ask to you, regard that adjust field, can we choose the candle ID? I mean inside this NULL,0,14,0
(my coding knowledge is less than zero)
-
The 0 on the end is the candle ID (is called offset, a lot of code has it) set it to whatever candle you want the range to start from. The 0 at the start is the timeframe, 0=current, on MT4 you can use a int number, MT5 you need to use code like PERIOD_CURRENT
-
@jstap Changed the number at the end to 1 and now the EA is fully working with the correct stops, thanks again very appreciated
-
You are welcome
-
@jstap said in Urgent: ATR Stop Loss values wrong:
The 0 on the end is the candle ID (is called offset, a lot of code has it) set it to whatever candle you want the range to start from. The 0 at the start is the timeframe, 0=current, on MT4 you can use a int number, MT5 you need to use code like PERIOD_CURRENT
well! thank you for explanation