This is for trades only, not pending orders. The problem comes from the fact that we send the request of our future trade in absolute values - SL and TP values are absolute, like 1.23456, not relative values to the open price, like 0.0010. Then on the server the Open Price can be something different than what we wanted, but SL and TP will be the absolute values we have sent. So eventually our Open Price will shift towards SL or TP.
In the EA I decided this - when such thing happens, to modify SL and TP relative to the open price. For this, the EA just compares the Open Price we initially wanted with the real Open Price at which the trade was opened. If there is a difference between those two prices - SL and TP are modified immediately. But pending orders are not monitored for this. It can be done, I guess, but now this only works for trades.
My idea is... isn't the server responsible to open pending orders at the price we want? There is no reason for big slippage, because there is no network delay of the request. The pending order exists on the server and the server is responsble to open it on the correct price. The server have the most fresh quotes. 30 pips difference.... I don't know, is this because the market was really really weird at that time or it was some bug from the broker?