I am trying to create Multi Symbol EA using OOP. I have created a set of files and EATemplate to test it.
I am getting invalid pointer error in the mfCStrategyA (child of mfCStrategyBase). To my understanding child class should be able to access variables/methods of parent class, which I am not able to. Please help me debug where is the error in my code.
All required files are attached as Zip.
#include "mfCStrategyBase.mqh"//+-----------------------------------------------------------------------------------------------------------------------------+//| CLASS: mfCStrategyA//+-----------------------------------------------------------------------------------------------------------------------------+class mfCStrategyA : public mfCStrategyBase {
public:
mfCStrategyA(SParamSymbol &pParamSymbol);
~mfCStrategyA();
voidOnTick();
private:
int mMagicBO;
private:
void RefreshBufferM15();
}; // END of Class declaration//+-----------------------------------------------------------------------------------------------------------------------------+//| METHOD: mfCStrategyA()//| APPLICATION: PARAMETRIC CONSTRUCTOR METHOD//+-----------------------------------------------------------------------------------------------------------------------------+
mfCStrategyA::mfCStrategyA(SParamSymbol &pParamSymbol)
: mfCStrategyBase(pParamSymbol) {
mMagicBO = 111;
} // End of CONSTRUCTOR Method mfCStrategyA()//+-----------------------------------------------------------------------------------------------------------------------------+//| METHOD: ~mfCStrategyA()//| APPLICATION: DECONSTRUCTOR METHOD//+-----------------------------------------------------------------------------------------------------------------------------+
mfCStrategyA::~mfCStrategyA() {
} // End of DECONSTRUCTOR Method ~mfCStrategyA()//+-----------------------------------------------------------------------------------------------------------------------------+//| METHOD: OnTick()//| APPLICATION: TRADE OPERATIONS OF THE STRATEGY//+-----------------------------------------------------------------------------------------------------------------------------+void mfCStrategyA::OnTick(void) {
if(cNewBar.M15()) {
RefreshBufferM15();
}
} // End of method OnTick()//+-----------------------------------------------------------------------------------------------------------------------------+//| METHOD: RefreshBufferM15()//+-----------------------------------------------------------------------------------------------------------------------------+void mfCStrategyA::RefreshBufferM15(void) {
string vMethod = "[" + mSymbol + "] " + __FUNCTION__;
PrintFormat("%s: ATR D01[%g] H01[%g] M15[%g] M05[%g] M01[%g]",vMethod,cATRD01.getATR(1),cATRH01.getATR(1),cATRM15.getATR(1),cATRM05.getATR(1),cATRM01.getATR(1));
} // END Of RefreshBufferM15()//+-----------------------------------------------------------------------------------------------------------------------------+
2024.07.12 17:56:02.533 mfEATemplate (XAUUSD,M15) MultiSymbol EA will process [2] Symbols, namely:
2024.07.12 17:56:02.534 mfEATemplate (XAUUSD,M15) "XAUUSD" "ETHUSD"
2024.07.12 17:56:02.746 mfEATemplate (XAUUSD,M15) [XAUUSD,2024.07.12 15:26] mfCStrategyBase::OnTick: ATR D01[31.49] H01[4.67] M15[2.25] M05[1.45] M01[1.05]
2024.07.12 17:56:02.746 mfEATemplate (XAUUSD,M15) invalid pointer access in 'mfCStrategyA.mqh' (54,145)
I will be grateful if can be assisted on the following too:
1) Can I set indicator parameters of mfCStrategyBase() from the EATemplate, i.e. by passing the CExpertBase() and avoid the duplication of setting the parameters?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Dear All
I am trying to create Multi Symbol EA using OOP. I have created a set of files and EATemplate to test it.
I am getting invalid pointer error in the mfCStrategyA (child of mfCStrategyBase). To my understanding child class should be able to access variables/methods of parent class, which I am not able to. Please help me debug where is the error in my code.
All required files are attached as Zip.
I will be grateful if can be assisted on the following too:
1) Can I set indicator parameters of mfCStrategyBase() from the EATemplate, i.e. by passing the CExpertBase() and avoid the duplication of setting the parameters?
Thanks in advance and wish all Happy Weekend.
regards.