Highest Value in an array

 

I would like to know where I am doing a mistake in this formula, I couldn't find it. It is only showing the first buffer - Impulse[]. .Thanks. Rodrigosm


#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow

//--- External Variables ---//
extern int periodos=20;

//--- External Buffers ---//
double Impulse[];
double maximo[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators buffers
   IndicatorBuffers(2);
   
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,Impulse);
   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,maximo);
   
   return(0);
  }
//-----  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {int   counted_bars=IndicatorCounted();
   int limit;
  
//---- Data ckecking ----//
   if (counted_bars==0)
      {
      limit=Bars-1;
      }
   if (counted_bars>0)
      {
      limit=Bars-counted_bars;
      } 
     
//---- Math part ----//
   for(int i=limit;i>=0;i--) // Count down for one pass
      {   
        Impulse[i]=MathAbs(Close[i]-Close[i+1]);
        
//--- Find the highest impulse's value        
        
        maximo[i]=maximo[ArrayMaximum(Impulse,periodos,i)];

      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
rodrigosm:

I would like to know where I am doing a mistake in this formula, I couldn't find it. It is only showing the first buffer - Impulse[]. .Thanks. Rodrigosm



I already found my error -

 maximo[i]=Impulse[ArrayMaximum(Impulse,periodos,i)];
Reason: