Disruption of the plot after timeframe change

 
Hello, I have an mt4 indicator. When I changed the timeframe, I realized that there was an different in the old plots in the timeframe opened. When I add the indicator to the chart again, it plots as it should. 

How can I make it work as opened from scratch every time it changes timeframe like in mt5? 

By the way, I want you to know that I reset the arrays and global values every time the deinit and init functions are called.

The blue line is the timeframe change indicator.

Yellow line is the indicator initialized from scratch


Update: When I reopen the timeframe I opened, the plots are corrected, for example, I opened the 1m timeframe, the plot is incorrect, it is corrected when I open 5m and open 1m again.

Files:
1.png  85 kb