How do I get the current spread in MQL5?

Rohan Gupta Asked 1 day ago 1.6K views

I want my EA to skip trades when the spread is too high. How can I read the spread in code?

๐Ÿ™2๐Ÿ™‚React
10
Report

Log in to report content.

For education only. This is not financial advice. Trading carries a high risk of loss.

Log in to reply.

1 Answer

Best answer

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.

Marcus LindqvistAlgo Trading and MQL5 Answered 1 day ago
15
๐Ÿ‘2โค๏ธ1๐Ÿ™3๐Ÿ™‚React
💬 Reply

Log in to reply.

Your Answer

Log in or sign up to answer this question.