iADX throw garbage values on first tick MQL5

To add comments, please log in or register
jaffer wilson
780
jaffer wilson  

I am trying to print the values of the ADX indicator in MQL5. Here is teh code and the output of me test:

void OnTick()
  {
   int testing = iADX(_Symbol,PERIOD_M1,5);
   double dminus[],dplus[],main[];
   ArraySetAsSeries(dminus,true);
   ArraySetAsSeries(dplus,true);
   ArraySetAsSeries(main,true);
   CopyBuffer(testing,0,0,5,main);
   CopyBuffer(testing,1,0,5,dplus);
   CopyBuffer(testing,2,0,5,dminus);

   Print("DPlus[0]:  ", dplus[0]);
   Print("DMinus[0]:  ", dminus[0]);
   Print("DPlus[1]:  ", dplus[1]);
   Print("DMinus[1]:  ", dminus[1]);
 }

Output:

output image

As you can see in the output, the first 4 values of DPlus[0],DPlus[1],DMinus[0],a nd DMinus[1] are garbage values and later one are the right or true values. I want to know how I can initialize with a default value so that I do not get a garbage values and I can put condition on so that the program run without any mistakes.

To add comments, please log in or register