How do I get the current spread in MQL5?
I want my EA to skip trades when the spread is too high. How can I read the spread in code?
For education only. This is not financial advice. Trading carries a high risk of loss.
I want my EA to skip trades when the spread is too high. How can I read the spread in code?
For education only. This is not financial advice. Trading carries a high risk of loss.
Log in to reply.
You can read it in points with SymbolInfoInteger, or calculate it from Ask and Bid:
long spreadPoints = SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
double spreadPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK) - SymbolInfoDouble(_Symbol, SYMBOL_BID);SYMBOL_SPREAD returns the spread in points, not pips. On a 5 digit forex symbol, 10 points equal 1 pip. The spread can change from tick to tick, so check it at the moment you send the order.
Log in to reply.