I have a custom signal (inherited from CExpertSignal, based on Heiken Ashi candles) and EA based on this signal. The signal works fine, but it's not always displayed on the Strategy Tester chart... The problem is that it's displayed randomly form time to time... Any ideas?
Any help would be appreciated :)
Cheers,
Constantine.
#include <Expert\ExpertSignal.mqh>
#include <Expert\Enums.mqh>
#include <Expert\ExpertHelper.mqh>
#property tester_indicator"Examples\\Heiken_Ashi.ex5"class XxxxxHeikenAshi : public CExpertSignal
{
private:
datetime m_LastBars_s[2];
datetime m_LastBars_l[2];
CiCustom m_ha;
//--- Configurable module parametersENUM_TIMEFRAMES m_period; // Custom Time Frame (Period)public:
//--- Constructor of class
XxxxxHeikenAshi();
//--- Destructor of class
~XxxxxHeikenAshi();
//--- Methods for placingvoidPeriod(constENUM_TIMEFRAMES value) { m_period=value; } // Overwrite ExpertBase Period method//--- Checking correctness of input databool ValidationSettings(void);
//--- Creating indicators and timeseries for the module of signalsbool InitIndicators(CIndicators *indicators);
//--- Access to indicator dataint HA_indicator(constint index) const { return(m_ha.Handle()); }
//--- Checking Buy and Sell conditionsvirtualint LongCondition();
virtualint ShortCondition();
protected:
//--- Creating OS indicatorbool CreateHA(CIndicators *indicators);
};
//+------------------------------------------------------------------+//| Constructor |//+------------------------------------------------------------------+
XxxxxHeikenAshi::XxxxxHeikenAshi()
{
}
//+------------------------------------------------------------------+//| Destructor |//+------------------------------------------------------------------+
XxxxxHeikenAshi::~XxxxxHeikenAshi(void)
{
}
//+------------------------------------------------------------------+//| Checks input parameters and returns true if everything is OK |//+------------------------------------------------------------------+bool XxxxxHeikenAshi::ValidationSettings()
{
//--- Call the base class methodif(!CExpertSignal::ValidationSettings()) return(false);
//--- All checks are completed, everything is okreturntrue;
}
//+------------------------------------------------------------------+//| Creates indicators |//| Input: a pointer to a collection of indicators |//| Output: true if successful, otherwise false |//+------------------------------------------------------------------+bool XxxxxHeikenAshi::InitIndicators(CIndicators* indicators)
{
//--- Standard check of the collection of indicators for NULLif(indicators==NULL) return(false);
//--- Initializing indicators and timeseries in additional filtersif(!CExpertSignal::InitIndicators(indicators)) return(false);
//--- Create Heiken Ashi indicatorif(!CreateHA(indicators)) return(false);
return(true);
}
//+------------------------------------------------------------------+//| Creates the Heiken Ashi indicator |//+------------------------------------------------------------------+bool XxxxxHeikenAshi::CreateHA(CIndicators *indicators)
{
//--- Checking the pointerif(indicators==NULL) return(false);
//--- Adding an object to the collectionif(!indicators.Add(GetPointer(m_ha)))
{
printf(__FUNCTION__+": Error adding an object of the HA indicator");
return(false);
}
//--- Setting parameters of the SO indicatorMqlParam parameters[1];
//---
parameters[0].type=TYPE_STRING;
parameters[0].string_value="Examples\\Heiken_Ashi.ex5";
//--- Object initializationif(!m_ha.Create(m_symbol.Name(),m_period,IND_CUSTOM,1,parameters))
{
printf(__FUNCTION__+": Error initializing the object of the HA indicator");
return(false);
}
//--- Number of buffersif(!m_ha.NumBuffers(1)) return(false);
//--- Reached this part, so the function was successful, return truereturn(true);
}
//+------------------------------------------------------------------+//| Returns the strength of the buy signal |//+------------------------------------------------------------------+int XxxxxHeikenAshi::LongCondition()
{
...
}
//+------------------------------------------------------------------+//| Returns the strength of the sell signal |//+------------------------------------------------------------------+int XxxxxHeikenAshi::ShortCondition()
{
...
}
Hey everybody!
I would like to share the following pain...
I have a custom signal (inherited from CExpertSignal, based on Heiken Ashi candles) and EA based on this signal. The signal works fine, but it's not always displayed on the Strategy Tester chart... The problem is that it's displayed randomly form time to time... Any ideas?
Any help would be appreciated :)
Cheers,
Constantine.