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 !
Which build of MT4 are you using? There were some issues when switching timeframes in the recent builds. I've not looked into it, but perhaps the wrong uninitialization reason codes are being sent?
Thank for the reply!
I use :
FxPro - Metatrader 4
Version: 4.00 Build 1065
(23 Mar 2017)
Thank for the reply!
I use :
FxPro - Metatrader 4
Version: 4.00 Build 1065
(23 Mar 2017)
I've compared the MQL5 and MQL4 Dialog.mqh files.
This could be the issue (the MQL4 version is on the right):
Good job mate!!! They miss to reset the m_deinit_reason variable on the CreateCommon function!! Thank you !
So could you somehow point them to correct that line ? I think that other developers will face similar problem.
Good job mate!!! They miss to reset the m_deinit_reason variable on the CreateCommon function!! Thank you !
So could you somehow point them to correct that line ? I think that other developers will face similar problem.
The best way to address things like this is to send a message to the Service Desk
yea this happened with me also , and it seems that there is a problem in Destroy function of CAppDialog . however i solved it this way
OnDeinit method i added additional part to manually destroy controls contained within the CAppDialog as follows
for(int i=main.ControlsTotal()-1;i>=0;i--) { main.Control(i).Destroy(reason); }
and it seems that the problem was solved . however when the minimum button is pressed the Whole Panel just disappears and i don't know why
yea this happened with me also , and it seems that there is a problem in Destroy function of CAppDialog . however i solved it this way
OnDeinit method i added additional part to manually destroy controls contained within the CAppDialog as follows
and it seems that the problem was solved . however when the minimum button is pressed the Whole Panel just disappears and i don't know why
Did you find a solution for that meanwhile?
When I press the minimum button my panel doesn't disappear but it gets a little "weird" - see pic
Did you find a solution for that meanwhile?
When I press the minimum button my panel doesn't disappear but it gets a little "weird" - see pic
This is a bug in standard library in file Dialog.mqh. Fixed in MT5 btw. Add a line to that file as follows:
//+------------------------------------------------------------------+ //| Initialize common area | //+------------------------------------------------------------------+ bool CAppDialog::CreateCommon(const long chart,const string name,const int subwin) { //--- save parameters m_chart_id =chart; m_name =name; m_subwin =subwin; m_program_name=name; m_deinit_reason=WRONG_VALUE; //--- get unique ID m_instance_id=CreateInstanceId(); //--- initialize chart object m_chart.Attach(chart); //--- determine type of program m_program_type=(ENUM_PROGRAM_TYPE)MQLInfoInteger(MQL_PROGRAM_TYPE); //--- specify object and mouse events if(!m_chart.EventObjectCreate() || !m_chart.EventObjectDelete() || !m_chart.EventMouseMove()) { Print("CAppDialog: object events specify error"); m_chart.Detach(); return(false); } //--- get subwindow offset SubwinOff(); //--- succeed return(true); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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!