Please help. question about drawing line connecting the highest point in every 20 bars.

 
//+------------------------------------------------------------------+
//|                                                 draw_hi_low_line.mq4 |
//|                       Copyright ?2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
//---- buffers
double ExtMapBuffer1[];  //  draw line with the highest point at a every 20 bars.
double ExtMapBuffer2[];  //  draw line with the lowest point at a every 20 bars.
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int    counted_bars=IndicatorCounted(); 
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit = Bars-counted_bars;   
   int i,j;
   
//----
   for(i=0;i<limit;)
   {
   ExtMapBuffer1[i]=iHighest(NULL,Period(),MODE_HIGH,20,i);
   ExtMapBuffer2[i]=iLowest(NULL,Period(),MODE_LOW,20,i);
   i=i+20;
   
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

 

this indicator does not draw lines,why?

 
Because iHighest returns an index, not a value. Use iHigh( NULL, Period(), iHighest(...) ) & iLow in the same way.
 
hasayama:
Because iHighest returns an index, not a value. Use iHigh( NULL, Period(), iHighest(...) ) & iLow in the same way.


Thank you,hasayama !

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
Returns the shift of the maximum value over a specific number of periods depending on type.