Вопрос к знатокам MQL4!

[Удален]  

Доброго времени суток!


По какой причине возникают ошибки с использованием iCustom и как их исправить ?


Код:

//+------------------------------------------------------------------+
//|                                                        ind 1.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 White
#property indicator_level1 0
 
double i_buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  SetIndexStyle(0,DRAW_LINE);
  SetIndexBuffer(0,i_buffer);
 
   return(0);
  }
 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted(),
       limit;    
   int i;    
   if(counted_bars>0)counted_bars--;
   
   limit=Bars-counted_bars;
   for(i=0;i<limit;i++)
   {
   i_buffer[i]=iCustom(NULL,0,"SMI",2,1,2,1,0,0);
   //i_buffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i);
   }
   return(0);
  }
//+------------------------------------------------------------------+

Резултат:

Файлы:
smi.mq4  4 kb
[Удален]  
Если
i_buffer[i]=iCustom(NULL,0,"SMI",2,1,2,1,0,0);
заменить на
i_buffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i);

или другой технический индикатор, то всё отрисовывается отлично.

 
for(i=0;i<limit;i++)
   {
   i_buffer[i]=iCustom(NULL,0,"SMI",2,1,2,1,0,0);
   //i_buffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i);
   }
///Потому что любому другому индикатору вы передаете переменную "i", а индикатору SMI передаете константу "0".
[Удален]  

Korey, большое спасибо!