Is "while(!IsStopped())" expected to work on Indicators?

 

Hi, the code "while(!IsStopped())" is not working on my Indicator. 

I have a code like this:

      while(!IsStopped()){
         copied = CopyTicks(_Symbol, ticks, COPY_TICKS_ALL, LAST_TICK_TIME, 1000000);
	 Print("COPIED: "+copied);
         if(copied>0){
            LAST_TICK_TIME = ticks[copied - 1].time_msc;
            handleTicks(ticks);
         }
         if(copied < ticks_to_copy ) break;
      } 

If i remove indicator from chart or close the chart, the operations inside "while" continue until the "break" is triggered (i can see it in logs).

Is it expected behaviour or a bug?

 
antony23:

Hi, the code "while(!IsStopped())" is not working on my Indicator. 

I have a code like this:

If i remove indicator from chart or close the chart, the operations inside "while" continue until the "break" is triggered (i can see it in logs).

Is it expected behaviour or a bug?

You have a loop that runs until it is complete. IsStopped() detects 3 seconds of inactivity when the code is running. in contrast, OnDeinit() detects when the indicator has been removed.

Expected. Not a bug.