question about the maximum number for volume possible in metatrade4 hst file

 

hi, I faced an strange issue in my hst file builder app that when some pair has small price value so the volume goes more than "tick_volume>100,000,000,000"  then metatrader4 gives "HistoryBase error" and destroys the candles data.


https://www.mql5.com/en/charts/15611872/shibusd-bin-m3-grand-capital-ltd

this is when I limit the volume in history to that number ( it starts working ) 

https://www.mql5.com/en/charts/15611840/shibusd-bin-m3-grand-capital-ltd


so its strange that despite tick volume is of type LONG and long max value is more than this number ... why does it face error when volume goes above that?

I searched but couldn't find any points in the documents.  or the timeframe converter sample code.

https://www.mql5.com/en/forum/149178

Chart SHIBUSD-Bin, M3, 2022.04.04 15:26 UTC, Grand Capital LTD, MetaTrader 4, Demo
Chart SHIBUSD-Bin, M3, 2022.04.04 15:26 UTC, Grand Capital LTD, MetaTrader 4, Demo
  • www.mql5.com
Symbol: SHIBUSD-Bin. Periodicity: M3. Broker: Grand Capital LTD. Trading Platform: MetaTrader 4. Trading Mode: Demo. Date: 2022.04.04 15:26 UTC.
 
Farzin Sadeghi: so its strange that despite tick volume is of type LONG and long max value is more than this number ... why does it face error when volume goes above that?
It could be an internal bug due to "old code" still being used, given that the previous version of the HST format used "double" for volume instead of "long" for the newer version.
 
Fernando Carreiro #:
It could be an internal bug due to "old code" still being used, given that the previous version of the HST format used "double" for volume instead of "long" for the newer version.

thanks for the answer. I will try it now.


I used mqlrate structure, and in it volume is long.

so I have to create another struct.

//--- Structure that stores information about the prices, volumes and spread.
struct MqlRatesNew
  {
   datetime time;         // Period start time
   double   open;         // Open price
   double   high;         // The highest price of the period
   double   low;          // The lowest price of the period
   double   close;        // Close price
   double   tick_volume;  // Tick volume
   int      spread;       // Spread
   double   real_volume;  // Trade volume
  };

and change the rest of the code to see if this solves the problem. I will update this post... 

thanks

 
Fernando Carreiro #:
It could be an internal bug due to "old code" still being used, given that the previous version of the HST format used "double" for volume instead of "long" for the newer version.

I tried a new struct in which I defined tick_volume as double... then type casted all volumes as (double) instead of (long)  in the periodconverter script for a test.

it is creating the history but all candles have volume of 1 . 

I checked the value in the print ... before writing the FileWriteStruct(ExtHandle,rate);  it has the values. 


maybe I should use FileWriteDouble... instead ?   but  as this is not csv and its  Binary mode I don't know if that may work or not. I will try that now.

https://www.mql5.com/en/charts/15612922/usdcad-m2-grand-capital-ltd

Chart USDCAD, M2, 2022.04.04 19:34 UTC, Grand Capital LTD, MetaTrader 4, Demo
Chart USDCAD, M2, 2022.04.04 19:34 UTC, Grand Capital LTD, MetaTrader 4, Demo
  • www.mql5.com
Symbol: USDCAD. Periodicity: M2. Broker: Grand Capital LTD. Trading Platform: MetaTrader 4. Trading Mode: Demo. Date: 2022.04.04 19:34 UTC.
Files:
 
Farzin Sadeghi #: thanks for the answer. I will try it now.

I meant that the bug could be in MetaTrader not in your code.

 
Fernando Carreiro #:

I meant that the bug could be in MetaTrader not in your code.

haha so I stop trying with converting the volume into double.   as volume does not need decimal points anyways.

for now I just limited the volumes into that number... 

if(rate.tick_volume>100000000000){
               rate.tick_volume=100000000000;
            }