Indicator working only after a while

 

This is strange, but proberly a newbie problem.

When I first run my indicator no lines is visible, but after a minute they start to show (I have 1 min resoloution). This is irritating because I have to wait for a hour before everything works as it should...

When I run my other indicators they draw the lines from left to right across my screen on startup...

I guess that, the buffer array is not fed with values and maybe the "Bars" value is causing this...

//--
if(Bars<=length) return(0);
i=Bars-length;
if(counted_bars>length) i=Bars-counted_bars-1;
//--

Any suggestions?

 
IntraTrade:

This is strange, but proberly a newbie problem.

When I first run my indicator no lines is visible, but after a minute they start to show (I have 1 min resoloution). This is irritating because I have to wait for a hour before everything works as it should...

When I run my other indicators they draw the lines from left to right across my screen on startup...

I guess that, the buffer array is not fed with values and maybe the "Bars" value is causing this...

//--
if(Bars<=length) return(0);
i=Bars-length;
if(counted_bars>length) i=Bars-counted_bars-1;
//--

Any suggestions?


If I use the 15 minutes timeframe it starts to work right away????
 
IntraTrade:

If I use the 15 minutes timeframe it starts to work right away????


I don´t like MQL... I can´t divide by zero :-))))

The program-output told me. I didn´t know the program had this debug feature while running. Otherwise I´ll be stuck...

Solved :)

 
IntraTrade:

This is strange, but proberly a newbie problem.

When I first run my indicator no lines is visible, but after a minute they start to show (I have 1 min resoloution). This is irritating because I have to wait for a hour before everything works as it should...

When I run my other indicators they draw the lines from left to right across my screen on startup...

I guess that, the buffer array is not fed with values and maybe the "Bars" value is causing this...

//--
if(Bars<=length) return(0);
i=Bars-length;
if(counted_bars>length) i=Bars-counted_bars-1;
//--


  1. Bars is not the problem. Your problem has to do with length. I assume you're doing a ma(length)
    int drawBegin = length; // Looking back maximum
    int counted_bars = IndicatorCounted();
    if (counted_bars < drawBegin) counted_bars = drawBegin;
    for(int i = Bars - 1 - counted_bars; i >= 0; i--){
       :
Reason: