Some more Info about that issue :
So i fixed the problem by change the code of the function CAppDialog::Destroy, from the include Dialog.mqh .
//+------------------------------------------------------------------+ //| Application dialog deinitialization function | //+------------------------------------------------------------------+ void CAppDialog::Destroy(const int reason) { /* HERE IS THE PROBLEM !!!!!!!!!!!!!!!! //--- destroyed already? if(m_deinit_reason!=WRONG_VALUE) return; */ //--- m_deinit_reason=reason; IniFileSave(); //--- detach chart object from chart m_chart.Detach(); //--- call parent destroy CDialog::Destroy(); //--- if(reason==REASON_PROGRAM) { if(m_program_type==PROGRAM_EXPERT) ExpertRemove(); if(m_program_type==PROGRAM_INDICATOR) ChartIndicatorDelete(m_chart_id,m_subwin,m_indicator_name); } //--- send message EventChartCustom(CONTROLS_SELF_MESSAGE,ON_APP_CLOSE,m_subwin,0.0,m_program_name); }
I think that the problem is on "m_deinit_reason " (private variable inside the Dialog.mqh). If the timeframe change then the OnDeinit function call and pass the reason = 3 to function Destroy(reason) .So the function Destroy set the m_deinit_reason variable with value 3 and the next time to change the timeframe again the check
if(m_deinit_reason!=WRONG_VALUE)return;
doesn't allow to destroy the CAppDialog because already have.So i make comment the section that check m_deinit_reason variable and the problem solved.
I don't like that kind of solution because it change the build in code. Another possible solution is to explicit change the m_deinit_reason value after deinit occur. In Order to reset the m_deinit_reason private variable you need to call the constructor of the class CAppDialog . But the constructor call only when the object created. Since we need the CAppDialog's classes to be used inside to others functions like " void OnDeinit, void OnChartEvent etc " i have to create the object on global scope. So the constructor call once and not every time that timeframe change.
Another question is why in MQL5 it works properly.... Looking at the ml5 code and i haven't notice any big change to the code...
So i hope that maybe you guys see that change or find a solution.
Thanks !
Hi!
The following code is an example of metaquotes.
If this code implemented to MQL5 and change the timeframe it is working fine like the picture below :
but if this code implemented to MQL4 and change the timeframe it doesn't work properly :
It seem to create extra objects every time i change the timeframe
Any idea to solve that problem ?
Thanks!