Download MetaTrader 5
To add comments, please log in or register
Having questions? Ask them on the Forum - traders will help you!
kenykau
45
kenykau 2014.11.26 03:46 

Hi all,

I found that MT4(Build 745) is compulsory requiring enum type variable to have a default value, which is very confused.

Below is my code segment.

enum LineType
{
   UP_TRENDLINE,
   DN_TRENDLINE
};
class FractalLine
{
   private:
      datetime    left, right;
      double      currentValue;
      string      name;
      LineType    type;
   protected:
      virtual void   DrawLine();
   public: 
                     FractalLine();
                     ~FractalLine();
      datetime       GetLeft(){return (this.left);};
      datetime       GetRight(){return (this.right);};
      LineType       GetType(){return (this.type);};
      virtual bool   SetValues(datetime l, datetime r, LineType t);
      virtual bool   IsSameLine(FractalLine &trendline);
};
bool FractalLine::SetValues(datetime l, datetime r, LineType t)
{
   return (true);
}
FractalLine::~FractalLine(void)
{
   if(ObjectFind(this.name)>=0)
      ObjectDelete(this.name);
}

bool FractalLine::IsSameLine(FractalLine &trendline)
{
   if(this.left == trendline.GetLeft() && this.right == trendline.GetRight() && this.type == this.GetType())
      return (true);
   return(false);
}
void FractalLine::DrawLine(void){
   if(ObjectFind(this.name)>=0)
      ObjectDelete(this.name);
   int lBar = iBarShift(Symbol(), PERIOD_CURRENT, left, true);
   int rBar = iBarShift(Symbol(), PERIOD_CURRENT, right, true);
   if(this.type == UP_TRENDLINE)
      ObjectCreate(ChartID(), this.name, OBJ_TREND, 0, this.left, High[lBar], this.right, High[rBar]);
   if(this.type == DN_TRENDLINE)
      ObjectCreate(ChartID(), this.name, OBJ_TREND, 0, this.left, Low[lBar], this.right, Low[rBar]);
}

When I compile, I got the error:

't' - missing default value for parameter    FTL.mq4    27    65
't' - missing default value for parameter    FTL.mq4    30    62
note: the above errors corresponding to the bold codes

Does anyone know why?

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.11.26 03:50  
Yes. Using DOT for variable name is only for MT5. Remove all the DOTs.
kenykau
45
kenykau 2014.11.26 04:05  
deysmacro:
Yes. Using DOT for variable name is only for MT5. Remove all the DOTs.

hi deysmacro:

Thanks for your advice

The other parts of code is fine. Also, in the bold segments, I did not use the DOT to call the private member.

Even I remove all the DOTs problems still yet remove.

Ken

Halley
198
Halley 2014.11.26 06:27  
I do not receive any compile error from your snippet when compiled by 745 nor 749.
ffoorr
982
ffoorr 2014.11.26 10:32  
add a line :
input LineType TL =  UP_TRENDLINE;

this is whithin the documentation, not in the help of editor

Alain Verleyen
Moderator
28517
Alain Verleyen 2014.11.26 18:34  
deysmacro:
Yes. Using DOT for variable name is only for MT5. Remove all the DOTs.

Please don't give wrong advice. DOT can not be used in variables for MT4 AND MT5.

There is not 1 variable with a dot in this code. See documentation.

whroeder1
13592
whroeder1 2014.11.26 19:23  

kenykau:

When I compile, I got the error:

Does anyone know why?

  1. When I compiled your posted code, I get no error.
  2. This can be simplified
    datetime GetLeft(){return (this.left);};
    datetime GetRight(){return (this.right);};
    LineType GetType(){return (this.type);};
    
    datetime GetLeft(){return left;}
    datetime GetRight(){return right;}
    LineType GetType(){return type;}
    

/
To add comments, please log in or register