Volume Tick

 

Hello! I would like to retrieve all ticks for the past n candles.  In MqlTick structure, what is tick[i].volum and tick[i].volum_real ?

I am geting zero for both of them unless I connect to a broker wich is giving real volume.

Can I retrieve tick_volume at every tick for forex market using MqlTick structure?

Thanks!


this is what I use :


 StringConcatenate(filename,"Ticks_",Symbol()," ",IntegerToString(_Period),".csv");
   int handle;

   double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
   handle=FileOpen(filename, FILE_CSV|FILE_READ|FILE_WRITE);
   if(handle<0)
     {
      Print("Could Not Create/Open File "+IntegerToString(GetLastError()));
      FileClose(handle);
      return;
     }
   if(handle==1)
      Print("File Opened Successfully");
   FileSeek(handle, 0, SEEK_END);

   MqlTick tick_array[];   // Tick receiving array
   ulong from =(ulong) iTime(_Symbol,PERIOD_CURRENT,30)*1000;
   ulong to = (ulong) iTime(_Symbol,PERIOD_CURRENT,0)*1000;
   int received=CopyTicksRange(_Symbol,tick_array,COPY_TICKS_ALL,from,to);
   
   int size=ArraySize(tick_array);
   int  ticks=MathMin(1000,size);
//--- Showing the first 100 ticks of the last day
   int counter=0;
   for(int i=0; i<ticks; i++)
     {
      datetime time=tick_array[i].time;
      double ask = tick_array[i].ask;
      double bid = tick_array[i].bid;
      ulong vol = tick_array[i].volume_real
      FileSeek(handle, 0, SEEK_END);
      FileWrite(handle,counter,TimeToString(time, TIME_DATE | TIME_SECONDS), " bid=",  bid, " ask=", ask,  "vol=", vol);
counter++;
     }


   FileClose(handle);
The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 

Your code looks okay and it appears to be:

  •  retrieving ticks for the past n candles using the CopyTicksRange function, and
  •  writing the tick data (including time, bid, ask, and volume_real) to external CSV file.

NOTE: if your broker is not providing accurate volume data, the volume_real value may not be reliable.

Reason: