[MQL4] Difference between SymbolInfoDouble(_Symbol, SYMBOL_ASK) and Ask (predefined variable)

 

Hi, would anyone know the difference between:

a) double SymbolInfoDouble(_Symbol, SYMBOL_ASK), and

b) double Ask (i.e. predefined variable)

The documentation tells me at "MQL4 Reference  /  Predefined Variables / Ask" that this is the latest known seller's price (ask price) for the current symbol. The RefreshRates() function must be used to update.

But if I use it directly in my OrderSend() function, isn't it the latest ask price then? When do I need to do a RefreshRates()? Also, how different is it to obtaining the ask price via SymbolInfoDouble(_Symbol, SYMBOL_ASK)?

Should I be using:

OrderSend(_Symbol, OP_BUY, lots, Ask, 30, stoploss);

or

double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

OrderSend(_Symbol, OP_BUY, lots, ask, 30, stoploss);

Thanks.

 

Ask is the Ask price when OnTick() was called.

While OnTick() is being executed, the Ask price may change.

You can make sure that Ask is updated by using RefreshRates().

You can also get the latest ask price with SymbolInfoDouble.

You can also use SymbolInfoDouble if you want values for a symbol that is not the chart symbol.

 

Thanks for that. So I would use it this way:

RefreshRates(); // gets latest Ask
OrderSend(_Symbol, OP_BUY, lots, Ask, 30, stoploss);

I'm actually questioning why we would need the latest ask price, as this is a market order i.e. OP_BUY would by default execute at the current market ask price, irrespective of what ask price I pass to OrderSend, or if it's up-to-date via use of RefreshRates(), or SymbolInfoDouble(). Or am I missing something?

Reason: