- The “take profit closure” is not managed by MT5. It is managed by your broker.
- Your TP was 1.6 PIPs below your entry price. You didn't add the spread. That is trivial, not “very large.”
First of all I would like to thank you for your reply. I'll try to explain my problem better, the EA works with a system similar to the martingale system. once certain levels are exceeded, a position with an increased lot is opened, the take profits of all positions are moved to the last useful take profit (tp of the last position). the take profit of the sell positions is calculated as follows:
double new_take_profit_sell = ask - (tp_pips_sell + pipsrecuperosell+spread_in_pips) * _Point; if (trade.Sell(new_lot_size_sell, NULL, 0.0, 0.0, new_take_profit_sell))
tp_pips_sell and pipsrecuperosell are int variables. also spread_in_pips are a int variables calculated in this way:
double spread = ask - bid; double spread_in_pips = spread / _Point;
in this way I should recover the spread present at the moment of opening the position, even if my broker does not have a fixed spread so I imagine that if it increases when the position is closed my profit will decrease.
as you can see in this image here is the correct behaviour of the system, where the progression closes at the right take profits and leads to a profit.
this is behavior that rarely occurs but which I would like to resolve because it leads to profit losses.
thank's
During very high volatility (you mentioned large candles), spreads can widen drastically, and increase slippage, affecting how, and if, orders are filled (and that includes T/P and S/L). In other words, since your stop was very small, the slippage affected the outcome due to the wide spread during that high volatility.
Some brokers honour limit orders and negative slippage does not occur, but other brokers convert limit orders into market orders when they are triggered and negative slippage can occur.
Open up a desktop MetaTrader terminal and study the tick data during the period so that you can see what really happened. If you find that it does not correspond with your expectations, then discuss the issue with your broker.
Also, just in case you may be misunderstand a few basic trading principles. The "spread" is a little more complex than you think. There is a Ask price and a Bid price. For Forex, MetaTrader charts only shows the bars/candles based on Bid prices, not Ask prices.
- A "buy" position opens at the Ask price and closes at the Bid price (stop-loss, take-profit, partial close, etc.).
- A "sell" position opens at the Bid price and closes at the Ask price (stop-loss, take-profit, partial close, etc.).
Enable the Ask price line on your chart so that you can track the current value visually.
EDIT: Sometimes it is best to filter your trading so that you don't trade or hold positions during high impact news events.
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use


Hello guys, I have some advice for an error that I can't understand. I developed an EA on mql5, everything works precisely, I only have one problem that I can't solve, sometimes (it happened 3 times in about a month) the set take profit is not respected and the position is even closed negatively. This all happens when there are very large candles. The error is not a few pips like a classic slippage but is a very large error. I attach the photo of the location. How can I solve the problem considering that the take profit closure is managed by MT5 and not by my EA? Thanks to anyone who can help