Hi all....
I'm working on an EA and it's getting an weird behavior.
I created a variable where I can change the timeframe for the chart. Everything worked OK until I added a Panel based on the CAppDialog.
- if I change the timeframe using that configuration variable, the EA Exits.
- If i change the timeframe using the toolbar buttons, it works OK
- If I change any other configuration variable, it works OK
- If I change the timeframe removing all references for the CAppDialog, it works OK
This is the code I'm using to apply such config:
----
answered in your other thread
Hey Paul, thanks for the help.
I realized I asked in English in the Portuguese forum.
I will delete that one and continue here, thanks.
So... From your answer I understand I might be forgetting to do something... The only think I do with the panel is:
CAppDialog panel;
CLabel m_statusMsg;
int initializePanel() {
if (!panel.Create(NULL, "Status Panel - " + gSymbol + ":" + IntegerToString(PeriodSeconds(TimeFrame)/60) + "(min)", 0, 0, 0, PANEL_WIDTH, PANEL_HEIGHT))
return (INIT_FAILED);
m_statusMsg.Create(NULL, "lStatusMsg", 0, 10, 100, 1, 1);
panel.Add(m_statusMsg);
panel.Run();
panel.Minimized(false);
return INIT_SUCCEEDED;
}
void OnDeinit(const int reason) {
Print("Entering OnDeinit() with reason: " + IntegerToString(reason));
m_statusMsg.Destroy(reason);
panel.Destroy(reason);
Print("Exiting OnDeinit()");
}
Do you see anything I'm not doing in the process?
Hey Paul, hope you're fine!
So, it seems it's related to a chart event handler I have in the code:
//+------------------------------------------------------------------+
//| Chart Event Handler |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) {
// I don't know why I need this but, when changing the chart to another one, when comming back
// to the original one, the panel was minimized. By doing this, the Min/Max state is preserved.
if (id == CHARTEVENT_CHART_CHANGE && lparam == 35) {return; };
panel.ChartEvent(id, lparam, dparam, sparam);
}
If I comment that out, it starts to work.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 all....
I'm working on an EA and it's getting an weird behavior.
I created a variable where I can change the timeframe for the chart. Everything worked OK until I added a Panel based on the CAppDialog.
- if I change the timeframe using that configuration variable, the EA Exits.
- If i change the timeframe using the toolbar buttons, it works OK
- If I change any other configuration variable, it works OK
- If I change the timeframe removing all references for the CAppDialog, it works OK
This is the code I'm using to apply such config:
----
if (TradeSymbol == "") gSymbol = _Symbol; else gSymbol = TradeSymbol;
ChartSetSymbolPeriod(0, gSymbol, TimeFrame);
if(!m_symbol.Name(gSymbol)) { // sets symbol name
Print(MyName, "> " + __FILE__," ",__FUNCTION__,", ERROR: CSymbolInfo.Name");
return(INIT_FAILED);
}
----
I will let below an output from the log (easy to understand) as a reference.
Any suggestions will be really appreciated. I'm on this for a while and I don't have any clue so far.
Thanks!
---
Changing the variable for a moving average period
2024.08.02 00:16:29.972 ALT_Template (WINQ24,M5) Entering OnDeinit() with reason: 5
2024.08.02 00:16:29.972 ALT_Template (WINQ24,M5) Releasing hndlMA1
2024.08.02 00:16:29.972 ALT_Template (WINQ24,M5) Releasing hndlMA2
2024.08.02 00:16:29.972 ALT_Template (WINQ24,M5) Releasing hndlMaFilter
2024.08.02 00:16:29.972 ALT_Template (WINQ24,M5) Releasing hndlBBFilter
2024.08.02 00:16:29.978 ALT_Template (WINQ24,M5) Exiting OnDeinit()
2024.08.02 00:16:29.979 ALT_Template (WINQ24,M5) Entered OnInit()
2024.08.02 00:16:29.979 ALT_Template (WINQ24,M5) ALT_Template> Ref candle != current candle. Analyzing @ opening of ref candle
2024.08.02 00:16:29.987 ALT_Template (WINQ24,M5) ALT_Template> EMA Fast :: Applying WINQ24 timeframe: PERIOD_CURRENT and period: 9
2024.08.02 00:16:29.987 ALT_Template (WINQ24,M5) ALT_Template> EMA MEdium :: Applying WINQ24 timeframe: PERIOD_CURRENT and period: 20
2024.08.02 00:16:30.203 ALT_Template (WINQ24,M5) Exiting OnInit() with INIT_SUCCEEDED
Changing the variable for the timeframe
2024.08.02 00:16:51.657 ALT_Template (WINQ24,M5) Entering OnDeinit() with reason: 5
2024.08.02 00:16:51.657 ALT_Template (WINQ24,M5) Releasing hndlMA1
2024.08.02 00:16:51.657 ALT_Template (WINQ24,M5) Releasing hndlMA2
2024.08.02 00:16:51.657 ALT_Template (WINQ24,M5) Releasing hndlMaFilter
2024.08.02 00:16:51.657 ALT_Template (WINQ24,M5) Releasing hndlBBFilter
2024.08.02 00:16:51.661 ALT_Template (WINQ24,M5) Exiting OnDeinit()
2024.08.02 00:16:51.662 ALT_Template (WINQ24,M5) Entered OnInit()
2024.08.02 00:16:51.662 ALT_Template (WINQ24,M5) ALT_Template> Ref candle != current candle. Analyzing @ opening of ref candle
2024.08.02 00:16:51.947 ALT_Template (WINQ24,M5) ALT_Template> EMA Fast :: Applying WINQ24 timeframe: PERIOD_M15 and period: 9
2024.08.02 00:16:51.963 ALT_Template (WINQ24,M5) ALT_Template> EMA MEdium :: Applying WINQ24 timeframe: PERIOD_M15 and period: 20
2024.08.02 00:16:51.982 ALT_Template (WINQ24,M5) Exiting OnInit() with INIT_SUCCEEDED
2024.08.02 00:16:51.982 ALT_Template (WINQ24,M5) Entering OnDeinit() with reason: 3
2024.08.02 00:16:51.982 ALT_Template (WINQ24,M5) Releasing hndlMA1
2024.08.02 00:16:51.982 ALT_Template (WINQ24,M5) Releasing hndlMA2
2024.08.02 00:16:51.982 ALT_Template (WINQ24,M5) Releasing hndlMaFilter
2024.08.02 00:16:51.982 ALT_Template (WINQ24,M5) Releasing hndlBBFilter
2024.08.02 00:16:52.131 ALT_Template (WINQ24,M5) Exiting OnDeinit()