What happens when scrolling the chart back?

 

I was wondering what the change in the buffers is when you scroll back and load older data. I am guessing the pre existing indexes are unchanged and the new data is added to the back.

However what is the maximum size the buffer can get?

Is an event created? Does the event cause the start() function to be executed?

Also most importantly, what is returned by the IndicatorCounted() function?

I am asking this because I have had indicators behave awkwardly when this happens.

Cheers guys!

 
50094689:

I was wondering what the change in the buffers is when you scroll back and load older data. I am guessing the pre existing indexes are unchanged and the new data is added to the back.

However what is the maximum size the buffer can get?

Is an event created? Does the event cause the start() function to be executed?

Also most importantly, what is returned by the IndicatorCounted() function?

I am asking this because I have had indicators behave awkwardly when this happens.

Me too, I never resolved the issue to my satisfaction, if you can please let us know.
 
Have you logged this with the service desk?
 
Trevhib:
Have you logged this with the service desk?
Logged what ? my ignorance of how to address my issue ?
 

Wthen you add more history data while an indicator is loaded;

IndicatorCounted() returns 0

Bars reflects the new amount of bars

so if you have something like limit = Bars - 1 - CountedBars;

limit is set to the new amount of Bars - 1 therfore the entire indicator should be redrawn, BUT. It doesn't always redraw it properly, I believe it has something to do with the buffers not being reinitialized when the indicator is redrawn, I havent been able to figure out why, but for some reason the indicator is getting redrawn with some of the old values as well as the new values, anyway I think the answer is to reinitialize the buffers.

 
   int    counted_bars=IndicatorCounted();
   int    i,limit=Bars-1-counted_bars;
   Print("Bars = ",Bars," IndicatorCounted = ",IndicatorCounted()," Limit = ",limit);

output:

20:20:35 Bars EURUSD,M15: loaded successfully
20:20:37 Bars EURUSD,M15: initialized
20:20:37 Bars EURUSD,M15: Bars = 44449 IndicatorCounted = 0 Limit = 44448 //start()
20:20:53 Bars EURUSD,M15: Bars = 44449 IndicatorCounted = 44448 Limit = 0 //tick
20:20:56 Bars EURUSD,M15: Bars = 44449 IndicatorCounted = 44448 Limit = 0 //tick
20:21:05 Bars EURUSD,M15: Bars = 44449 IndicatorCounted = 44448 Limit = 0 //tick
20:21:13 Bars EURUSD,M15: Bars = 44449 IndicatorCounted = 44448 Limit = 0 //tick
20:21:22 Bars EURUSD,M15: Bars = 44449 IndicatorCounted = 44448 Limit = 0 //tick
20:21:39 Bars EURUSD,M15: Bars = 44449 IndicatorCounted = 44448 Limit = 0 //tick
20:21:44 Bars EURUSD,M15: Bars = 44480 IndicatorCounted = 0 Limit = 44479 //Home button, more history loaded
20:21:48 Bars EURUSD,M15: Bars = 44480 IndicatorCounted = 44479 Limit = 0 //tick
20:21:57 Bars EURUSD,M15: Bars = 44480 IndicatorCounted = 44479 Limit = 0 //tick
20:22:07 Bars EURUSD,M15: Bars = 44480 IndicatorCounted = 44479 Limit = 0 //tick

 

I did some testing and the messed up indicator problem is not helped by WindowRedraw() but it does appear to be fixed if you reinitialize the buffers,

if(Indicator_Counted() == 0) //history loaded

{ArrayInitialize(Buffer1,EMPTY_VALUE); 

 ArrayInitialize(Buffer2,EMPTY_VALUE); 

 ArrayInitialize(Buffer3,EMPTY_VALUE);  

}

That might need some more testing to be sure it doesn't create a different problem...

 

some more useful info, (based on my own testing)

Buffers are automatically initialized to EMPTY_VALUE when the indicator is loaded. Calling init() after that wont automatically reinitialize the buffers unless you code it to do so.

Buffers are also not automatically reinitialized after recompile or after historical data is loaded

Doing ArrayInitialize() in init() will throw up errors in the log if you do it the first time the indicator is loaded.

it is OK to do ArrayInitialize() in init() after the indicator has already been loaded so use bool flag if you want to do call init() from start() to do ArrayInitialize() in init().

 

Really interesting... Initializing the array when IndicatorCounted() returns 0 deals with the hiccups in the indicator. Cheers SDC.

 
RaptorUK:
Logged what ? my ignorance of how to address my issue ?


What I said was tongue in cheek ;)
 
Trevhib:

What I said was tongue in cheek ;)
Ah
Reason: