why iATR sometimes returns 0?

 

Hello, 

Could you explain to me why this code sometimes return ATR=0?

string orderSymbol = OrderSymbol();
double ATR = iATR(orderSymbol, PERIOD_M15, 5, 0);
if(ATR == 0){
  Print("ATR=0...FAILED...RETRY...");
  return false;
}

        

orderSymbol can be different from graph than the one the EA is attached to.

 
The answer is in the last line of your question.
 
Ahmet Metin Yilmaz:
The answer is in the last line of your question.

Could you explain please?

 
if ordersymbol is the chart symbol ATR returns different from zero 
 
Ahmet Metin Yilmaz:
if ordersymbol is the chart symbol ATR returns different from zero 

Is there a way to get ATR values for symbols others than the current graph?

 
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. double ATR = iATR(orderSymbol, PERIOD_M15, 5, 0);
    On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

 
William Roeder:
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

Thanks a lot!