- Graphical Objects - Analytical Objects - Price Charts, Technical and Fundamental Analysis
- Analytical Objects - Price Charts, Technical and Fundamental Analysis
- Bitmap Label - Graphical Objects - Analytical Objects - Price Charts, Technical and Fundamental Analysis
In case the symbol or timeframe of a chart, to which the Expert Advisor is attached, changes, Expert Advisors are not loaded or unloaded. In this case client terminal subsequently calls OnDeinit() handlers on the old symbol/timeframe and OnInit() on the new symbol/timeframe (if they are such), values of global variables and static variables are not reset. All events, which have been received for the Expert Advisor before the initialization is completed (OnInit() function) are skipped.
Thus the OnInit() event is raised. And in the OnInit () all items are created anew.
In case the symbol or timeframe of a chart, to which the Expert Advisor is attached, changes, Expert Advisors are not loaded or unloaded. In this case client terminal subsequently calls OnDeinit() handlers on the old symbol/timeframe and OnInit() on the new symbol/timeframe (if they are such), values of global variables and static variables are not reset. All events, which have been received for the Expert Advisor before the initialization is completed (OnInit() function) are skipped.
Thus the OnInit() event is raised. And in the OnInit () all items are created anew.
Store the state of the labels in global variables then (if they exist), load them in OnInit()
I use this code for resolve such problem
int LastDeinitReason = 0; void OnDeinit(const int reason) { LastDeinitReason = reason; if(reason==REASON_CHARTCHANGE || reason==REASON_TEMPLATE || reason==REASON_PARAMETERS) return; // code for real deinit } int OnInit() { if(LastDeinitReason==REASON_CHARTCHANGE || LastDeinitReason==REASON_TEMPLATE) { LastDeinitReason = 0; return(INIT_SUCCEEDED); } if(LastDeinitReason==REASON_PARAMETERS) { SetParameters(); return(INIT_SUCCEEDED); } // code for start init }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use