Discussion of article "Simple Trading Systems Using Semaphore Indicators"

 

New article Simple Trading Systems Using Semaphore Indicators is published:

If we thoroughly examine any complex trading system, we will see that it is based on a set of simple trading signals. Therefore, there is no need for novice developers to start writing complex algorithms immediately. This article provides an example of a trading system that uses semaphore indicators to perform deals.

Fig.4. Trading signal for performing a deal using Heiken Ashi Smoothed semaphore trend indicator


Author: Nikolay Kositsin

 
The article is very clear.
A small remark along the way - there is a mechanical typo in the code fragment given in the example, which was copy-pasted:
//---- Declaring local variables
   double TrendVelue[2];
 

I compiled some Signals and restart, like "Candles_SmoothedSignal.mqh" (..MQL5\Include\Expert\MySignals\Candles_SmoothedSignal.mqh), but MetaEditor can not see it to make an Expert Advisor in the Wizard.

How can I solved it?

 

Thanks for this most excellent and thorough explanation ...!


daveM

 

I downloaded and unpacked everything as indicated in the instructions, but the tester gives an error on all systems:

tester stopped because OnInit failed

CExpert::ValidationSettings: error money parameters

CMoneyFixedLot::ValidationSettings: lots amount must be in the range from 1.000000 to 1000000.000000

Please tell me what to tweak.

 

Hello!

I am trying to add the ASCtrendSignal trading signal module (located in the compressed file mysignals.zip) created on the basis of the ASCtrend indicator (located in the compressed file indicators.zip) to the MQL5 Wizard, but nothing works. I place the ASCtrendSignal trading signal module in Include\Expert\Signal, and place the ASCtrend indicator in the Indicators package, everything seems to be correct, but the module persistently does not want to be displayed in the MQL5 Wizard. Here is the code of the ASCtrendSignal trading signal module:

//+------------------------------------------------------------------+
//|ASCtrendSignal.mqh |
//|Copyright © 2011, Nikolay Kositsin | 
//|Khabarovsk, farria@mail.redcom.ru | 
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Nikolay Kositsin."
#property link      "farria@mail.redcom.ru"
//+------------------------------------------------------------------+
//| Included files|
//+------------------------------------------------------------------+
#property tester_indicator "ASCtrend.ex5"
#include <Expert\ExpertSignal.mqh>
//--- wizard description start
//+------------------------------------------------------------------+ 
//| Declaration of constants|
//+------------------------------------------------------------------+ 
#define  OPEN_LONG     80  // The constant for returning the buy command to the Expert Advisor
#define  OPEN_SHORT    80  // The constant for returning the sell command to the Expert Advisor
#define  CLOSE_LONG    40  // The constant for returning the command to close a long position to the Expert Advisor
#define  CLOSE_SHORT   40  // The constant for returning the command to close a short position to the Expert Advisor
#define  REVERSE_LONG  100 // The constant for returning the command to reverse a long position to the Expert Advisor
#define  REVERSE_SHORT 100 // The constant for returning the command to reverse a short position to the Expert Advisor
#define  NO_SIGNAL      0  // The constant for returning the absence of a signal to the Expert Advisor
//+----------------------------------------------------------------------+
//| Description of the class|
//| Title=The signals based on ASCtrend indicator |
//| Type=SignalAdvanced.|
//| Name=ASCtrend|
//| Class=CASCtrendSignal|
//| Page=|
//| Parameter=BuyPosOpen,bool,true,Permission to buy |
//| Parameter=SellPosOpen,bool,true,Permission to sell |
//| Parameter=BuyPosClose,bool,true,Permission to exit a long position |
//| Parameter=SellPosClose,bool,true,Permission to exit a short position |
//| Parameter=Ind_Timeframe,ENUM_TIMEFRAMES,PERIOD_H4,Timeframe |
//| Parameter=RISK,int,4,Risk level|
//| Parameter=SignalBar,uint,1,Bar index for entry signal |
//+----------------------------------------------------------------------+
//--- wizard description end
//+----------------------------------------------------------------------+
//| CASCtrendSignal class.|
//| Purpose: Class of generator of trade signals based on |
//| ASCtrend indicator values http://www.mql5.com/ru/code/491/.&nbsp;         |
//| Is derived from the CExpertSignal class. ||
//+----------------------------------------------------------------------+
class CASCtrendSignal : public CExpertSignal
  {
protected:
   CiCustom          m_indicator;      // the object for access to ASCtrend values

   //--- adjusted parameters
   bool              m_BuyPosOpen;       // permission to buy
   bool              m_SellPosOpen;      // permission to sell
   bool              m_BuyPosClose;      // permission to exit a long position
   bool              m_SellPosClose;     // permission to exit a short position
   ENUM_TIMEFRAMES   m_Ind_Timeframe;    // ASCtrend indicator timeframe
   uint              m_RISK;             // Risk level
   uint              m_SignalBar;        // bar index for entry signal

public:
                     CASCtrendSignal();

   //--- methods of setting adjustable parameters
   void               BuyPosOpen(bool value)                  { m_BuyPosOpen=value;       }
   void               SellPosOpen(bool value)                 { m_SellPosOpen=value;      }
   void               BuyPosClose(bool value)                 { m_BuyPosClose=value;      }
   void               SellPosClose(bool value)                { m_SellPosClose=value;     }
   void               Ind_Timeframe(ENUM_TIMEFRAMES value)    { m_Ind_Timeframe=value;    }
   void               RISK(uint value)                        { m_RISK=value;             }
   void               SignalBar(uint value)                   { m_SignalBar=value;        }

   //--- adjustable parameters validation method
   virtual bool      ValidationSettings();
   //--- adjustable parameters validation method
   virtual bool      InitIndicators(CIndicators *indicators); // indicators initialisation
   //--- market entry signals generation method
   virtual int       LongCondition();
   virtual int       ShortCondition();

   bool              InitASCtrend(CIndicators *indicators);   // ASCtrend indicator initializing method

protected:

  };
//+------------------------------------------------------------------+
//|CASCtrendSignal constructor.|
//| INPUT: no.|
//| OUTPUT: no.|
//|| REMARK: no.|
//+------------------------------------------------------------------+
void CASCtrendSignal::CASCtrendSignal()
  {
//--- setting default parameters
   m_BuyPosOpen=true;
   m_SellPosOpen=true;
   m_BuyPosClose=true;
   m_SellPosClose=true;
   
//--- indicator input parameters
   m_Ind_Timeframe=PERIOD_H4;
   m_RISK=4;
//--- 
   m_SignalBar=1;
   m_used_series=USE_SERIES_OPEN+USE_SERIES_HIGH+USE_SERIES_LOW+USE_SERIES_CLOSE;
  }
//+------------------------------------------------------------------+
//| Checking adjustable parameters.|
//| INPUT: no.|
//| OUTPUT: true if the settings are valid, false - if not. ||
//|| REMARK: no.|
//+------------------------------------------------------------------+
bool CASCtrendSignal::ValidationSettings()
  {
//--- checking parameters
   if(m_RISK<=0)
     {
      printf(__FUNCTION__+": Risk level must be above zero");
      return(false);
     }

//--- successful completion
   return(true);
  }
//+------------------------------------------------------------------+
//| Initialisation of indicators and time series. ||
//| INPUT: indicators - pointer to an object-collection |
//| of indicators and time series.|
//| OUTPUT: true - in case of successful, otherwise - false. || OUTPUT: true - in case of successful, otherwise - false. ||
//|| REMARK: no.|
//+------------------------------------------------------------------+
bool CASCtrendSignal::InitIndicators(CIndicators *indicators)
  {
//--- check of pointer
   if(indicators==NULL) return(false);

//--- indicator initialisation 
   if(!InitASCtrend(indicators)) return(false);

//--- successful completion
   return(true);
  }
//+------------------------------------------------------------------+
//| ASCtrend indicator initialisation.|
//| INPUT: indicators - pointer to an object-collection |
//| of indicators and time series.|
//| OUTPUT: true - in case of successful, otherwise - false. || OUTPUT: true - in case of successful, otherwise - false. ||
//|| REMARK: no.|
//+------------------------------------------------------------------+
bool CASCtrendSignal::InitASCtrend(CIndicators *indicators)
  {
//--- check of pointer
   if(indicators==NULL) return(false);

//--- adding an object to the collection
   if(!indicators.Add(GetPointer(m_indicator)))
     {
      printf(__FUNCTION__+": error of adding the object");
      return(false);
     }

//--- setting the indicator parameters
   MqlParam parameters[2];
   
   parameters[0].type=TYPE_STRING;
   parameters[0].string_value="ASCtrend.ex5";
   
   parameters[1].type=TYPE_INT;
   parameters[1].integer_value=m_RISK;

//--- object initialisation 
   if(!m_indicator.Create(m_symbol.Name(),m_Ind_Timeframe,IND_CUSTOM,2,parameters))
     {
      printf(__FUNCTION__+": object initialization error");
      return(false);
     }
     
//--- number of buffers
   if(!m_indicator.NumBuffers(2)) return(false);
   
//--- ASCtrend indicator initialized successfully
   return(true);
  }
