iHigh and iLow returns 0.0 [Solved] - page 2

 
Dark Ryd3r #:

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

so i see this error, how can it be fixed, I am sure the chart has history and receiving ticks

When i check with CheckLoadHistory(), it confirms there are bars


Good Luck with debugging it :D MT4 does work but on MT5 i was facing the exactly same issue. While the bars are there time to time i was actively receiving 0.0 from the Ticks , not even bars. Let me know if you find the solution. Try to read the article that is mentioned above and make data requests or return if the reading is 0.0...

 
Dark Ryd3r #:

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

so i see this error, how can it be fixed, I am sure the chart has history and receiving ticks

When i check with CheckLoadHistory(), it confirms there are bars


Read the help:  Organizing Data Access  
Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
  • www.mql5.com
Organizing Data Access - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Ferhat Happy #:

Good Luck with debugging it :D MT4 does work but on MT5 i was facing the exactly same issue. While the bars are there time to time i was actively receiving 0.0 from the Ticks , not even bars. Let me know if you find the solution. Try to read the article that is mentioned above and make data requests or return if the reading is 0.0...

i have tried this, seems to be working but please check and confirm me

//+------------------------------------------------------------------+
//|                                                      HighLow.mq5 |
//|                                       Copyright 2021, Dark Ryd3r |
//|                                           https://t.me/DarkRyd3r |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Dark Ryd3r"
#property link      "https://t.me/DarkRyd3r"
#property version   "1.00"
#property indicator_chart_window

