iHigh and iLow returns 0.0 [Solved] - page 4

 
Revo Trades #:


i have been searching for method to cover this bug for some time, but none of the gurus have given proof that their methods work, so I have always been uncertain who to believe but I have found this in the docs. I have been watching the print out data for almost 5 mins non stop, and see not even 1 line that has 0.0. I hope the doc page help you too. 


I do coding for both mt4 and mt5, and both indicators and eas. Please confirm that the example in the docs page below, at the bottom of the page will re-populate the OHCL data for current and past candles, for both ea's (in OnTick func) and indicator (in start() or OnTick()); coding AND for both MT4/5.



https://www.mql5.com/en/docs/series/copyrates

yes it worked!!! feedback needed

//+------------------------------------------------------------------+
//|                                                      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
#property indicator_plots 0

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
      MqlRates  rates[];
      ArraySetAsSeries (rates, true );
      int  copied= CopyRates ( symbolsList[i],PERIOD_M1,0,1,rates);
      if (copied>0) {
         int  size= fmin (copied,1);
         for ( int  j=0; j<size; j++) {

            Print("#"+(string)(i+1)+" "+symbolsList[i]+"| High : "+DoubleToString(rates[j].high,(int)SymbolInfoInteger(symbolsList[i],SYMBOL_DIGITS))+".");

            //Print (out);
            if(rates[j].high==0.0) {
               not_synchro=true;
               bool series_sinchronized=SeriesInfoInteger(symbolsList[i],PERIOD_M1,SERIES_SYNCHRONIZED);
               Print("#"+(string)(i+1)+" "+symbolsList[i]+"| High : "+DoubleToString(rates[j].high,(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);
}
 
Ferhat Mutlu #:
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

This is completely wrong statement. Or you need to prove it.

Yes OnTick() is only triggered for the current chart symbol, but beside that there are several methods to be notified about ticks on other symbols. Do some researches, it's all publicly available on this site.

 
Arpit Tailang #:
Yes as I said temporarily fix using Bid price
But on IHigh I'm still getting 0.0
If that bug of Mt5 gets fixes I'll be very helpful

Again. This is NOT a bug, it's a feature which allow MT5 to be way faster then MT4, at the price of simplicity for sure.

Learn to deal with it.

 
Alain Verleyen #:

Again. This is NOT a bug, it's a feature which allow MT5 to be way faster then MT4, at the price of simplicity for sure.

Learn to deal with it.

thanks
 
Alain Verleyen #:


ok thanks. But i did give context in my last msg. Please read my previous msg and confirm that it should suite my "context".

And, yeah, ok. maybe the word "bug" does not apply here. However, anything that requires error correction is labeled as a bug to 99% of coders i have conversed with; whether that behavior is NORMAL behavior or not. If it is NORMAL behavior it goes on the "to be fixed list", or the "shit list", all of these fall under the same banner of "bugs" :D

 
Alain Verleyen #:

This is completely wrong statement. Or you need to prove it.

Yes OnTick() is only triggered for the current chart symbol, but beside that there are several methods to be notified about ticks on other symbols. Do some researches, it's all publicly available on this site.

it is publicly available but the search feature of this website sucks and is very limited. Its no wonder the same questions get asked so many times.

 
Dark Ryd3r #:

yes it worked!!! feedback needed

sweet! i am happy it worked for you. It is working for me too, albeit i have not tested it in ea codes yet.

 
Revo Trades #:

it is publicly available but the search feature of this website sucks and is very limited. Its no wonder the same questions get asked so many times.

Maybe, but it's not my role to do the search for other people. Or to go back read what you think I should have read.

If you have a question not answered, ask it again.

 
A suggestion:
You should reset not_syncro at the beginning of each loop.

Or do it like this:

not_synchro=(rates[j].high==0.0);

When all symbols are synced, return rates_total, until then do this:


Change this:
//--- return value of prev_calculated for next call
   return(rates_total);

to this:

//--- return value of prev_calculated for next call
   return(prev_calculated +1);
Reason: