Questions from Beginners MQL5 MT5 MetaTrader 5 - page 244

 
forexman77:
Can you tell me if there are any other quick ways to get the current price besides "SymbolInfoTick". Maybe there is a faster way to get the current quote?

SymbolInfoDouble can be used

withSYMBOL_BID andSYMBOL_ASK identifiers.

 
Fleder:

SymbolInfoDouble can be used

withSYMBOL_BID andSYMBOL_ASK identifiers.

Thank you!

It's not quite clear what follows from "SYMBOL_BID" (Bid is the best offer for sale). Is it still the current quote or the best market price from the ESN cup?

 
forexman77:

Thank you!

It's not quite clear what follows from "SYMBOL_BID" (Bid is the best offer to sell). Is it still the current quote or the best market price from the ESN cup?

The current quote and the best price in the ECN market cup are the same thing.

 
Fleder:

The current quote and the best price in the ECN Dock are one and the same.

In general, it turns out that if we use "SymbolInfoDouble" when querying, a trade at this price may not happen, i.e. it is the current Bid.

If we use "SymbolInfoTick", then the price was exactly there, i.e. this is the current price at which the last trade occurred, when using double last; // Current price of the last trade (Last)

 
forexman77:

In general, it turns out that if we use "SymbolInfoDouble" in the query, a trade at this price may not happen, i.e. it is the current Bid.

If we use "SymbolInfoTick", then the price was definitely there, i.e. it is the current price at which the last transaction took place.

Note

If this function is used to get information about the last tick, then it is better to useSymbolInfoTick(). It is quite possible that there has not been any quote for this symbol since the time the terminal connected to the trading account. In this case, the requested value will be undefined.

SymbolInfoTick may return an undefined value if there has not been a single tick since the terminal connected to the server.

SymbolInfoDouble excludes this situation.

 
Fleder:

Note

If the function is used to get information about the last tick, it is better to useSymbolInfoTick(). It's quite possible that there hasn't been any quote for this symbol since the terminal has been connected to the trading account. In this case, the requested value will be undefined.

SymbolInfoTick can return an undefined value if there has not been a single tick since the EA was connected to the chart.

SymbolInfoDouble excludes such a situation.

Got it. Thank you! Now the only thing to do is to find a simple code example to check how much time each function takes when called?
 
forexman77:
Got it. Thank you! Now all that's left is to find a simple code example to check how long it takes to call both functions?
uint start=GetTickCount();
// здесь Ваш код вызова 
Print("Вызов прошёл за = ",GetTickCount()-start);
 
barabashkakvn:

This trick will probably not work in this situation.

There will always be a zero undershoot.

TheSymbolInfoTick andSymbolInfoDouble functions are too fast- no longer than units of microseconds.

 
Fleder:

This trick will probably not work in this situation.

There will always be a zero undershoot.

TheSymbolInfoTick andSymbolInfoDouble functions are too fast- no longer than units of microseconds.

All the more interesting, there is an example code. We are waiting for result.
 
barabashkakvn:
Fleder:

This trick will probably not work in this situation.

There will always be a zero undershoot.

TheSymbolInfoTick andSymbolInfoDouble functions are too fast- no longer than units of microseconds.

In the script, I created this little thing:

void OnStart()
  {
uint start=GetTickCount();
double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
Alert("ask=",ask);
uint time=GetTickCount()-start;
Alert("time=",time);
   
  }
//+------------------------------------------------------------------+

time=0

SymbolInfoTick will be checked on Monday.