int total = 0,shift = 0;
double iH[],iL[];
string symbolsList[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit() {
   total = SymbolsTotal(true);
   ArrayResize(symbolsList, total);
   ArrayResize(iH, total);

//--- indicator buffers mapping
   for(int i=0; i<total; i++) {
      symbolsList[i] = SymbolName(i,true);
   }
//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[]) {
//---


   for(int i=0; i<total; i++) {


      int  res=CheckLoadHistory( symbolsList[i],PERIOD_M1,TimeGMT ()-PeriodSeconds(PERIOD_M1));
      switch (res) {
      case  -1 :
         //Print ( "Unknown symbol ",PERIOD_M1);
         break ;
      case  -2 :
         //Print ( "Requested bars more than max bars in chart" );
         break ;
      case  -3 :
         //Print ( "Program was stopped" );
         break ;
      case  -4 :
         //Print ( "Indicator shouldn't load its own data" );
         break ;
      case  -5 :
         //Print ( "Load failed" );
         break ;
      case   0 :
         // Print ( "Loaded OK" );
         break ;
      case   1 :
         // Print ( "Loaded previously" );
         break ;
      case   2 :
         // Print ( "Loaded previously and built" );
         break ;
      default  :
         Print ( "Unknown result" );
      }
      if(res==2 || res==1 || res==0) {
         iH[i] = iHigh(symbolsList[i],PERIOD_M1,0); // High
         Print("#"+(string)(i+1)+" "+symbolsList[i]+"| High : "+DoubleToString(iH[i],(int)SymbolInfoInteger(symbolsList[i],SYMBOL_DIGITS))+"." );
      } else {
         Print("Error : ", symbolsList[i] +" "+ GetLastError());
      }
   }

//--- return value of prev_calculated for next call
   return(rates_total);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int  CheckLoadHistory( string  symbol, ENUM_TIMEFRAMES  period, datetime  start_date) {
   datetime  first_date=0;
   datetime  times[100];
//--- check symbol & period
   if ( symbol == NULL  ||  symbol == "" )  symbol = Symbol ();
   if ( period == PERIOD_CURRENT )      period = Period ();
//--- check if symbol is selected in the Market Watch
   if (! SymbolInfoInteger ( symbol, SYMBOL_SELECT )) {
      if ( GetLastError ()== ERR_MARKET_UNKNOWN_SYMBOL )  return (-1);
      SymbolSelect ( symbol, true );
   }
//--- check if data is present
   SeriesInfoInteger ( symbol, period, SERIES_FIRSTDATE,first_date);
   if (first_date>0 && first_date<=start_date)  return (1);
//--- don't ask for load of its own data if it is an indicator
   if ( MQL5InfoInteger ( MQL5_PROGRAM_TYPE )== PROGRAM_INDICATOR  &&  Period ()== period  &&  Symbol ()== symbol )
      return (-4);
//--- second attempt
   if ( SeriesInfoInteger ( symbol, PERIOD_M1, SERIES_TERMINAL_FIRSTDATE,first_date)) {
      //--- there is loaded data to build timeseries
      if (first_date>0) {
         //--- force timeseries build
         CopyTime ( symbol, period,first_date+ PeriodSeconds ( period ),1,times);
         //--- check date
         if ( SeriesInfoInteger ( symbol, period, SERIES_FIRSTDATE,first_date))
            if (first_date>0 && first_date<=start_date)  return (2);
      }
   }
//--- max bars in chart from terminal options
   int  max_bars= TerminalInfoInteger ( TERMINAL_MAXBARS );
//--- load symbol history info
   datetime  first_server_date=0;
   while (! SeriesInfoInteger ( symbol, PERIOD_M1, SERIES_SERVER_FIRSTDATE,first_server_date) && ! IsStopped ())
      Sleep (5);
//--- fix start date for loading
   if (first_server_date>start_date) start_date=first_server_date;
   if (first_date>0 && first_date<first_server_date)
      Print ( "Warning: first server date ",first_server_date, " for ", symbol,
              " does not match to first series date ",first_date);
//--- load data step by step
   int  fail_cnt=0;
   while (! IsStopped ()) {
      //--- wait for timeseries build
      while (! SeriesInfoInteger ( symbol, period, SERIES_SYNCHRONIZED ) && ! IsStopped ())
         Sleep (5);
      //--- ask for built bars
      int  bars = Bars ( symbol, period );
      if ( bars >0) {
         if ( bars >=max_bars)  return (-2);
         //--- ask for first date
         if ( SeriesInfoInteger ( symbol, period, SERIES_FIRSTDATE,first_date))
            if (first_date>0 && first_date<=start_date)  return (0);
      }
      //--- copying of next part forces data loading
      int  copied= CopyTime ( symbol, period, bars,100,times);
      if (copied>0) {
         //--- check for data
         if (times[0]<=start_date)   return (0);
         if ( bars +copied>=max_bars)  return (-2);
         fail_cnt=0;
      } else {
         //--- no more than 100 failed attempts
         fail_cnt++;
         if (fail_cnt>=100)  return (-5);
         Sleep (10);
      }
   }
//--- stopped
   return (-3);
}
//+------------------------------------------------------------------+
//| Returns string value of the period                               |
//+------------------------------------------------------------------+
string  GetPeriodName( ENUM_TIMEFRAMES  period ) {
   if ( period == PERIOD_CURRENT )  period = Period ();
//---
   switch ( period ) {
   case  PERIOD_M1 :
      return ( "M1" );
   case  PERIOD_M2 :
      return ( "M2" );
   case  PERIOD_M3 :
      return ( "M3" );
   case  PERIOD_M4 :
      return ( "M4" );
   case  PERIOD_M5 :
      return ( "M5" );
   case  PERIOD_M6 :
      return ( "M6" );
   case  PERIOD_M10 :
      return ( "M10" );
   case  PERIOD_M12 :
      return ( "M12" );
   case  PERIOD_M15 :
      return ( "M15" );
   case  PERIOD_M20 :
      return ( "M20" );
   case  PERIOD_M30 :
      return ( "M30" );
   case  PERIOD_H1 :
      return ( "H1" );
   case  PERIOD_H2 :
      return ( "H2" );
   case  PERIOD_H3 :
      return ( "H3" );
   case  PERIOD_H4 :
      return ( "H4" );
   case  PERIOD_H6 :
      return ( "H6" );
   case  PERIOD_H8 :
      return ( "H8" );
   case  PERIOD_H12 :
      return ( "H12" );
   case  PERIOD_D1 :
      return ( "Daily" );
   case  PERIOD_W1 :
      return ( "Weekly" );
   case  PERIOD_MN1 :
      return ( "Monthly" );
   }
//---
   return ( "unknown period" );
}
//+------------------------------------------------------------------+
 
Dark Ryd3r #:

i have tried this, seems to be working but please check and confirm me

You don't need to load the history like someone wrongly advised. Well you can if you want, but that will not solve your problem.

MT5 is multi-threaded application, of course, it can always happen that a given symbol/timeframe data are not available, it will then return an error, you just have to deal with it (wait next tick, use a timer, use sleep, or whatever creative mechanism you could find).

Vladimir posted the links to the documentation. This topic has been discussed numerous time on the forum, no need to repeat all again and again, do some researches.

 
Well atleast its not happening on MT4. So we are coming to the result that is the common issue of MT5. I had some cases on multi pair ea and indicators that , it would not download the data automatically even if its on a marketwatch and manual download or data fixing is needed. So the data management is not perfect at all.  Allso receiving 0.0 on some ticks can cause looses. So missing the data on the fly for some pairs is totally upsetting. You can try to receive data each Milisecond. Then again, it will not help 0.0 ONES. All you can do is ignore the result if its 0.0. Unless there is known valid solution.  Lets say 100MS must be universal for all pairs in marketwatch. So once that is reached every pair must updated synched way. Sad part comes that is, When it happens few of them will return you 0.0 while there is a data ;). So if you are trying to create cross indicator from 2 different pairs get ready for such weird problems.
 
Ferhat Mutlu #:
Well atleast its not happening on MT4. So we are coming to the result that is the common issue of MT5. I had some cases on multi pair ea and indicators that , it would not download the data automatically even if its on a marketwatch and manual download or data fixing is needed. So the data management is not perfect at all.  Allso receiving 0.0 on some ticks can cause looses. So missing the data on the fly for some pairs is totally upsetting. You can try to receive data each Milisecond. Then again, it will not help 0.0 ONES. All you can do is ignore the result if its 0.0. Unless there is known valid solution.  Lets say 100MS must be universal for all pairs in marketwatch. So once that is reached every pair must updated synched way. Sad part comes that is, When it happens few of them will return you 0.0 while there is a data ;). So if you are trying to create cross indicator from 2 different pairs get ready for such weird problems.

Does this issue occur with Ask and Bid, also?

 
Alain Verleyen #:

You don't need to load the history like someone wrongly advised. Well you can if you want, but that will not solve your problem.

MT5 is multi-threaded application, of course, it can always happen that a given symbol/timeframe data are not available, it will then return an error, you just have to deal with it (wait next tick, use a timer, use sleep, or whatever creative mechanism you could find).

Vladimir posted the links to the documentation. This topic has been discussed numerous time on the forum, no need to repeat all again and again, do some researches.

Does this issue occur with Ask and Bid, also? Or only close, open, high, low? or just the ones with i prefix?
 
Alain Verleyen #:

You don't need to load the history like someone wrongly advised. Well you can if you want, but that will not solve your problem.

MT5 is multi-threaded application, of course, it can always happen that a given symbol/timeframe data are not available, it will then return an error, you just have to deal with it (wait next tick, use a timer, use sleep, or whatever creative mechanism you could find).

Vladimir posted the links to the documentation. This topic has been discussed numerous time on the forum, no need to repeat all again and again, do some researches.

please give search terms to use to find readings on 1) what prices this bug affects, and 2) proven methods that avoid or fix the bug.

I have idea for error correction, but at this stage is just a hypothesis. If i can see proofs of working fixes, then, I would not have to spend so much time testing my own code and hyposthese.
 
Revo Trades #:

please give search terms to use to find readings on 1) what prices this bug affects, and 2) proven methods that avoid or fix the bug.

I have idea for error correction, but at this stage is just a hypothesis. If i can see proofs of working fixes, then, I would not have to spend so much time testing my own code and hyposthese.
It does happen for ask and bid. Allso there is allso mind scratching thing. If you want to get the bid value of another symbol, you will not get that because you will be able to call data based on the current symbols tick. The way is prevent that to call data every X ms possible. That way atleast you will get different ticks based on the symbols. Not all symbols creating the tick at the same time. That is another issue of MT5 :) OnTick gets updated only based on the symbol you are in. OnTimer is the best for such cross pair tick data. Then you will get the most realistic data but again. Still reason is unknown for 0.0. Not an exact explanation
 

Just run this code and watch - each time there are less and less unsynchronized symbols:

//+------------------------------------------------------------------+
//|                                                      HighLow.mq5 |
//|                                       Copyright 2021, Dark Ryd3r |
//|                                           https://t.me/DarkRyd3r |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Dark Ryd3r"
#property link      "https://t.me/DarkRyd3r"
#property version   "1.00"
#property indicator_chart_window

int total = 0,shift = 0;
double iH[],iL[];
string symbolsList[];
int counter=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   total = SymbolsTotal(true);
   ArrayResize(symbolsList, total);
   ArrayResize(iH, total);
//--- indicator buffers mapping
   for(int i=0; i<total; i++)
     {
      symbolsList[i] = SymbolName(i,true);
     }
   counter=0;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---
   bool not_synchro=false;
   for(int i=0; i<total; i++)
     {
      iH[i] = iHigh(symbolsList[i],PERIOD_M1,0); // High
      if(iH[i]==0.0)
        {
         not_synchro=true;
         bool series_sinchronized=SeriesInfoInteger(symbolsList[i],PERIOD_M1,SERIES_SYNCHRONIZED);
         Print("#"+(string)(i+1)+" "+symbolsList[i]+"| High : "+DoubleToString(iH[i],(int)SymbolInfoInteger(symbolsList[i],SYMBOL_DIGITS))+"."+" SYNCHRONIZED: ",series_sinchronized);
        }
     }
   if(not_synchro)
     {
      counter++;
      Print("Not synchro: ",counter);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
  }
//+------------------------------------------------------------------+
Files:
HighLow.mq5  6 kb