EA reset when I change time frame

 
hi sir have an EA that creates horizontal lines and create a button when initiated. If the button is pressed an order will open and  all the horizontal line that have created upon inititating the EA will be deleted buy ObjectDelete. For example i pressed the button on 1 min TF it do its job making an order and deleting the lines, its works fine until i  change the timeframe after pressing the button it seems to reset the EA and  it brings back all the horizontal line that was deleted. 
 
Of course, it is reloaded on chart change.
 
William Roeder #:
Of course, it is reloaded on chart change.
Oh i see is theres a way not to reload it? Do i need to add a code?
 
What part of “is reloaded” was unclear?
 
William Roeder #:
What part of “is reloaded” was unclear?

thank you sir but I have solved the problem I used this


bool FirstOnInit = False;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
 

if(Symbol()==_Symbol && FirstOnInit == False )
  {      
FirstOnInit = True;  

/////Codes not to reload on change of timeframe

 }

}
 
mark692 #: thank you sir but I have solved the problem I used this

You haven't solved anything.

  1. Symbol() always equals _Symbol.
  2. Your EA has been reloaded, therefor FirstOnInit will always be reset.

if, and only if, the uninit reason iREASON_CHARTCHANGE, save your state in persistent storage (files, global variables) and check if the symbol has not changed on init.

 
William Roeder #:

You haven't solved anything.

  1. Symbol() always equals _Symbol.
  2. Your EA has been reloaded, therefor FirstOnInit will always be reset.

if, and only if, the uninit reason iREASON_CHARTCHANGE, save your state in persistent storage (files, global variables) and check if the symbol has not changed on init.

i dont know what happen sir but the horizontal line is not appearing now if i change my timeframe.. hmmm thats weird