Obnovlenie idicatora

 
Znaeshie lydi pomogite razobratza. Y menia indicator ne obnaviatza sam. Prihodidza delat "right click"->"Obnovlenie"

//+------------------------------------------------------------------+
//| Index .mq4 
//| Aborigen 
//| http://forex.kbpauk.ru/ 
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

//---- input parameters
extern int Show=0;
//---- buffers
double IndexBuffer[];
  
//  Show=0 index USD
//  Show=1 index GBP   
//  Show=2 index EUR  
//  Show=3 index CHF
//  Show=4 index JPY
  
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,IndexBuffer);
   //SetIndexEmptyValue(0,0);
   //ArrayInitialize(IndexBuffer,0);

   
//---- name for DataWindow and indicator subwindow label
   //SetIndexDrawBegin(0,2);
//----
if (Show<0 || Show>4)
   {    Comment ("Show must be >0 and <5");    return(-1); }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()

  {
  int counted_bars=IndicatorCounted();
  int i;
  double USD, GBP, EUR, CHF, JPY;
  double Data1,Data2,Data3,Data4;
  if (counted_bars==0) i=5000;
  if (counted_bars>0) i=5000-counted_bars+1;
  //i=(5000-counted_bars)+1;
  i--;
   while(i>=0)
{

Data1=iClose("GBPUSD",NULL,i);
Data2=iClose("USDCHF",NULL,i);
Data3=iClose("EURUSD",NULL,i);
Data4=iClose("USDJPY",NULL,i);

USD = MathPow( Data2 * Data4 / Data1 / Data3, 0.2); 
GBP = Data1 * USD; 
EUR = Data3 * USD; 
CHF = USD / Data2; 
JPY = USD / Data4; 

switch (Show) 
   {
   case 0: IndexBuffer[i]=USD; break;
   case 1: IndexBuffer[i]=GBP; break;
   case 2: IndexBuffer[i]=EUR; break;
   case 3: IndexBuffer[i]=CHF; break;
   case 4: IndexBuffer[i]=JPY; break;
   }

      i--;
}  
//----
   return(0);
  }
//+------------------------------------------------------------------+




 
мне кажется, нужно вместо
i=5000-counted_bars+1;

вставить
i=Bars-counted_bars+1;
 
мне кажется, нужно вместо
i=5000-counted_bars+1;

вставить
i=Bars-counted_bars+1;



Me nepomoglo.

Ydalil indicatorcounted() funkzyu voopshe, teper obnavlietza. No zato ondicator peririsovivaetza na kazdom tike chto zamedliaet sistemy :(
 
  if (counted_bars>0) i=5000-counted_bars+1;
  //i=(5000-counted_bars)+1;
  i--;


этот
i--;
надо было удалить :)

 
  if (counted_bars>0) i=5000-counted_bars+1;
  //i=(5000-counted_bars)+1;
  i--;


этот
i--;
надо было удалить :)



Probival, Indicator risueza no ne obnavliaetza.
 
При нормальной работе индикатора при первом вызове IndicatorCounted() возвращает 0. После первого пересчета возвращает число на 1 меньше Bars. При появлении нового бара разница составляет 2, после пересчета опять 1. Исходя из этого, все, что советовали выше, должно выглядеть так:
 ...
  if (counted_bars==0) i=5000;
  if (counted_bars>0) i=Bars-1-counted_bars;

  while(i>=0)
 ...


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

 
Странно, посылки все верные, а выводы нет.
 
Почему?
 
A I vot kak sdelal:
 if (counted_bars==0) i=5000;
  if (counted_bars>0) i=2;

  while(i>=0)


Risyet vsy istoriu (5000 barov) i obnavlietza!
Spasibo Roman i Rosh.

 
vasilyt, вечером выключишь комп, утром включишь. Индикатор прорисуется, потом докачается история, потом просчитаются 2 последних бара. Дыра в индикаторе должна получиться.
Причина обращения: