Mqltick struct not providing volume information

 

I want to know why the volume fields of the mqltick struct are always giving 0.0, both "volume_real" and "volume" are not giving any data. The "tick_volumes" buffer is plotting fine in this small example I made, but not volume from Mqltick struct.

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1

#property indicator_color1 clrGreen
#property indicator_type1 DRAW_HISTOGRAM


double tickVolumes[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

    SetIndexBuffer(0, tickVolumes, INDICATOR_DATA); 
    
    ArraySetAsSeries(tickVolumes, true);
//---
   return(INIT_SUCCEEDED);
  }


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{

  MqlTick latestTick;
 
  SymbolInfoTick(_Symbol, latestTick);
  
  if(prev_calculated == 0){
   ArrayInitialize(tickVolumes, EMPTY_VALUE);
  }
 
//  tickVolumes[0] = (double)latestTick.volume;   // not giving data
  
   tickVolumes[0] = (double)tick_volume[rates_total-1]; // tick volume of the current bar

   return(rates_total);
}

Are these volume fields on the struct for stocks only or something?

Any time that I try to use the search bar for documentation, not working, even the codebase search does not work for me.

From the mql5 reference, it's not explained much.

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2025.02.09
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
Conor Mcnamara: Are these volume fields on the struct for stocks only or something?
Correct. Only exchange based symbols, like stocks and futures have real volume. Non centralised symbols like Forex, CFDs, Crypto, etc. do not have real volume.
 
Thanks for clarifying. So I guess volume in MqlTick refers to real volume which is tracked and it's not tick volume in forex, so for tick volume on forex options would be iTickVolume, iVolume, and tick_volume in the OnCalculate function signature.
 
Conor Mcnamara #: Thanks for clarifying. So I guess volume in MqlTick refers to real volume which is tracked and it's not tick volume in forex, so for tick volume on forex options would be iTickVolume, iVolume, and tick_volume in the OnCalculate function signature.
MqlTick is simply a tick. Therefore it's tick volume is simply 1. One tick! So simple is not? 😅
 
Fernando Carreiro #:
MqlTick is simply a tick. Therefore it's tick volume is simply 1. One tick! So simple is not? 😅
Yes, I was trying to make a tick version of an indicator, and I was shifting older tick data back inside a loop, the bid price would shift fine, but the indicator also used volume, and unfortunately I wasted a lot of time assuming it was tick volume (which I needed). It wasn't until I was debugging all the parts when I found out too late that it wasn't giving me tick volume. Now using the tick_volume buffer and all is fine.