//+------------------------------------------------------------------+
//| Checking conditions for opening a long position and |
//| and closing a short one|
//| INPUT:no|
//| OUTPUT: Vote weight from 0 to 100|
//|| REMARK: no.|
//+------------------------------------------------------------------+
int CASCtrendSignal::LongCondition()
  {
//--- buy signal is determined by buffer 1 of the ASCtrend indicator
   double Signal=m_indicator.GetData(1,m_SignalBar);

//--- getting a trading signal 
   if(Signal && Signal!=EMPTY_VALUE)
     {
      if(m_BuyPosOpen)
        {
         if(m_SellPosClose) return(REVERSE_SHORT);
         else return(OPEN_LONG);
        }
      else
        {
         if(m_SellPosClose) return(CLOSE_SHORT);
        }
     }

//--- searching for signals for closing a short position
   if(!m_SellPosClose) return(NO_SIGNAL);

   int Bars_=Bars(m_symbol.Name(),m_Ind_Timeframe);

   for(int bar=int(m_SignalBar); bar<Bars_; bar++)
     {
      Signal=m_indicator.GetData(0,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(NO_SIGNAL);

      Signal=m_indicator.GetData(1,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(CLOSE_SHORT);
     }

//--- no trading signal
   return(NO_SIGNAL);
  }
//+------------------------------------------------------------------+
//| Checking conditions for opening a short position and |
//| closing a long one|
//| INPUT:no|
//| OUTPUT: Vote weight from 0 to 100|
//|| REMARK: no.|
//+------------------------------------------------------------------+
int CASCtrendSignal::ShortCondition()
  {
//--- sell signal is determined by buffer 0 of the ASCtrend indicator
   double Signal=m_indicator.GetData(0,m_SignalBar);
   
//--- getting a trading signal
   if(Signal && Signal!=EMPTY_VALUE)
     {
      if(m_SellPosOpen)
        {
         if(m_BuyPosClose) return(REVERSE_LONG);
         else return(OPEN_SHORT);
        }
      else
        {
         if(m_BuyPosClose) return(CLOSE_LONG);
        }
     }

//--- searching for signals for closing a long position
   if(!m_BuyPosClose) return(NO_SIGNAL);

   int Bars_=Bars(m_symbol.Name(),m_Ind_Timeframe); // Здесь код исправлен с учетом подсказки от Владимира Карпутова: Symbol() заменен на m_symbol.Name()
   for(int bar=int(m_SignalBar); bar<Bars_; bar++)
     {
      Signal=m_indicator.GetData(1,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(NO_SIGNAL);

      Signal=m_indicator.GetData(0,bar);
      if(Signal && Signal!=EMPTY_VALUE) return(CLOSE_LONG);
     }

//--- no trading signal 
   return(NO_SIGNAL);
  }
//+------------------------------------------------------------------+

Can you please tell me what the problem may be?

Regards, Vladimir

 
MrBrooklin:

Hello!

I am trying to add the ASCtrendSignal trading signal module (located in the compressed file mysignals.zip) created on the basis of the ASCtrend indicator (located in the compressed file indicators.zip) to the MQL5 Wizard, but nothing works. I place the ASCtrendSignal trading signal module in Include\Expert\Signal, and place the ASCtrend indicator in the Indicators package, everything seems to be correct, but the module persistently does not want to be displayed in the MQL5 Wizard. Here is the code of the ASCtrendSignal trading signal module:

Can you please tell me what the problem might be?

Regards, Vladimir

I would like to add that this same problem occurs with other modules of trading signals written on the basis of indicators. Apparently, they have the same problem. Please help in solving these problems.

Regards, Vladimir.

P.S. Some indicators that I unpacked from the compressed file indicators.zip are installed on the terminal and work normally.

 

It's the order that counts:

// wizard description start
//+----------------------------------------------------------------------+
//| Description of the class|
//| Title=The signals based on ASCtrend indicator |
//| Type=SignalAdvanced.|
//| Name=ASCtrend|
//| Class=CASCtrendSignal|
//| Page=|
//| Parameter=BuyPosOpen,bool,true,Permission to buy |
//| Parameter=SellPosOpen,bool,true,Permission to sell |
//| Parameter=BuyPosClose,bool,true,Permission to exit a long position |
//| Parameter=SellPosClose,bool,true,Permission to exit a short position |
//| Parameter=Ind_Timeframe,ENUM_TIMEFRAMES,PERIOD_H4,Timeframe |
//| Parameter=RISK,int,4,Risk level|
//| Parameter=SignalBar,uint,1,Bar index for entry signal |
//+----------------------------------------------------------------------+
// wizard description end

not

//--- wizard description start
//--- wizard description end

and between start and end only a service block - no variables or macro substitutions.


This is how the module should start:

//+------------------------------------------------------------------+
//|ASCtrendSignal.mqh |
//|Copyright © 2011, Nikolay Kositsin |
//|Khabarovsk, farria@mail.redcom.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Nikolay Kositsin."
#property link      "farria@mail.redcom.ru"
//+------------------------------------------------------------------+
//| Included files|
//+------------------------------------------------------------------+
//#property tester_indicator "ASCtrend.ex5"
#include <Expert\ExpertSignal.mqh>
// wizard description start
//+----------------------------------------------------------------------+
//| Description of the class|
//| Title=The signals based on ASCtrend indicator |
//| Type=SignalAdvanced.|
//| Name=ASCtrend|
//| Class=CASCtrendSignal|
//| Page=|
//| Parameter=BuyPosOpen,bool,true,Permission to buy |
//| Parameter=SellPosOpen,bool,true,Permission to sell |
//| Parameter=BuyPosClose,bool,true,Permission to exit a long position |
//| Parameter=SellPosClose,bool,true,Permission to exit a short position |
//| Parameter=Ind_Timeframe,ENUM_TIMEFRAMES,PERIOD_H4,Timeframe |
//| Parameter=RISK,int,4,Risk level|
//| Parameter=SignalBar,uint,1,Bar index for entry signal |
//+----------------------------------------------------------------------+
// wizard description end
//+------------------------------------------------------------------+
//| Declaration of constants|
//+------------------------------------------------------------------+
#define  OPEN_LONG     80  // The constant for returning the buy command to the Expert Advisor
#define  OPEN_SHORT    80  // The constant for returning the sell command to the Expert Advisor
#define  CLOSE_LONG    40  // The constant for returning the command to close a long position to the Expert Advisor
#define  CLOSE_SHORT   40  // The constant for returning the command to close a short position to the Expert Advisor
#define  REVERSE_LONG  100 // The constant for returning the command to reverse a long position to the Expert Advisor
#define  REVERSE_SHORT 100 // The constant for returning the command to reverse a short position to the Expert Advisor
#define  NO_SIGNAL      0  // The constant for returning the absence of a signal to the Expert Advisor
//+----------------------------------------------------------------------+
//| CASCtrendSignal class.|
//| Purpose: Class of generator of trade signals based on |
//| ASCtrend indicator values http://www.mql5.com/ru/code/491/.&nbsp;         |
//| Is derived from the CExpertSignal class. ||
//+----------------------------------------------------------------------+
class CASCtrendSignal : public CExpertSignal
  {

reload MetaEditor after making edits

 
Vladimir Karputov:

It's the order that counts:

not

and between start and end only a service block - no variables or macro substitutions.


This is how a module should start:

reload MetaEditor after making edits

Thank you, Vladimir!

Everything worked.

Regards, Vladimir.

 

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "Simple trading systems using semaphore indicators"

Vladimir Karputov , 2019.10.30 08:50

The order is important:

 // wizard description start
//+----------------------------------------------------------------------+
//| Description of the class                                             |
//| Title=The signals based on ASCtrend indicator                        |
//| Type=SignalAdvanced                                                  |
//| Name=ASCtrend                                                        |
//| Class=CASCtrendSignal                                                |
//| Page=                                                                |
//| Parameter=BuyPosOpen,bool,true,Permission to buy                     |
//| Parameter=SellPosOpen,bool,true,Permission to sell                   |
//| Parameter=BuyPosClose,bool,true,Permission to exit a long position   |
//| Parameter=SellPosClose,bool,true,Permission to exit a short position |
//| Parameter=Ind_Timeframe,ENUM_TIMEFRAMES,PERIOD_H4,Timeframe          |
//| Parameter=RISK,int,4,Risk level                                      |
//| Parameter=SignalBar,uint,1,Bar index for entry signal                |
//+----------------------------------------------------------------------+
// wizard description end 

but not

 //--- wizard description start
//--- wizard description end 

and between start and end only the service block - no variables and macro substitutions.


This is the beginning the module should have:

 //+------------------------------------------------------------------+
//|                                               ASCtrendSignal.mqh |
//|                             Copyright © 2011,   Nikolay Kositsin |
//|                              Khabarovsk,   farria@mail.redcom.ru |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2011, Nikolay Kositsin"
#property  link        "farria@mail.redcom.ru"
//+------------------------------------------------------------------+
//| Included files                                                   |
//+------------------------------------------------------------------+
//#property tester_indicator "ASCtrend.ex5"
#include  <Expert\ExpertSignal.mqh>
// wizard description start
//+----------------------------------------------------------------------+
//| Description of the class                                             |
//| Title=The signals based on ASCtrend indicator                        |
//| Type=SignalAdvanced                                                  |
//| Name=ASCtrend                                                        |
//| Class=CASCtrendSignal                                                |
//| Page=                                                                |
//| Parameter=BuyPosOpen,bool,true,Permission to buy                     |
//| Parameter=SellPosOpen,bool,true,Permission to sell                   |
//| Parameter=BuyPosClose,bool,true,Permission to exit a long position   |
//| Parameter=SellPosClose,bool,true,Permission to exit a short position |
//| Parameter=Ind_Timeframe,ENUM_TIMEFRAMES,PERIOD_H4,Timeframe          |
//| Parameter=RISK,int,4,Risk level                                      |
//| Parameter=SignalBar,uint,1,Bar index for entry signal                |
//+----------------------------------------------------------------------+
// wizard description end
//+------------------------------------------------------------------+
//|  Declaration of constants                                        |
//+------------------------------------------------------------------+
#define  OPEN_LONG     80    // The constant for returning the buy command to the Expert Advisor
#define  OPEN_SHORT     80    // The constant for returning the sell command to the Expert Advisor
#define  CLOSE_LONG     40    // The constant for returning the command to close a long position to the Expert Advisor
#define  CLOSE_SHORT   40    // The constant for returning the command to close a short position to the Expert Advisor
#define  REVERSE_LONG   100 // The constant for returning the command to reverse a long position to the Expert Advisor
#define  REVERSE_SHORT 100 // The constant for returning the command to reverse a short position to the Expert Advisor
#define  NO_SIGNAL       0    // The constant for returning the absence of a signal to the Expert Advisor
//+----------------------------------------------------------------------+
//| CASCtrendSignal class.                                               |
//| Purpose: Class of generator of trade signals based on                |
//| ASCtrend indicator values http://www.mql5.com/ru/code/491/.&nbsp;         |
//| Is derived from the CExpertSignal class.                             |
//+----------------------------------------------------------------------+
class CASCtrendSignal : public CExpertSignal
  {

restart the MetaEditor after making changes