Ticks

Back to topics list To post a new topic, please log in or register
avatar
2
deltatangoxray 2016.08.17 18:41
 

How can I get the current price (last tick) of a given symbol? I have tried calling the MqlTick and SymbolInfoTick, but this has failed to return the last tick.

Code:
MqlTick lastTick;
SymbolInfoTick(Symbol(),lastTick);
double price = lastTick.last;

Output:
price = 0.000000000



Thank you for any assistance on this.
avatar
2017
gooly 2016.08.17 19:55 #
 
Try lastTick.Bid and lastTick.Ask.
avatar
1200
FMIC 2016.08.17 23:55 #
 

Gooly is correct, as the "lastTick.last" value is only valid in a MT5/MQL5 environment. However, use the lowercase version of "lastTick.bid" and/or "lastTick.ask" (as the names are case sensitive).

Also remember to check the return results of the SymbolInfoTick() and to address any 4066 and 4073 errors with a respective delay if using multi-symbol (due to the symbol in question not being yet loaded during the first call to the function).

PS! Remember that in the Strategy Tester you cannot use multi-symbol and the function will cause a 4059 error for any symbol other than the one being tested.

Back to topics list  

To add comments, please log in or register