SymbolInfoTick() doubt

 
Hello everyone. I'm trying to run a very simple EA to get the tick information but I can't get the volume.

Can anyone tell me why it is?

Here the EA

MqlTick L_Tick;

void OnTick()
{
   if(SymbolInfoTick(Symbol(),L_Tick))
     Print(L_Tick.time, ": Bid = ",L_Tick.bid, " Ask = ",L_Tick.ask,"  Volume = ", L_Tick.volume);

   else 
      Print("SymbolInfoTick() failed, error = ",GetLastError());   
}
Here the output

1

Thank you!!

 

Yes, there is a problem. Additionally, queries (SYMBOL_VOLUME and SYMBOL_VOLUME_REAL) also do not work.

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   long volume=SymbolInfoInteger(Symbol(),SYMBOL_VOLUME);
   double volume_real=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_REAL);

   MqlTick m_tick;
   if(!SymbolInfoTick(Symbol(),m_tick))
      return;
   Print(TimeToString(m_tick.time,TIME_DATE|TIME_MINUTES),",",
         " Bid ",DoubleToString(m_tick.bid,Digits()),
         " Ask ",DoubleToString(m_tick.ask,Digits()),
         " Volume ",IntegerToString(m_tick.volume),
         " Volume real ",DoubleToString(m_tick.volume_real,0),
         " SYMBOL_VOLUME ",IntegerToString(volume),
         " SYMBOL_VOLUME_REAL ",DoubleToString(volume_real,0));
  }
//+------------------------------------------------------------------+


Result:

1 (AUDUSD,H1)   2020.04.22 09:01, Bid 0.63184 Ask 0.63195 Volume 0 Volume real 0 SYMBOL_VOLUME 0 SYMBOL_VOLUME_REAL 0
Files:
1.mq5  3 kb
 
Thanks for your quick response.

Do you know if it is a temporary or permanent problem?

Do you know an alternative way to get the tick volume?
 
karachiento :
Thanks for your quick response.

Do you know if it is a temporary or permanent problem?

Do you know an alternative way to get the tick volume ?

Try restarting the computer (not the terminal, namely the computer). Also indicate the equipment on which there is a problem (after starting the terminal, take the first three lines from the Journal tab).

I have this:

Terminal        MetaTrader 5 x64 build 2380 started for MetaQuotes Software Corp.
Terminal        Windows 10 build 19041, Intel Core i3-3120M  @ 2.50GHz, 1 / 7 Gb memory, 66 / 415 Gb disk, IE 11, UAC, GMT+2
Terminal        C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075
 

It is not my pc. I run the EA on another pc and get the same result.

Do you have any other suggestion?

Thanks for your time
 
karachiento:

It is not my pc. I run the EA on another pc and get the same result.

Do you have any other suggestion?

Thanks for your time

Also indicate the equipment on which there is a problem (after starting the terminal, take the first three lines from the Journal tab).

 

A working option is to use CopyTickVolume and CopyRealVolume.

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   long volume=SymbolInfoInteger(Symbol(),SYMBOL_VOLUME);
   double volume_real=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_REAL);
   long volume_array[],real_volume_array[];


   MqlTick m_tick;
   if(!SymbolInfoTick(Symbol(),m_tick) || CopyTickVolume(Symbol(),Period(),0,1,volume_array)!=1 ||
      CopyRealVolume(Symbol(),Period(),0,1,real_volume_array)!=1)
      return;
   Print(TimeToString(m_tick.time,TIME_DATE|TIME_MINUTES),",",
         " Bid ",DoubleToString(m_tick.bid,Digits()),
         " Ask ",DoubleToString(m_tick.ask,Digits()),
         " Volume ",IntegerToString(m_tick.volume),
         " Volume real ",DoubleToString(m_tick.volume_real,0),
         " SYMBOL_VOLUME ",IntegerToString(volume),
         " SYMBOL_VOLUME_REAL ",DoubleToString(volume_real,0),
         " CopyTickVolume ",IntegerToString(volume_array[0]));
  }
//+------------------------------------------------------------------+


Result:

1 (AUDUSD,H1)   2020.04.22 10:05, Bid 0.63283 Ask 0.63291 Volume 0 Volume real 0 SYMBOL_VOLUME 0 SYMBOL_VOLUME_REAL 0 CopyTickVolume 407

Documentation on MQL5: Timeseries and Indicators Access / CopyTickVolume
Documentation on MQL5: Timeseries and Indicators Access / CopyTickVolume
  • www.mql5.com
The function gets into volume_array the history data of tick volumes for the selected symbol-period pair in the specified quantity. It should be noted that elements ordering is from present to past, i.e., starting position of 0 means the current bar. If you know the amount of data you need to copy, it should better be done to a statically...
 


I have used your code to test and I do not get the volume, only correlative numbers that return to 1 when a new candle appears ...

f


 
karachiento :

I have used your code to test and I do not get the volume, only correlative numbers that return to 1 when a new candle appears ...

You got the volumes. You even highlighted the volumes in the picture.

 
Yes. you're right. Thank you!
 
Vladimir Karputov:

Yes, there is a problem. Additionally, queries (SYMBOL_VOLUME and SYMBOL_VOLUME_REAL) also do not work.


Result:

There is no problem. Most brokers don't provide trade volume information for Forex symbols.