Trading Strategy Tester: sometimes indicators are not displayed.

 

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.

#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 parameters
   ENUM_TIMEFRAMES               m_period;         // Custom Time Frame (Period)

public:
   //--- Constructor of class
                     XxxxxHeikenAshi();
   //--- Destructor of class
                    ~XxxxxHeikenAshi();

   //--- Methods for placing
   void              Period(const ENUM_TIMEFRAMES value)    { m_period=value; }  // Overwrite ExpertBase Period method

   //--- Checking correctness of input data
   bool              ValidationSettings(void);

   //--- Creating indicators and timeseries for the module of signals
   bool              InitIndicators(CIndicators *indicators);

   //--- Access to indicator data
   int               HA_indicator(const int index)        const { return(m_ha.Handle()); }

   //--- Checking Buy and Sell conditions
   virtual int       LongCondition();
   virtual int       ShortCondition();

protected:
   //--- Creating OS indicator
   bool              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 method
   if(!CExpertSignal::ValidationSettings())  return(false);
   
   //--- All checks are completed, everything is ok
   return true;
}

//+------------------------------------------------------------------+
//| 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 NULL
   if(indicators==NULL)                             return(false);

   //--- Initializing indicators and timeseries in additional filters
   if(!CExpertSignal::InitIndicators(indicators))   return(false);

   //--- Create Heiken Ashi indicator
   if(!CreateHA(indicators))  return(false);

   return(true);
}

//+------------------------------------------------------------------+
//| Creates the Heiken Ashi indicator                                |
//+------------------------------------------------------------------+
bool XxxxxHeikenAshi::CreateHA(CIndicators *indicators)
{
   //--- Checking the pointer
   if(indicators==NULL) return(false);

   //--- Adding an object to the collection
   if(!indicators.Add(GetPointer(m_ha)))
   {
      printf(__FUNCTION__+": Error adding an object of the HA indicator");
      return(false);
   }

   //--- Setting parameters of the SO indicator
   MqlParam parameters[1];

   //---
   parameters[0].type=TYPE_STRING;
   parameters[0].string_value="Examples\\Heiken_Ashi.ex5";

   //--- Object initialization
   if(!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 buffers
   if(!m_ha.NumBuffers(1)) return(false);
   
   //--- Reached this part, so the function was successful, return true
   return(true);
}

//+------------------------------------------------------------------+
//| Returns the strength of the buy signal                           |
//+------------------------------------------------------------------+
int XxxxxHeikenAshi::LongCondition()
{
...
}

//+------------------------------------------------------------------+
//| Returns the strength of the sell signal                          |
//+------------------------------------------------------------------+
int XxxxxHeikenAshi::ShortCondition()
{
...
}
 
Please let me know if any further information may be of use to help me solve the issue.

Thank you.
Reason: