mql5 file compile with NO error, but won't plot

 

hello all the gurus out there, I am new to mq5.  My mql5 file compile with NO error, but won't plot, can someone please tell me what is wrong and help me fix it. thanks.


#property copyright ""
#property link ""
#property version "1.00"

#property indicator_chart_window

#property indicator_buffers 4
#property indicator_plots 1

#property indicator_color1 clrYellow
#property indicator_width1 2
#property indicator_style1 STYLE_SOLID



// Indicator parameters
input int                  length = 100;  // Length
input int                  incr   = 10;   //Increment

double                     maBuffer[];
double                     alphaBuffer[];
double                     upperBuffer[];
double                     lowerBuffer[];
 
int                        upperHandle;
int                        lowerHandle;
int                        init_maHandle;
int                        alphaHandle;
int                        maHandle;

;
int OnInit() {

   SetIndexBuffer( 0, maBuffer, INDICATOR_DATA );
   PlotIndexSetInteger( 0, PLOT_DRAW_TYPE, DRAW_LINE );
   PlotIndexSetString( 0, PLOT_LABEL, "my MA" );
   ArraySetAsSeries( maBuffer, true );

   SetIndexBuffer( 1, alphaBuffer );
   ArraySetAsSeries( alphaBuffer, true );
   
    SetIndexBuffer( 2, upperBuffer );
   ArraySetAsSeries( upperBuffer, true );
   
    SetIndexBuffer( 3, lowerBuffer );
   ArraySetAsSeries( lowerBuffer, true );

   upperHandle = iHighest(NULL, 0, MODE_HIGH, length, 0);
   lowerHandle  = iLowest(NULL, 0, MODE_LOW, length, 0); 
   init_maHandle = iMA( Symbol(), Period(), length, 0, MODE_SMA, PRICE_CLOSE );
   alphaHandle = 0;
   maHandle = 0;
   
   
   return ( INIT_SUCCEEDED );
}

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

   //   Need a minimum number of available rates to function
   if ( rates_total < length ) return ( 0 );

   //   Housekeeping to release asap
   if ( IsStopped() ) return ( 0 );

   // Skip values already calculated
   int    limit = ( prev_calculated == 0 ) ? rates_total - length - 1 : rates_total - prev_calculated;

   double highValues[];
   double lowValues[];
   double iniValues[];
   double alphaValues[];
   double maValues[];
    
   ArraySetAsSeries( highValues, true );
   ArraySetAsSeries( lowValues, true );
   ArraySetAsSeries( close, true );
   ArraySetAsSeries( iniValues, true );
   ArraySetAsSeries( alphaValues, true );
   ArraySetAsSeries( maValues, true );


   CopyBuffer( upperHandle, 0, 0, limit + 1, highValues );
   CopyBuffer( lowerHandle, 0, 0, limit + 1, lowValues );
   CopyBuffer( init_maHandle, 0, 0, limit + 1, iniValues );
   CopyBuffer( alphaHandle, 0, 0, limit + 1, alphaValues );
   CopyBuffer( maHandle, 0, 0, limit + 1, maValues );

   //   Loop through bars
   for ( int i = limit; i >= 0 && !IsStopped(); i-- ) {

   //   double hi          = highValues[i];
   //   double lo          = lowValues[i];
      double ini          = iniValues[i];
  //    double alp         = alphaValues[i];
  //    double ma         = maValues[i];
      double k = 1.0 / incr;
     int cross ;   
      
      cross = ((close[i] > maBuffer[i] && close[i+1] <= maBuffer[i+1]) || (close[i] < maBuffer[i] && close[i+1] >= maBuffer[i+1])) ? 1 : 0;
      alphaBuffer[i] = cross ? 2.0 / (length + 1.0)
            : close[i] > maBuffer[i] && upperBuffer[i] > upperBuffer[i+1] ? alphaBuffer[i] + k
            : close[i] < maBuffer[i] && lowerBuffer[i] < lowerBuffer[i+1] ? alphaBuffer[i] + k
            : alphaBuffer[i];
            
       //if( !MathIsValidNumber( maBuffer[i+1] + alphaBuffer[i+1] * (close[i] - maBuffer[i+1])) )
       //maBuffer[i] = ini;
       maBuffer[i] = MathIsValidNumber( maBuffer[i+1] + alphaBuffer[i+1] * (close[i] - maBuffer[i+1])) ? maBuffer[i] : ini;

   }

   return ( rates_total );
}
Files:
myMA.mq5  5 kb
 
   upperHandle = iHighest(NULL, 0, MODE_HIGH, length, 0);
   lowerHandle  = iLowest(NULL, 0, MODE_LOW, length, 0); 
iHighest/iLowest does not return a handle.
Reason: