How to get a Variable Not to Initialize when timeframe changes??

 

Please anybody could inform me how it is possible for a variable not to be initialize every time the timeframe changes...

I want to create an MTF indicator and some prices of variables should stay the same when timeframe changes and not initialize them again!!!

 
Kaloko:

Please anybody could inform me how it is possible for a variable not to be initialize every time the timeframe changes...

I want to create an MTF indicator and some prices of variables should stay the same when timeframe changes and not initialize them again!!!

Use global variables.

Global Variables of the Terminal - MQL4 Reference
Global Variables of the Terminal - MQL4 Reference
  • docs.mql4.com
Global variables are kept in the client terminal for 4 weeks since the last access, then they will be deleted automatically. An access to a global variable is not only setting of a new value, but reading of the global variable value, as well. When testing and optimizing the Expert Advisors that use global variables, keep in mind...
 
  1. Unlike indicators, EAs are not reloaded on chart change — just use globally declared or static variables.

  2. For indicators, it should just redraw everything. You do not want it do different things. Rethink your problem.
 
William Roeder:
  1. Unlike indicators, EAs are not reloaded on chart change — just use globally declared or static variables.

  2. For indicators, it should just redraw everything. You do not want it do different things. Rethink your problem.

Thank you for your reply!!

Reason: