iAdx Not Supplying Consistent Data

I am currently working on an indicator that uses ADX data from different time periods. In the attached indicator I am attempting to populate arrays with data from these different time periods. When I use the Print formula to look a the data I am getting irregular data from the array I have populated. Am I missing something as it relates to properly using arrays? I don’t understand why I have big gaps in the data. I am using MetaTrader 4. I have also included a print-screen of the data I am getting.

   /+------------------------------------------------------------------+

//| Indicator-ColorBar.mq4 |
//| Copyright 2020, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//±-----------------------------------------------------------------+
#property copyright “Mike Certini”
#property link “”
#property version “1.00”
#property strict

#include <DeinitErrors.mqh>

#property indicator_chart_window
#property indicator_buffers 39

#property indicator_label1 “Up Indicator”
#property indicator_color1 clrBlue
#property indicator_width1 2

#property indicator_label2 “Up Indicator”
#property indicator_color2 clrBlue
#property indicator_width2 2

#property indicator_label3 “Down Indicator”
#property indicator_color3 clrRed
#property indicator_width3 2

#property indicator_label4 “Down Indicator”
#property indicator_color4 clrRed
#property indicator_width4 2

//±-----------------------------------------------------------------+
//| Indicator Buffers |
//±-----------------------------------------------------------------+

double UpBodyHigh[]; //Indicator buffers
double UpBodyLow[];
double DnBodyHigh[];
double DnBodyLow[];

extern int indperiod = 14;
extern int btlevel = 20;
extern int tplevel = 80;
extern int barsback = 0; //Setting for the amount of bars to report on.
extern int barsadj = 3; //Adjustment to ensure there is no beyond array error.

double ADXMND10[];
double ADXPLD10[];
double ADXMID10[];
double ADXMNH40[];
double ADXPLH40[];
double ADXMIH40[];
double ADXMNH10[];
double ADXPLH10[];
double ADXMIH10[];
double ADXMNM300[];
double ADXPLM300[];
double ADXMIM300[];
double ADXMNM150[];
double ADXPLM150[];
double ADXMIM150[];
double ADXMNM50[];
double ADXPLM50[];
double ADXMIM50[];
double ADXMNM10[];
double ADXPLM10[];
double ADXMIM10[];
double UD1[];
double UH4[];
double UH1[];
double UH30[];
double UH15[];
double UH5[];
double UM1[];
double DD1[];
double DH4[];
double DH1[];
double DH30[];
double DH15[];
double DH5[];
double DM1[];

//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
int OnInit()
{
IndicatorBuffers(39);

IndicatorSetString(INDICATOR_SHORTNAME,“Indicator-ColorBar”); //Name the indicator.
IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1); //Determine the accuracy of the values of the indicator.

SetIndexBuffer(0,UpBodyHigh); //Bind an array and an indicator buffer.
SetIndexStyle(0,DRAW_HISTOGRAM);
ArraySetAsSeries(UpBodyHigh,true);

SetIndexBuffer(1,UpBodyLow); //Bind an array and an indicator buffer.
SetIndexStyle(1,DRAW_HISTOGRAM);
ArraySetAsSeries(UpBodyLow,true);

SetIndexBuffer(2,DnBodyHigh); //Bind an array and an indicator buffer.
SetIndexStyle(2,DRAW_HISTOGRAM);
ArraySetAsSeries(DnBodyHigh,true);

SetIndexBuffer(3,DnBodyLow); //Bind an array and an indicator buffer.
SetIndexStyle(3,DRAW_HISTOGRAM);
ArraySetAsSeries(DnBodyLow,true);

SetIndexBuffer(4,ADXMND10); //Bind an array and an indicator buffer.
SetIndexStyle(4,DRAW_NONE);
ArraySetAsSeries(ADXMND10,true);

SetIndexBuffer(5,ADXPLD10); //Bind an array and an indicator buffer.
SetIndexStyle(5,DRAW_NONE);
ArraySetAsSeries(ADXPLD10,true);

SetIndexBuffer(6,ADXMID10);
SetIndexBuffer(7,ADXMNH40);
SetIndexBuffer(8,ADXPLH40);
SetIndexBuffer(9,ADXMIH40);
SetIndexBuffer(10,ADXMNH10);
SetIndexBuffer(11,ADXPLH10);
SetIndexBuffer(12,ADXMIH10);
SetIndexBuffer(13,ADXMNM300);
SetIndexBuffer(14,ADXPLM300);
SetIndexBuffer(15,ADXMIM300);
SetIndexBuffer(16,ADXMNM150);
SetIndexBuffer(17,ADXPLM150);
SetIndexBuffer(18,ADXMIM150);
SetIndexBuffer(19,ADXMNM50);
SetIndexBuffer(20,ADXPLM50);
SetIndexBuffer(21,ADXMIM50);
SetIndexBuffer(22,ADXMNM10);
SetIndexBuffer(23,ADXPLM10);
SetIndexBuffer(24,ADXMIM10);
SetIndexBuffer(25,UD1);
SetIndexBuffer(26,UH4);
SetIndexBuffer(27,UH1);
SetIndexBuffer(28,UH30);
SetIndexBuffer(29,UH15);
SetIndexBuffer(30,UH5);
SetIndexBuffer(31,UM1);
SetIndexBuffer(32,DD1);
SetIndexBuffer(33,DH4);
SetIndexBuffer(34,DH1);
SetIndexBuffer(35,DH30);
SetIndexBuffer(36,DH15);
SetIndexBuffer(37,DH5);
SetIndexBuffer(38,DM1);

SetIndexStyle(6,DRAW_NONE);
SetIndexStyle(7,DRAW_NONE);
SetIndexStyle(8,DRAW_NONE);
SetIndexStyle(9,DRAW_NONE);
SetIndexStyle(10,DRAW_NONE);
SetIndexStyle(11,DRAW_NONE);
SetIndexStyle(12,DRAW_NONE);
SetIndexStyle(13,DRAW_NONE);
SetIndexStyle(14,DRAW_NONE);
SetIndexStyle(15,DRAW_NONE);
SetIndexStyle(16,DRAW_NONE);
SetIndexStyle(17,DRAW_NONE);
SetIndexStyle(18,DRAW_NONE);
SetIndexStyle(19,DRAW_NONE);
SetIndexStyle(20,DRAW_NONE);
SetIndexStyle(21,DRAW_NONE);
SetIndexStyle(22,DRAW_NONE);
SetIndexStyle(23,DRAW_NONE);
SetIndexStyle(24,DRAW_NONE);
SetIndexStyle(25,DRAW_NONE);
SetIndexStyle(26,DRAW_NONE);
SetIndexStyle(27,DRAW_NONE);
SetIndexStyle(28,DRAW_NONE);
SetIndexStyle(29,DRAW_NONE);
SetIndexStyle(30,DRAW_NONE);
SetIndexStyle(31,DRAW_NONE);
SetIndexStyle(32,DRAW_NONE);
SetIndexStyle(33,DRAW_NONE);
SetIndexStyle(34,DRAW_NONE);
SetIndexStyle(35,DRAW_NONE);
SetIndexStyle(36,DRAW_NONE);
SetIndexStyle(35,DRAW_NONE);
SetIndexStyle(37,DRAW_NONE);

ArraySetAsSeries(ADXMID10,true);
ArraySetAsSeries(ADXMNH40,true);
ArraySetAsSeries(ADXPLH40,true);
ArraySetAsSeries(ADXMIH40,true);
ArraySetAsSeries(ADXMNH10,true);
ArraySetAsSeries(ADXPLH10,true);
ArraySetAsSeries(ADXMIH10,true);
ArraySetAsSeries(ADXMNM300,true);
ArraySetAsSeries(ADXPLM300,true);
ArraySetAsSeries(ADXMIM300,true);
ArraySetAsSeries(ADXMNM150,true);
ArraySetAsSeries(ADXPLM150,true);
ArraySetAsSeries(ADXMIM150,true);
ArraySetAsSeries(ADXMNM50,true);
ArraySetAsSeries(ADXPLM50,true);
ArraySetAsSeries(ADXMIM50,true);
ArraySetAsSeries(ADXMNM10,true);
ArraySetAsSeries(ADXPLM10,true);
ArraySetAsSeries(ADXMIM10,true);
ArraySetAsSeries(UD1,true);
ArraySetAsSeries(UH4,true);
ArraySetAsSeries(UH1,true);
ArraySetAsSeries(UH30,true);
ArraySetAsSeries(UH15,true);
ArraySetAsSeries(UH5,true);
ArraySetAsSeries(UM1,true);
ArraySetAsSeries(DD1,true);
ArraySetAsSeries(DH4,true);
ArraySetAsSeries(DH1,true);
ArraySetAsSeries(DH30,true);
ArraySetAsSeries(DH15,true);
ArraySetAsSeries(DH5,true);
ArraySetAsSeries(DM1,true);

return(INIT_SUCCEEDED);
}

//±-----------------------------------------------------------------+
//| Error reporting function |
//±-----------------------------------------------------------------+

void OnDeinit(const int reason)
{
Print(FUNCTION,"_UninitReason = ",DeinitializationError(_UninitReason));
}

//±-----------------------------------------------------------------+
//| 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[])
{

ArrayInitialize(UpBodyHigh,0);                                 //Index elements in the arrays as in a timeseries
ArrayInitialize(UpBodyLow,0);
ArrayInitialize(DnBodyHigh,0);                                 
ArrayInitialize(DnBodyLow,0);
ArrayInitialize(ADXMND10,0);
ArrayInitialize(ADXPLD10,0);
ArrayInitialize(ADXMID10,0);
ArrayInitialize(ADXMNH40,0);
ArrayInitialize(ADXPLH40,0);
ArrayInitialize(ADXMIH40,0);
ArrayInitialize(ADXMNH10,0);
ArrayInitialize(ADXPLH10,0);
ArrayInitialize(ADXMIH10,0);
ArrayInitialize(ADXMNM300,0);
ArrayInitialize(ADXPLM300,0);
ArrayInitialize(ADXMIM300,0);
ArrayInitialize(ADXMNM150,0);
ArrayInitialize(ADXPLM150,0);
ArrayInitialize(ADXMIM150,0);
ArrayInitialize(ADXMNM50,0);
ArrayInitialize(ADXPLM50,0);
ArrayInitialize(ADXMIM50,0);
ArrayInitialize(ADXMNM10,0);
ArrayInitialize(ADXPLM10,0);
ArrayInitialize(ADXMIM10,0);
ArrayInitialize(UD1,0);
ArrayInitialize(UH4,0);
ArrayInitialize(UH1,0);
ArrayInitialize(UH30,0);
ArrayInitialize(UH15,0);
ArrayInitialize(UH5,0);
ArrayInitialize(UM1,0);
ArrayInitialize(DD1,0);
ArrayInitialize(DH4,0);
ArrayInitialize(DH1,0);
ArrayInitialize(DH30,0);
ArrayInitialize(DH15,0);
ArrayInitialize(DH5,0);
ArrayInitialize(DM1,0);

int limit = 0;
int counted_bars=IndicatorCounted(); //How many bars have not changed since the last tick has come in
if(counted_bars<0)
{
return(-1); //Exit OnCalculate - there is an error.
}
if(counted_bars>0)
{
counted_bars–; //After the first pass, decrement the count of counted bars.
}
if(barsback>0)
{
limit=barsback-barsadj; //Set the limit for the maximum bars to be reported on.
}
else
{
limit=Bars-counted_bars-barsadj; //Set limit to be all bars minus bars that have not changed which is zero. Limit = Bars.
} //To eliminate out of range when on the first pass, the indicator looks to one bar to the left of bar 0. Verify the maximum bars to the left of bar 0.

ArrayResize(ADXMND10,limit);
ArrayResize(ADXPLD10,limit);
ArrayResize(ADXMID10,limit);
ArrayResize(ADXMNH40,limit);
ArrayResize(ADXPLH40,limit);
ArrayResize(ADXMIH40,limit);
ArrayResize(ADXMNH10,limit);
ArrayResize(ADXPLH10,limit);
ArrayResize(ADXMIH10,limit);
ArrayResize(ADXMNM300,limit);
ArrayResize(ADXPLM300,limit);
ArrayResize(ADXMIM300,limit);
ArrayResize(ADXMNM150,limit);
ArrayResize(ADXPLM150,limit);
ArrayResize(ADXMIM150,limit);
ArrayResize(ADXMNM50,limit);
ArrayResize(ADXPLM50,limit);
ArrayResize(ADXMIM50,limit);
ArrayResize(ADXMNM10,limit);
ArrayResize(ADXPLM10,limit);
ArrayResize(ADXMIM10,limit);
ArrayResize(UD1,limit);
ArrayResize(UH4,limit);
ArrayResize(UH1,limit);
ArrayResize(UH30,limit);
ArrayResize(UH15,limit);
ArrayResize(UH5,limit);
ArrayResize(UM1,limit);
ArrayResize(DD1,limit);
ArrayResize(DH4,limit);
ArrayResize(DH1,limit);
ArrayResize(DH30,limit);
ArrayResize(DH15,limit);
ArrayResize(DH5,limit);
ArrayResize(DM1,limit);

//for(int i=0 ; i<limit ; i++) //Run to one less than bars on the chart. Calculate from the right side of the chart to the left side of the chart.
for(int i=limit ; i>=0 ; i–) //Run to bars on the chart. Calculate from the left side of the chart to the right side of the chart.
{

   for(i=limit ; i>=0 ; i--)
   		{
        //ADXMND10[i]=iCustom(NULL,1440,"AvgDirMov",0,i);   //ADX Main      
			//ADXPLD10[i]=iCustom(NULL,1440,"AvgDirMov",1,i);   //ADX Plus   
			//ADXMID10[i]=iCustom(NULL,1440,"AvgDirMov",2,i);   //ADX Minus 	
     	ADXMND10[i]=iADX(NULL,1440,14,PRICE_CLOSE,0,i);   //ADX Main      
			ADXPLD10[i]=iADX(NULL,1440,14,PRICE_CLOSE,1,i);   //ADX Plus   
			ADXMID10[i]=iADX(NULL,1440,14,PRICE_CLOSE,2,i);   //ADX Minus 	
     	}
   for(i=limit ; i>=0 ; i--)
   		{
			//ADXMNH40[i]=iCustom(NULL,240,"AvgDirMov",0,i);    //ADX Main
			//ADXPLH40[i]=iCustom(NULL,240,"AvgDirMov",1,i);    //ADX Plus
			//ADXMIH40[i]=iCustom(NULL,240,"AvgDirMov",2,i);    //ADX Minus
			ADXMNH40[i]=iADX(NULL,240,14,PRICE_CLOSE,0,i);    //ADX Main
			ADXPLH40[i]=iADX(NULL,240,14,PRICE_CLOSE,1,i);    //ADX Plus
			ADXMIH40[i]=iADX(NULL,240,14,PRICE_CLOSE,2,i);    //ADX Minus
			}
  for(i=limit ; i>=0 ; i--)
   		{	
         //ADXMNH10[i]=iCustom(NULL,60,"AvgDirMov",0,i);     //ADX Main
         //ADXPLH10[i]=iCustom(NULL,60,"AvgDirMov",1,i);     //ADX Plus
         //ADXMIH10[i]=iCustom(NULL,60,"AvgDirMov",2,i);     //ADX Minus
         ADXMNH10[i]=iADX(NULL,60,14,PRICE_CLOSE,0,i);     //ADX Main
         ADXPLH10[i]=iADX(NULL,60,14,PRICE_CLOSE,1,i);     //ADX Plus
         ADXMIH10[i]=iADX(NULL,60,14,PRICE_CLOSE,2,i);     //ADX Minus
	      }
  for(i=limit ; i>=0 ; i--)
   		{
	      //ADXMNM300[i]=iCustom(NULL,30,"AvgDirMov",0,i);    //ADX Main
	      //ADXPLM300[i]=iCustom(NULL,30,"AvgDirMov",1,i);    //ADX Plus
	      //ADXMIM300[i]=iCustom(NULL,30,"AvgDirMov",2,i);    //ADX Minus
	     	ADXMNM300[i]=iADX(NULL,30,14,PRICE_CLOSE,0,i);    //ADX Main
	      ADXPLM300[i]=iADX(NULL,30,14,PRICE_CLOSE,1,i);    //ADX Plus
	      ADXMIM300[i]=iADX(NULL,30,14,PRICE_CLOSE,2,i);    //ADX Minus
	      }
  for(i=limit ; i>=0 ; i--)
   		{
	      //ADXMNM150[i]=iCustom(NULL,15,"AvgDirMov",0,i);    //ADX Main
	      //ADXPLM150[i]=iCustom(NULL,15,"AvgDirMov",1,i);    //ADX Plus
	      //ADXMIM150[i]=iCustom(NULL,15,"AvgDirMov",2,i);    //ADX Minus
	      ADXMNM150[i]=iADX(NULL,15,14,PRICE_CLOSE,0,i);    //ADX Main
	      ADXPLM150[i]=iADX(NULL,15,14,PRICE_CLOSE,1,i);    //ADX Plus
	      ADXMIM150[i]=iADX(NULL,15,14,PRICE_CLOSE,2,i);    //ADX Minus
	      }
	for(i=limit ; i>=0 ; i--)
	      {
  		//ADXMNM50[i]=iCustom(NULL,5,"AvgDirMov",0,i);      //ADX Main
  		//ADXPLM50[i]=iCustom(NULL,5,"AvgDirMov",1,i);      //ADX Plus
  		//ADXMIM50[i]=iCustom(NULL,5,"AvgDirMov",2,i);      //ADX Minus
  		ADXMNM50[i]=iADX(NULL,15,5,PRICE_CLOSE,0,i);      //ADX Main
  		ADXPLM50[i]=iADX(NULL,15,5,PRICE_CLOSE,1,i);       //ADX Plus
  		ADXMIM50[i]=iADX(NULL,15,5,PRICE_CLOSE,2,i);       //ADX Minus
  		}
	for(i=limit ; i>=0 ; i--)
	      {
  		//ADXMNM10[i]=iCustom(NULL,1,"AvgDirMov",0,i);      //ADX Main
        //ADXPLM10[i]=iCustom(NULL,1,"AvgDirMov",1,i);      //ADX Plus
        //ADXMIM10[i]=iCustom(NULL,1,"AvgDirMov",2,i);      //ADX Minus   
	      ADXMNM10[i]=iADX(NULL,1,5,PRICE_CLOSE,0,i);      //ADX Main
        ADXPLM10[i]=iADX(NULL,1,5,PRICE_CLOSE,1,i);      //ADX Plus
        ADXMIM10[i]=iADX(NULL,1,5,PRICE_CLOSE,2,i);      //ADX Minus   
	      }
	
   for(i=limit ; i>=0 ; i--)
        {
        Print(Time[i],"  ",ADXMND10[i],"  ",ADXPLD10[i],"  ",ADXMID10[i],"  ",ADXMNH40[i],"  ",ADXPLH40[i],"  ",ADXMIH40[i],"  ",ADXMNH10[i],"  ",ADXPLH10[i],"  ",ADXMIH10[i],"  ",ADXMNM300[i],"  ",ADXPLM300[i],"  ",ADXMIM300[i],"  ",ADXMNM150[i],"  ",ADXPLM150[i],"  ",ADXMIM150[i],"  ",ADXMNM50[i],"  ",ADXPLM50[i],"  ",ADXMIM50[i],"  ",ADXMNM10[i],"  ",
        ADXPLM10[i],"  ",ADXMIM10[i]);
        }

 }

return(0);
}

//±-----------------------------------------------------------------+