First you should research what a "re-quote" is. You should learn what execution policies are and the difference between "Instant" and "Market" execution policies.
You should also learn about maximum deviation (slippage) and how to set it in your order placement. You should also decide how you should handle re-quotes according to your trading strategy.
And then finally, once you understand all that, then you can go back to your MQL code and apply that logic to it.
Forum on trading, automated trading systems and testing trading strategies
Avoid Slippage without Pending Orders.
Fernando Carreiro, 2021.07.26 22:56
As I have already explained, for "Market Execution" policy, the opening price is ignored and you will get whatever price is available at the time.
With "Instant Execution" policy, then the price is important and if it deviates too far away from the current price, you will get a "requote" error.
Remember that Buy orders open at the Ask price and close at the Bid price, and Sell orders open at the Bid price and close at the Ask price.
EDIT: Also read the following:
- Instant Execution Policy
- Market Execution Policy
- Request Execution Policy (I know nothing about this one. I've never encountered it before)
- Exchange Execution Policy (I also have no experience with this one)
Then please take the time to read about "Instant Execution Policy"!
You have set a maximum deviation of 30 points when XAUUSD can easily have a minimum spread of 300 spread, so 30 point maximum slippage is extremely tight.
So print out both the Ask and Bid Prices with the order details, including the error code.
Also remember, that you Buy at the Ask price and you Sell at the Bid price.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use