переделать индикатора в эксперт

 

Здравствуйте! В индикаторе проверка алертом

Alert (100.0*(1.0-1.0/(1.0+positive/negative)));
дает нужное значение.

Попытался переделать индикатор в советник (см код ниже ....заштриховал в шапке все "проперти" и поставил баров =2000

вместо IndicatorCounted(); ) но Алерт дает ноль на выходе ((( ПОДСКАЖИТЕ ПЛИЗ что не так. Спасибо.

//The Relative Brokers Vigor Index RBVI. Based on code RSI.mq4, Copyright © 2004, MetaQuotes Software Corp.
#property copyright "Copyright © 2004, MetaQuotes Software Corp., BECEMAL 2010"
#property link " "
//#property indicator_separate_window
//#property indicator_minimum 0
//#property indicator_maximum 100
//#property indicator_level1 40
//#property indicator_level2 602
//#property indicator_buffers 3
//#property indicator_color1 RoyalBlue
extern int RBVIPeriod=10;
double RBVIBuffer[];
double PosBuffer[];
double NegBuffer[];
string xxx;

int init()
{
// string short_name = "RBVI("+RBVIPeriod+")";
//SetIndexBuffer(1,PosBuffer);
// SetIndexBuffer(2,NegBuffer);
//SetIndexStyle(0,DRAW_LINE);
//SetIndexStyle(1,DRAW_NONE);
//SetIndexStyle(2,DRAW_NONE);
//SetIndexBuffer(0,RBVIBuffer);
//IndicatorShortName(short_name);
//SetIndexLabel(0,"RBVI");
// SetIndexDrawBegin(0,RBVIPeriod);
PosBuffer[-1]=0;
NegBuffer[-1]=0;
PosBuffer[0]=0;
NegBuffer[0]=0;

return(0);

}
int start()
{


xxx="EURUSD";



int i, counted_bars = 2000 ; // IndicatorCounted();

double rel, negative, positive, sumn, sump;


if(iBars(xxx,PERIOD_M15)<=RBVIPeriod) return(0);
if(counted_bars<1)

for(i=1;i<=RBVIPeriod;i++) RBVIBuffer[iBars(xxx,PERIOD_M15)-i]=50.0;
i=iBars(xxx,PERIOD_M15)-RBVIPeriod-1;
if(counted_bars>=RBVIPeriod) i=iBars(xxx,PERIOD_M15)-counted_bars-1;
while(i >= 0) {
sumn=0.0; sump=0.0;
rel=iATR(xxx,0,RBVIPeriod,i) * iVolume(xxx,PERIOD_M15,i)- iATR(xxx,0,RBVIPeriod,i+1)
* iVolume(xxx,PERIOD_M15,i+1);
if(rel>0) {sump= rel; }
else sumn=-rel;
positive=(PosBuffer[i+1]*(RBVIPeriod-1)+sump)/RBVIPeriod;
negative=(NegBuffer[i+1]*(RBVIPeriod-1)+sumn)/RBVIPeriod;
PosBuffer[i]=positive;
NegBuffer[i]=negative;
if(negative==0.0) RBVIBuffer[i]=0.0;
else
RBVIBuffer[i]=100.0*(1.0-1.0/(1.0+positive/negative));
i--;
}

Alert (100.0*(1.0-1.0/(1.0+positive/negative)));



return(0);


}

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