Please let me know if any additional information is required.
Thanks in advance!
Context:
I`ve built an EA on which I`m using EMA and MACD indicators inside the Expert Signal class. I`ve inherited the standard Expert Signal class and created my own. I`m using indicator classes CiMA and CiMyMACD (my custom implementation of CiMACD).
Issue:
Due to huge gaps between last day closing and current day opening prices, the indicators are not behaving as expected on the first N bars (screenshot attached).
Question:
How to begin indicators calculation from the first bar of the day, instead of the first bar on history?
Expected behaviour:
Considering an EMA on the closing prices, this would mean to set the value of EMA on the first bar as the closing price of this bar and then calculating further values (from second bar on) using standard EMA calculation
Considering MACD, the idea would be to have the same behaviour described above for the 3 used EMAs: fast, slow and signal
Code:
Indicator objects declaration:
class CMyExpertSignal : public CExpertSignal
{
protected:
CiMA m_iMA;
CiMyMACD m_iMyMACD;
.
.
.
Indicators init:
bool CMyExpertSignal::InitIndicators(CIndicators *indicators)
{
//--- check of pointer is performed in the method of the parent class//---//--- initialization of indicators and timeseries of additional filtersif(!CExpertSignal::InitIndicators(indicators))
return(false);
//--- create and initialize MAif(!InitMA(indicators))
return(false);
//--- create and initialize MACDif(!InitMACD(indicators))
return(false);
//--- okreturn(true);
}
MA init (I`m using a 26 days period and applying EMA to closing prices):
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 MQL5 Experts, good afternoon!
Kindly ask for your help on this.
Please let me know if any additional information is required.
Thanks in advance!
Context:
I`ve built an EA on which I`m using EMA and MACD indicators inside the Expert Signal class. I`ve inherited the standard Expert Signal class and created my own. I`m using indicator classes CiMA and CiMyMACD (my custom implementation of CiMACD).
Issue:
Due to huge gaps between last day closing and current day opening prices, the indicators are not behaving as expected on the first N bars (screenshot attached).
Question:
How to begin indicators calculation from the first bar of the day, instead of the first bar on history?
Expected behaviour:
Code:
Indicator objects declaration:
Indicators init:
MA init (I`m using a 26 days period and applying EMA to closing prices):
MACD init (I`m using classical MACD period values 26 /12 /9 and applying it to the close prices):
Methods used for retrieving data from indicators: