Не прорисовываеться индикатор... HELP!

 

почему не прорисовываеться индикатор. суть идеи, показывать за определенный период сколько бычьих сечей, а сколько медвежьих

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       period=30;
//---- buffers
double buf1[];
double buf2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,buf1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,buf2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    limit=IndicatorCounted();
//----
   //расчет среднего количества баров за период=======================
   int i;
   int count, up_count, down_count;
   for (i = limit; 0 <= i; i--)
      {
       for(i=period-1; i>=0; i--)
         {
          if (Open[i]<Close[i]) // бычья свеча
            {
             up_count++;
            }
          if (Open[i]>Close[i]) //медвежья свеча
            {
             down_count++;
            }
         }
       buf1[i] = up_count;
       buf2[i] = down_count;
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
dmmikl86 >>:

почему не прорисовываеться индикатор. суть идеи, показывать за определенный период сколько бычьих сечей, а сколько медвежьих



неправильно написаны циклы, ошибка в логическом построении
 
xeon >>:


неправильно написаны циклы, ошибка в логическом построении

 а как тогда правильно будет если я хочу в цикле сделать еще один цикл?

 
dmmikl86 >>:

 а как тогда правильно будет если я хочу в цикле сделать еще один цикл?

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       period=30;
//---- buffers
double buf1[];
double buf2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,buf1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,buf2);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----
   
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   double up_count,down_count;
//----
   //расчет среднего количества баров за период=======================
   for (int i = limit; i>=0; i--)
   {
       if(i<period){period =i;}
       up_count=0;
       down_count=0;
       for(int y=i; y<i+period; y++)
       {
          if (Close[y+1]<Close[y]){up_count++;}// бычья свеча
          if (Close[y+1]>Close[y]){down_count++;}//медвежья свеча
       }
       buf1[i] = up_count;
       buf2[i] = down_count*(-1);
   }
//----
   return(0);
}
//+------------------------------------------------------------------+
Вот так.


сравните со своим кодом и увидите ошибки.

Причина обращения: