iCustom problem

 

Hello, I have a strange problem. When I load my written indicator based on another iCustom indicator on the chart, two lines appear, although it should be only one.

#property strict

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

input int SignalPeriod=5;
input int NR_SLIPE=3;
input double FilterNumber=1.0;
input int Points=20;

double Above[],Below[],temp[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   IndicatorBuffers(3);

   SetIndexBuffer(0,Above);
   SetIndexBuffer(1,Below);
   SetIndexBuffer(2,temp);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexLabel(0,"Above");
   SetIndexLabel(1,"Below");
   
   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[])
{
   int pos;
   int limit;
   if(!prev_calculated)limit=rates_total-SignalPeriod;
   else limit=rates_total-prev_calculated;
   
   for(pos=0; pos<=limit; pos++)
   {
      if(iCustom(_Symbol,_Period,"SuperScalper",SignalPeriod,NR_SLIPE,FilterNumber,0,pos)>0 && iCustom(_Symbol,_Period,"SuperScalper",SignalPeriod,NR_SLIPE,FilterNumber,0,pos)!=2147483647.0)
      {
         temp[pos]=iCustom(_Symbol,_Period,"SuperScalper",SignalPeriod,NR_SLIPE,FilterNumber,0,pos);
      }
      if(iCustom(_Symbol,_Period,"SuperScalper",SignalPeriod,NR_SLIPE,FilterNumber,2,pos)>0 && iCustom(_Symbol,_Period,"SuperScalper",SignalPeriod,NR_SLIPE,FilterNumber,2,pos)!=2147483647.0)
      {
         temp[pos]=iCustom(_Symbol,_Period,"SuperScalper",SignalPeriod,NR_SLIPE,FilterNumber,2,pos);
      }
   }
   
   for(int i=limit;i>=0;i--)
   {
      if(temp[i]>temp[i+1] && temp[i]!=2147483647.0 && temp[i+1]!=2147483647.0)
      {
         Below[i]=temp[i]+0.00100;
         Below[i+1]=temp[i+1]+0.00100;
         Above[i]=EMPTY_VALUE;
         
//         Below[i]=temp[i];
//         Below[i+1]=temp[i+1];
//         Above[i]=EMPTY_VALUE;
      }
      if(temp[i]<temp[i+1] && temp[i]!=2147483647.0 && temp[i+1]!=2147483647.0)
      {
         Above[i]=temp[i]+0.00100;
         Above[i+1]=temp[i+1]+0.00100;
         Below[i]=EMPTY_VALUE;
         
//         Above[i]=temp[i];
//         Above[i+1]=temp[i+1];
//         Below[i]=EMPTY_VALUE;
      }
   }
   
   return(rates_total);
}
//+------------------------------------------------------------------+
Files:
AUDUSDM1.png  65 kb
 
I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.