'CPattern' - unexpected token, probably type is missing? Header.mqh

 
//+------------------------------------------------------------------+
//|                                                       Header.mqh |
//|                                             Copyright 2018, DNG® |
//|                                 http://www.mql5.com/en/users/dng |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|  Structures                                                      |
//+------------------------------------------------------------------+
   struct s_Extremum
     {
      datetime          TimeStartBar;
      double            Price;
      
      s_Extremum(void)  :  TimeStartBar(0),
                           Price(0)
         {
         }
      void Clear(void)
        {
         TimeStartBar=0;
         Price=0;
        }
     };
//+------------------------------------------------------------------+
//|  Includes                                                        |
//+------------------------------------------------------------------+
#include <Trade\LimitTakeProfit.mqh>
#include <Arrays\ArrayObj.mqh>
#include "ZigZag.mqh"
#include "Trends.mqh"
#include "Pattern.mqh"
#include <Trade\Trade.mqh>
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
sinput   string            s1             =  "---- ZigZag Settings ----";     //---
input    int               i_Depth        =  12;                              // Depth
input    int               i_Deviation    =  100;                             // Deviation
input    int               i_Backstep     =  3;                               // Backstep
input    int               i_MaxHistory   =  1000;                            // Max history, bars
input    ENUM_TIMEFRAMES   e_TimeFrame    =  PERIOD_M30;                      // Work Timeframe
sinput   string            s2             =  "---- Pattern Settings ----";    //---
input    double            d_MinCorrection=  0.118;                           // Minimal Correction
input    double            d_MaxCorrection=  0.5;                             // Maximal Correction
input    ENUM_TIMEFRAMES   e_ConfirmationTF= PERIOD_M5;                       // Timeframe for confirmation
sinput   string            s3             =  "---- Trade Settings ----";      //---
input    double            d_Lot          =  0.1;                             // Trade Lot
input    ulong             l_Slippage     =  10;                              // Slippage
input    uint              i_SL           =  350;                             // Stop Loss Backstep, points
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CArrayObj         *ar_Objects;
CTrade            *Trade;
CPattern          *Pattern;
datetime           start_search;
//+------------------------------------------------------------------+

header.mqh

//+------------------------------------------------------------------+
//|                                                      Pattern.mqh |
//|                                             Copyright 2018, DNG® |
//|                                 http://www.mql5.com/en/users/dng |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, DNG®"
#property link      "http://www.mql5.com/en/users/dng"
#property version   "1.00"
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
#include "Header.mqh"
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class CPattern : public CObject
  {
private:
   s_Extremum     s_StartTrend;        //Trend start point
   s_Extremum     s_StartCorrection;   //Correction start point
   s_Extremum     s_EndCorrection;     //Correction end point
   s_Extremum     s_EndTrend;          //Trend completion point
   double         d_MinCorrection;     //Minimum correction
   double         d_MaxCorrection;     //Maximum correction
//---
   bool           b_found;             //"Pattern detected" flag
//---
   CTrends       *C_Trends;
public:
                     CPattern();
                    ~CPattern();
//--- Class initialization
   virtual bool      Create(CTrends *trends, double min_correction, double max_correction);
//--- Methods for searching the pattern and entry points
   virtual bool      Search(datetime start_time);
   virtual bool      CheckSignal(int &signal, double &sl, double &tp1, double &tp2);
//--- Method of comparing the objects
   virtual int       Compare(const CPattern *node,const int mode=0) const;
//---
   s_Extremum        StartTrend(void)        const {  return s_StartTrend;       }
   s_Extremum        StartCorrection(void)   const {  return s_StartCorrection;  }
   s_Extremum        EndCorrection(void)     const {  return s_EndCorrection;    }
   s_Extremum        EndTrend(void)          const {  return s_EndTrend;         }
   virtual datetime  EndTrendTime(void)            {  return s_EndTrend.TimeStartBar;  }
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CPattern::CPattern() :  d_MinCorrection(0.236),
                        d_MaxCorrection(0.5),
                        b_found(false),
                        C_Trends(NULL)
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CPattern::~CPattern()
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CPattern::Create(CTrends *trends,double min_correction,double max_correction)
  {
   if(CheckPointer(trends)==POINTER_INVALID)
      return false;
//---
   C_Trends=trends;
   b_found=false;
   s_StartTrend.Clear();
   s_StartCorrection.Clear();
   s_EndCorrection.Clear();
   s_EndTrend.Clear();
   d_MinCorrection=min_correction;
   d_MaxCorrection=max_correction;
//---
   return true;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CPattern::Search(datetime start_time)
  {
   if(CheckPointer(C_Trends)==POINTER_INVALID || C_Trends.Total()<4)
      return false;
//---
   int start=C_Trends.ExtremumByTime(start_time);
   if(start<0)
      return false;
//---
   b_found=false;
   for(int i=start;i>=0;i--)
     {
      if((i+3)>=C_Trends.Total())
         continue;
      if(!C_Trends.Extremum(s_StartTrend,i+3) || !C_Trends.Extremum(s_StartCorrection,i+2) ||
         !C_Trends.Extremum(s_EndCorrection,i+1) || !C_Trends.Extremum(s_EndTrend,i))
         continue;
//---
      double trend=s_StartCorrection.Price-s_StartTrend.Price;
      double correction=s_StartCorrection.Price-s_EndCorrection.Price;
      double re_trial=s_EndTrend.Price-s_EndCorrection.Price;
      double koef=correction/trend;
      if(koef<d_MinCorrection || koef>d_MaxCorrection || (1-fmin(correction,re_trial)/fmax(correction,re_trial))>=d_MaxCorrection)
         continue;
      b_found= true; 
//---
      break;
     }
//---
   return b_found;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CPattern::CheckSignal(int &signal, double &sl, double &tp1, double &tp2)
  {
   if(!b_found)
      return false;
//---
   string symbol=C_Trends.Symbol();
   if(symbol=="Not Initilized")
      return false;
   datetime start_time=s_EndTrend.TimeStartBar+PeriodSeconds(C_Trends.Timeframe());
   int shift=iBarShift(symbol,e_ConfirmationTF,start_time);
   if(shift<0)
      return false;
   MqlRates rates[];
   int total=CopyRates(symbol,e_ConfirmationTF,0,shift+1,rates);
   if(total<=0)
      return false;
//---
   signal=0;
   sl=tp1=tp2=-1;
   bool up_trend=C_Trends.IsHigh(s_EndTrend);
   double extremum=(up_trend ? fmax(s_StartCorrection.Price,s_EndTrend.Price) : fmin(s_StartCorrection.Price,s_EndTrend.Price));
   double exit_level=2*s_EndCorrection.Price- extremum;
   bool break_neck=false;
   for(int i=0;i<total;i++)
     {
      if(up_trend)
        {
         if(rates[i].low<=exit_level || rates[i].high>extremum)
            return false;
         if(!break_neck)
           {
            if(rates[i].close>s_EndCorrection.Price)
               continue;
            break_neck=true;
            continue;
           }
         if(rates[i].high>s_EndCorrection.Price)
           {
            if(sl==-1)
               sl=rates[i].high;
            else
               sl=fmax(sl,rates[i].high);
           }
         if(rates[i].close<s_EndCorrection.Price || sl==-1)
            continue;
         if((total-i)>2)
            return false;
//---
         signal=-1;
         double top=fmax(s_StartCorrection.Price,s_EndTrend.Price);
         tp1=s_EndCorrection.Price-(top-s_EndCorrection.Price)*0.9;
         tp2=top-(top-s_StartTrend.Price)*0.9;
         tp1=fmax(tp1,tp2);
         break;
        }
      else
        {
         if(rates[i].high>=exit_level || rates[i].low<extremum)
            return false;
         if(!break_neck)
           {
            if(rates[i].close<s_EndCorrection.Price)
               continue;
            break_neck=true;
            continue;
           }
         if(rates[i].low<s_EndCorrection.Price)
           {
            if(sl==-1)
               sl=rates[i].low;
            else
               sl=fmin(sl,rates[i].low);
           }
         if(rates[i].close>s_EndCorrection.Price || sl==-1)
            continue;
         if((total-i)>2)
            return false;
//---
         signal=1;
         double down=fmin(s_StartCorrection.Price,s_EndTrend.Price);
         tp1=s_EndCorrection.Price+(s_EndCorrection.Price-down)*0.9;
         tp2=down+(s_StartTrend.Price-down)*0.9;
         tp1=fmin(tp1,tp2);
         break;
        }
     }   
//---
   return true;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CPattern::Compare(const CPattern *node,const int mode=0) const
  {
   if(s_StartTrend.TimeStartBar>node.StartTrend().TimeStartBar)
      return -1;
   else
      if(s_StartTrend.TimeStartBar<node.StartTrend().TimeStartBar)
         return 1;
//---
   if(s_StartCorrection.TimeStartBar>node.StartCorrection().TimeStartBar)
      return -1;
   else
      if(s_StartCorrection.TimeStartBar<node.StartCorrection().TimeStartBar)
         return 1;
//---
   if(s_EndCorrection.TimeStartBar>node.EndCorrection().TimeStartBar)
      return -1;
   else
      if(s_EndCorrection.TimeStartBar<node.EndCorrection().TimeStartBar)
         return 1;
//---
   return 0;
  }
//+------------------------------------------------------------------+

pattern.mqh


Im trying to resolve this error 'CPattern' - unexpected token, probably type is missing?    Header.mqh    55    1

I have tried adding it as class but not working. I request to help if possible

Thank you.

 
header include pattern, pattern includes header. Not going to work
 
Arpit T:

header.mqh

pattern.mqh


Im trying to resolve this error 'CPattern' - unexpected token, probably type is missing?    Header.mqh    55    1

I have tried adding it as class but not working. I request to help if possible

Thank you.

Probably need forward declaration.
In Pattern.mqh, place that line 

class CPattern;

before the #include 

#include "Header.mqh"
should look like:
//+------------------------------------------------------------------+
//|                                                      Pattern.mqh |
//|                                             Copyright 2018, DNG® |
//|                                 http://www.mql5.com/en/users/dng |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, DNG®"
#property link      "http://www.mql5.com/en/users/dng"
#property version   "1.00"
class CPattern;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
#include "Header.mqh"
 

Thank you. It fixed the issue

if(Pattern.Compare(ar_Objects.At(i),0)==0)

At this line its giving warning

deprecated behavior, hidden method calling will be disabled in a future MQL compiler version  

If you could advice, that would be aweomse

Thanks

Amir Yacoby:

Probably need forward declaration.
In Pattern.mqh, place that line 

before the #include 

should look like: