Updating Custom Indicator Line Automatically

unaizams

Newbie
Messages
6
Likes
0
Hi,

I noticed that some custom indicators do not redraw themselves automatically to the new bars with every incoming tick or bar. Only when you first open the chart or when you click a different time frame and then chick back their lines get redrawn to the last bar.

So what is making them behave like that?

Going to Charts/Refresh or rightclicking Refresh doesn't help and adding WindowRedraw() to the code doesn't help either.

I've read that the problem may be that such indicator(s) use a limit, i.e. the IndicatorCounted() function severely limits the loop for the indicator in order to not repaint bars.

Here is an example of the limit in such an indicator:

PHP:
   int i,limit;
   int counted_bars=IndicatorCounted();
   //---- check for possible errors
   if(counted_bars<0) return(-1);
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-Periods-1-counted_bars;
   //---- main loop
   for(i=limit; i>=0; i--) {



Thanks for providing a solution.
 
Top