This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

geting zero values from indecators in the init function


Back to topics list
avatar
41
johny_abo 2005.08.01 13:53 

int init()
  {
//---- 
 
  
   double adx,ma5,maxp13,maxp21;    // the graphs value
 
   
   ma5=iMA(NULL,PERIOD_H1,5,0,MODE_SMA,PRICE_CLOSE,0);
   maxp13=iMA(NULL,PERIOD_H1,13,0,MODE_EMA,PRICE_CLOSE,0);
   maxp21=iMA(NULL,PERIOD_H1,21,0,MODE_EMA,PRICE_CLOSE,0);
   adx=iADX(NULL,PERIOD_H1,14,PRICE_CLOSE,0,0);
   Print("ADX="+adx + "  MA5 " +ma5 +"  MAXP13 :"+maxp13+"  MAXP21 :"+maxp21);
}



when i run this in the tester i get 0 in all the 4 vars

what's the reason
how can i fix this???

avatar
4464
Slawa 2005.08.01 14:40 
please analyze result from GetLastError function
avatar
41
johny_abo 2005.08.01 14:48 
please analyze result from GetLastError function


the returend value is 0 no error
avatar
4464
Slawa 2005.08.01 14:55 
GetLastError after first indicator call (ma5=...)
it may be 4066. it may be no data when initialization. there are no reasons to call indicators in the init function
avatar
129
Vooch 2005.08.04 09:46 
1). Try using 60 instead of PERIOD_H1.
2). Put that code in the start() function instead of inside the init() function.

- Vooch
Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets