iCustom is read out incorrectly - page 2

 

My code now looks like this. And it seems to work.

//+------------------------------------------------------------------+
//|                                               SuperIndicator.mq4 |
//|                                        Copyright 2020, Arthur S. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Arthur S."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrAqua
#property indicator_color2 clrYellow

double UpBuffer[];
double DownBuffer[];

input int Input1=4;
input int Input2=5;
input int Input3=3;
input int Input4=2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0,UpBuffer);
   SetIndexLabel(0,"Buy");
   SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,5);
   SetIndexArrow(0,233);
   
   SetIndexBuffer(1,DownBuffer);
   SetIndexLabel(1,"Sell");
   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,5);
   SetIndexArrow(1,234);
   
   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[])
{
   ArraySetAsSeries(UpBuffer,true);
   ArraySetAsSeries(DownBuffer,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(close,true);
   
//   for(int i=0;i<rates_total;i++)
//   for(int i=rates_total-2;i>=0;i--)
   for(int i=0;i<rates_total;i++)
   {
      UpBuffer[i]=0;
      DownBuffer[i]=0;
      
      /*double BuyBuffer=NormalizeDouble(iCustom(NULL,0,"100pips Momentum_1.4",1,15,"",false,false,false,"",Input1,i),_Digits);
      double SellBuffer=NormalizeDouble(iCustom(NULL,0,"100pips Momentum_1.4",1,15,"",false,false,false,"",Input2,i),_Digits);
      double BlueMA=NormalizeDouble(iCustom(NULL,0,"100pips Momentum_1.4",1,15,"",false,false,false,"",Input3,i),_Digits);
      double RedMA=NormalizeDouble(iCustom(NULL,0,"100pips Momentum_1.4",1,15,"",false,false,false,"",Input4,i),_Digits);*/
      
      double BuyBuffer=iCustom(NULL,0,"100pips Momentum_1.4",1,15,"",false,false,false,"",4,i);    // 2147483647.0
      
      if((BuyBuffer>0) && (BuyBuffer!=2147483647.0))
      {
         UpBuffer[i]=low[i];
      }
      /*if(SellBuffer>0)
      {
         DownBuffer[i]=high[i];
      }*/
   }
   
   return(rates_total);
}
//+------------------------------------------------------------------+
Reason: