ошибка в коде индикатора

 

помогите новичку. понадобился индикатор МА с 2 линиями по High и Low ценам. пробовал переделать стандартныи - неполучилось. Показывает толко одну линию. В чем проблема - помогите разобратся.

с ***** отмечены места которые добавлены

//+------------------------------------------------------------------+
//|                                        Custom Moving Average.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"
 
#property indicator_chart_window
#property indicator_buffers 2 //***** added 1 buffer
#property indicator_color1 Red
#property indicator_color2 Gold//*****
//---- indicator parameters
extern int MA_Period=10;
extern int MA_Shift=0;
//---- indicator buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];//*****
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int    draw_begin;
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexShift(0,MA_Shift);
   
   SetIndexStyle(1,DRAW_LINE);//*****
   SetIndexShift(1,MA_Shift);//*****
   
   if(MA_Period<2) MA_Period=13;
   draw_begin=MA_Period-1;
 
 //  IndicatorShortName(short_name+MA_Period+")");
   SetIndexDrawBegin(0,draw_begin);
   SetIndexDrawBegin(1,draw_begin);//*****
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexBuffer(1,ExtMapBuffer2);//*****
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   if(Bars<=MA_Period) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
//----
 
//+------------------------------------------------------------------+
//| Simple Moving Average                                            |
//+------------------------------------------------------------------+
 
   double sumH=0;
   double sumL=0;//*****
   int    i,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<MA_Period;i++,pos--)
      sumH+=High[pos];
      sumL+=Low[pos];//*****
      
//---- main calculation loop
   while(pos>=0)
     {
      sumH+=High[pos];
      sumL+=Low[pos];//*****
      
    ExtMapBuffer[pos]=sumH/MA_Period;
    ExtMapBuffer2[pos]=sumL/MA_Period;//*****
     
       sumH-=High[pos+MA_Period-1];
       sumL-=Low[pos+MA_Period-1];//*****
      
        pos--;
     }
//---- zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++)
         {
         ExtMapBuffer[Bars-i]=0;
         ExtMapBuffer2[Bars-i]=0;//*****
         }
  return;
  }
//----
//+------------------------------------------------------------------+
 
может всетаки кто то разберается лучше меня.... :(
[Удален]  
Просто невнимательность:
   for(i=1;i<MA_Period;i++,pos--)
      sumH+=High[pos];
      sumL+=Low[pos];//*****
А надо:
   for(i=1;i<MA_Period;i++,pos--)
   {
      sumH+=High[pos];
      sumL+=Low[pos];//*****
   }
 
Вторая линия там тоже присутствует только много ниже.
 
СПАСИБО Figar0 !!! а то по 20 раз пересмотрел и некак не мог понять в чем ошыбка...