How to get the ASK price when using TradeClass

#include <Trade\SymbolInfo.mqh>
CSymbolInfo mysymbol;
//+------------------------------------------------------------------+
//| Script program start [function](https://www.mql5.com/en/docs/constants/namedconstants/compilemacros)                                    |
//+------------------------------------------------------------------+
void OnStart()
{
double Ask=mysymbol.Ask();
Print("Ask is : ",Ask);
}

print result is 0.0, I don’t know why? maybe I missed something?

thanks your reply,

Add this in your code:

mysymbol.RefreshRates();

Where should I add it, like this ? :smiley:

#include <Trade\SymbolInfo.mqh>
CSymbolInfo mysymbol;
//+------------------------------------------------------------------+
//| Script program start function                                    |

mysymbol.RefreshRates();
//+------------------------------------------------------------------+
void OnStart()
  {
   double Ask=mysymbol.Ask();
   Print("Ask is : ",Ask);
  }

Ha! Point taken.

:smiley:

void OnStart()
  {
   mysymbol.RefreshRates();
   double Ask=mysymbol.Ask();
   Print("Ask is : ",Ask);
  }

Tanks so much! The first time to try mt5 TradeClass : -(