SymbolInfoTick() doubt - page 2

 
A single tick does t have an volume, a volume can only apper over a period of time
 
Alain Verleyen :
There is no problem. Most brokers don't provide trade volume information for Forex symbols.

You are confusing tick volume and real volume. Tick volume is broadcast for all Forex symbols. It’s for some reason that I can’t get the tick volume - there is only one CopyTickVolume function "/

Methods SYMBOL_VOLUME , SymbolInfoTick , do not work. Please do not confuse tick volume and real volume.

 

Also you can't get the latest price with SymbolInfoTick(). 

Do you know the problem with SymbolInfoTick () is eventual with a short term solution?

Should we find another way to get the latest price and volume for each tick?

 
Vladimir Karputov:

You are confusing tick volume and real volume. Tick volume is broadcast for all Forex symbols. It’s for some reason that I can’t get the tick volume - there is only one CopyTickVolume function "/

Methods SYMBOL_VOLUME , SymbolInfoTick , do not work. Please do not confuse tick volume and real volume.

YOU are confusing tick volume and real volume.

SYMBOL_VOLUME is about REAL volume, not tick volume.

MqlTick volume and volume_real are about REAL VOLUME. The tick volume of a tick is obviously 1.

 
Yeah, you're not going to get real volume because forex doesn't have a centralized exchange. If you want to know the real volume you will need to trade futures at a FCM. Other than that use tick volume like Alain has mentioned several times. 
 
Thank you!
 
Alain Verleyen :


Alain - many thanks! I really rarely refer to EXCHANGE symbols. You have helped me!

Now I will show the correct code - thanks to it you can see all the volumes:

//+------------------------------------------------------------------+
//|                                               Get Volumes EA.mq5 |
//|                              Copyright © 2020, Vladimir Karputov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020, Vladimir Karputov"
#property version   "1.000"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   Print("Start ",__FUNCTION__);

   long symbol_volume=SymbolInfoInteger(Symbol(),SYMBOL_VOLUME);
   double symbol_volume_real=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_REAL);
   long tick_volume_array[],real_volume_array[];


   MqlTick m_tick;
   if(!SymbolInfoTick(Symbol(),m_tick) || CopyTickVolume(Symbol(),Period(),0,1,tick_volume_array)!=1 ||
      CopyRealVolume(Symbol(),Period(),0,1,real_volume_array)!=1)
      return(0);

   Print(TimeToString(m_tick.time,TIME_DATE|TIME_MINUTES),",",
         " m_tick.bid ",DoubleToString(m_tick.bid,Digits()),
         " m_tick.ask ",DoubleToString(m_tick.ask,Digits()),
         " m_tick.volume ",IntegerToString(m_tick.volume),
         " m_tick.volume_real ",DoubleToString(m_tick.volume_real,0),
         " SYMBOL_VOLUME ",IntegerToString(symbol_volume),
         " SYMBOL_VOLUME_REAL ",DoubleToString(symbol_volume_real,0),
         " tick_volume_array[0] ",IntegerToString(tick_volume_array[0]),
         " real_volume_array[0] ",IntegerToString(real_volume_array[0]));

   Print("End ",__FUNCTION__);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   long symbol_volume=SymbolInfoInteger(Symbol(),SYMBOL_VOLUME);
   double symbol_volume_real=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_REAL);
   long tick_volume_array[],real_volume_array[];


   MqlTick m_tick;
   if(!SymbolInfoTick(Symbol(),m_tick) || CopyTickVolume(Symbol(),Period(),0,1,tick_volume_array)!=1 ||
      CopyRealVolume(Symbol(),Period(),0,1,real_volume_array)!=1)
      return;

   Print(TimeToString(m_tick.time,TIME_DATE|TIME_MINUTES),",",
         " m_tick.bid ",DoubleToString(m_tick.bid,Digits()),
         " m_tick.ask ",DoubleToString(m_tick.ask,Digits()),
         " m_tick.volume ",IntegerToString(m_tick.volume),
         " m_tick.volume_real ",DoubleToString(m_tick.volume_real,0),
         " SYMBOL_VOLUME ",IntegerToString(symbol_volume),
         " SYMBOL_VOLUME_REAL ",DoubleToString(symbol_volume_real,0),
         " tick_volume_array[0] ",IntegerToString(tick_volume_array[0]),
         " real_volume_array[0] ",IntegerToString(real_volume_array[0]));
  }
//+------------------------------------------------------------------+


Futures result

(FUTCLJUN20,D1)  2020.04.23 04:34, m_tick.bid 14.99 m_tick.ask 15.00 m_tick.volume 1 m_tick.volume_real 1 SYMBOL_VOLUME 1 SYMBOL_VOLUME_REAL 1 tick_volume_array[0] 40279 real_volume_array[0] 66089
(FUTCLJUN20,D1)  2020.04.23 04:34, m_tick.bid 15.00 m_tick.ask 15.01 m_tick.volume 2 m_tick.volume_real 2 SYMBOL_VOLUME 2 SYMBOL_VOLUME_REAL 2 tick_volume_array[0] 40282 real_volume_array[0] 66093
(FUTCLJUN20,D1)  2020.04.23 04:34, m_tick.bid 14.99 m_tick.ask 15.00 m_tick.volume 2 m_tick.volume_real 2 SYMBOL_VOLUME 2 SYMBOL_VOLUME_REAL 2 tick_volume_array[0] 40283 real_volume_array[0] 66095
(FUTCLJUN20,D1)  2020.04.23 04:34, m_tick.bid 14.99 m_tick.ask 15.01 m_tick.volume 1 m_tick.volume_real 1 SYMBOL_VOLUME 1 SYMBOL_VOLUME_REAL 1 tick_volume_array[0] 40285 real_volume_array[0] 66097


Forex result

(AUDUSD,H1)      2020.04.23 07:36, m_tick.bid 0.63061 m_tick.ask 0.63069 m_tick.volume 0 m_tick.volume_real 0 SYMBOL_VOLUME 0 SYMBOL_VOLUME_REAL 0 tick_volume_array[0] 764 real_volume_array[0] 0
(AUDUSD,H1)      2020.04.23 07:36, m_tick.bid 0.63061 m_tick.ask 0.63070 m_tick.volume 0 m_tick.volume_real 0 SYMBOL_VOLUME 0 SYMBOL_VOLUME_REAL 0 tick_volume_array[0] 764 real_volume_array[0] 0
(AUDUSD,H1)      2020.04.23 07:36, m_tick.bid 0.63063 m_tick.ask 0.63070 m_tick.volume 0 m_tick.volume_real 0 SYMBOL_VOLUME 0 SYMBOL_VOLUME_REAL 0 tick_volume_array[0] 765 real_volume_array[0] 0
Files:
 
Thank you again Vladimir and Alain. You have helped me a lot!
 

Hi,


starting from this code, how could I do to get de volume grouped for every tick on every candle? I need an indicator that shows the buy and sell volume for every tick on a candle (showing on log, for example)


Thank you

 
israelhernando: starting from this code, how could I do to get de volume grouped for every tick on every candle? I need an indicator that shows the buy and sell volume for every tick on a candle (showing on log, for example)

Then read this thread again, because it answers that very question.

Reason: