See help for this method - https://www.mql5.com/en/docs/standardlibrary/tradeclasses/csymbolinfo/csymbolinfoask:
Note
The symbol should be selected by Name method.
- www.mql5.com
Hi Rosh,
can you write the solution here? :)
CSymbolInfo sym;
int OnInit()
{
sym.Name(_Symbol); <----? this one?
double askprice =sym.Ask();
Print ( "askprice =", Ask());
}
// still doesnt work. Got zero as answer.
#include <Trade/SymbolInfo.mqh>
CSymbolInfo sym;
int OnInit()
{
sym.Name(_Symbol); <----? this one?
double askprice =sym.Ask();
Print ( "askprice =", Ask());
}
// still doesnt work. Got zero as answer.
Try to call RefreshRates() method before you try to get any rates.
Hi,
I attempted with sym.Refreshrate(); , but still dont work. Can you try it in your metatrader5? Something wrong with my metatrader?
hi! Thanks a lot guys! =) it is working now!
I am also having this problem.
thanks
Could you please say what it was that you did to fix your error please?
I am also having this problem.
thanks
This code should work correctly
#include <Trade/SymbolInfo.mqh> CSymbolInfo sym; int OnInit() { sym.Name(_Symbol); if(sym.RefreshRates()) { double askprice=sym.Ask(); Print("askprice =",askprice); } }
Hi All,
I have similar problem, but with "LastHigh()" and "LastLow()" methods from CSymbolInfo. I have tried all the above suggestions, but I still get a ZERO value returned for these.
I can get valid numbers for others like AskHigh(), Ask(), etc... So, I don't have a clue what wrong at this point.
Any assistance/suggestions would be appreciated.
Thanks in advance.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
CSymbolInfo sym;
int OnInit()
{
double askprice =sym.Ask();
Print ( "askprice =", Ask());
}
//I got the result : askprice = 0. I cant manage to get the last ask price from OOP. So it is bug in SymbolInfo.mqh?
What is wrong here?