iHigh and iLow returns 0.0 [Solved]

 

When i try to get values of current bar for multi symbols it returns 0.0

double GetHigh = iHigh(_Symbol,_Period,barshift);
double GetLow = iLow(_Symbol,_Period,barshift);

When

barshift = 0;

it returns 0.0 for some of the symbols but

When

barshift = 1; 

all works fine,

Why should it be returning 0.0 for some symbols?

I also tried

if(BarsCalculated(handle)>0){
double GetHigh = iHigh(_Symbol,_Period,barshift);
double GetLow = iLow((_Symbol,_Period,barshift);
}

but did not work

 
Dark Ryd3r:

When i try to get values of current bar for multi symbols it returns 0.0

When

it returns 0.0 for some of the symbols but

When

all works fine,

Why should it be returning 0.0 for some symbols?

I also tried

but did not work

How can you can try to get it for multi symbol while _Symbol is returning only attached indicator current charts symbol.
 
Ferhat Mutlu #:
How can you can try to get it for multi symbol while _Symbol is returning only attached indicator current charts symbol.
https://www.mql5.com/en/articles/8257
 

? that is not explaining my question.

iHigh with _Symbol will return only current attached symbols High value. That will be different only if the indicator gets called by another indicator as buffer. But that is definitely is not the question asked by the topic starter.

 
Ferhat Happy #:

? that is not explaining my question.

iHigh with _Symbol will return only current attached symbols High value. That will be different only if the indicator gets called by another indicator as buffer. But that is definitely is not the question asked by the topic starter.

//+------------------------------------------------------------------+
//|                                                      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++) {
      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))+".");
   }

//--- return value of prev_calculated for next call
   return(rates_total);
}
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer() {
//---

}
//+------------------------------------------------------------------+


 
Dark Ryd3r #:


Now your calling is correct.
Those symbols don't have candlestick data. That is one of the issues of the MT4-MT5. Make sure you open that charts manually and candlesticks there. Then if you re run your code the data will be represented. So that timeframe + symbol must have the data and candlestick of that index.

 
Ferhat Mutlu #:

Now your calling is correct.
Those symbols don't have candlestick data. That is one of the issues of the MT4-MT5. Make sure you open that charts manually and candlesticks there. Then if you re run your code the data will be represented. So that timeframe + symbol must have the data and candlestick of that index.

Thanks for your reply. if that is a MT5 issue, I am looking to solve this issue with any alternative, I cant open charts manually as this is for more than 100 symbols and MT5 only supports opening 100 charts max.

 
Arpit Tailang #:

Thanks for your reply. if that is a MT5 issue, I am looking to solve this issue with any alternative, I cant open charts manually as this is for more than 100 symbols and MT5 only supports opening 100 charts max.

You don't need to open them. You just need to code a simple history downloader that will open your market watch symbols one by one and scroll back in history untill X bars downloaded.
If the market watch pairs are not get updated that is commonly broker issue.
 

MetaTrader has no problems - users have a problem: no one wants to read the help.

Read the help: Organizing Data Access 

Read the help : iHigh and especially pay attention to the fact that you SHOULD check the results!

Documentation on MQL5: Timeseries and Indicators Access / iHigh
Documentation on MQL5: Timeseries and Indicators Access / iHigh
  • www.mql5.com
iHigh - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Vladimir Karputov #:

MetaTrader has no problems - users have a problem: no one wants to read the help.

Read the help: Organizing Data Access 

Read the help : iHigh and especially pay attention to the fact that you SHOULD check the results!

Nice article. So basically if the symbol is in the market watch and i cannot get the data with my buffer call. Is the broker responsible or me that i did not do the checks as mentioned in the article ?
 
Vladimir Karputov # :

MetaTrader has no problems - users have a problem: no one wants to read the help.

Read the help:  Organizing Data Access  

Read the help : iHigh and especially pay attention to the fact that you SHOULD check the results!

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


Reason: