Compile error mt4 expression not boolean ?

 

Can anyone help me ?

when I compile in mt4 strategy tester it says expression not boolean ? it used to say something like 0 errors 0 faults etc ?

It's got me, it still compiles the expert advisor ok but Its not confirming that there is no errors in the programme.


Geoff

 

Assuming you mean MetaEditor, not Strategy Tester, but you probably used a single equal sign in a place where you need two.  Use a single = when assigning values and == when evaluating something in an expression. For example:

if(OrderType()==0  <--Compiler is happy

if(OrderType()=0 <-- Expression is not boolean error

If you post the line of code it's complaining about I'm sure we can find it quickly.

 
Piptide:

Assuming you mean MetaEditor, not Strategy Tester, but you probably used a single equal sign in a place where you need two.  Use a single = when assigning values and == when evaluating something in an expression. For example:

if(OrderType()==0  <--Compiler is happy

if(OrderType()=0 <-- Expression is not boolean error

If you post the line of code it's complaining about I'm sure we can find it quickly.

Have the same problem,

here is my code:

//--- Has the candle actually formed
bool ValidCandleCheck(string symbol, ENUM_TIMEFRAMES timeframe)
{
   double low = iLow(symbol,timeframe,0);
   double high = iHigh(symbol,timeframe,0);   
   if( MathAbs( high - low ) == 0 || low == 0 || high == 0 )
   {
      return(False);
   }
   else
   {
      return(True);
   }
}
 
//--- Has the candle actually formed
bool ValidCandleCheck(string symbol, ENUM_TIMEFRAMES timeframe)
{
   double low = iLow(symbol,timeframe,0);
   double high = iHigh(symbol,timeframe,0);   
   if( MathAbs( high - low ) == 0 || low == 0 || high == 0 )
   {
      return(False);
   }
   else
   {
      return(True);
   }
   return(True);
}
or
//--- Has the candle actually formed
bool ValidCandleCheck(string symbol, ENUM_TIMEFRAMES timeframe)
{
   double low = iLow(symbol,timeframe,0);
   double high = iHigh(symbol,timeframe,0);   
   if( MathAbs( high - low ) == 0 || low == 0 || high == 0 )
   {
      return(False);
   }
   return(True);
}

or

//--- Has the candle actually formed
bool ValidCandleCheck(string symbol, ENUM_TIMEFRAMES timeframe)
{
   double low = iLow(symbol,timeframe,0);
   double high = iHigh(symbol,timeframe,0);   
   
   return(( MathAbs( high - low ) == 0 || low == 0 || high == 0 ) ? False : True);
}
 
//--- Has the candle actually formed
bool ValidCandleCheck(string symbol, ENUM_TIMEFRAMES timeframe)
{
   double low = iLow(symbol,timeframe,0);
   double high = iHigh(symbol,timeframe,0);   
   
   return !( MathAbs( high - low ) == 0 || low == 0 || high == 0 );
}
or
//--- Has the candle actually formed
bool ValidCandleCheck(string symbol, ENUM_TIMEFRAMES timeframe)
{
   double low = iLow(symbol,timeframe,0);
   double high = iHigh(symbol,timeframe,0);   
   
   return MathAbs( high - low ) != 0 && low != 0 && high != 0;
}
 
whroeder1:
or

Hi, something like this happens to me, with the new version I get a warning of "not boolean expression" in this code. Can you tell me what the right code is?


f ((UseFridayFinalTradeTime && (Hour()>=FridayFinalHourGMT + ServerTimeZone) && DayOfWeek()==5)||DayOfWeek()==0)return (False); // Friday Control

 

You used to be able to use True and False with the capitalized initial letter

now you must use

true and false - all lower case.

 

Same problem here... Only it is not supposed to be a boolean... It's just an int (that i converted to double to dodge another unresponding-for no reason error).

Keith Watford:

You used to be able to use True and False with the capitalized initial letter

now you must use

true and false - all lower case.

 
Pantelis Papaisidorou:

Same problem here... Only it is not supposed to be a boolean... It's just an int (that i converted to double to dodge another unresponding-for no reason error).

Show your code if you want help.

 
Keith Watford:

You used to be able to use True and False with the capitalized initial letter

now you must use

true and false - all lower case.

This has changed since, you can use True and False again.

 

SAME PROBLEM HERE WITH THIS CODE


//+------------------------------------------------------------------+
//|                                      KG Support & Resistance.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Kang_Gun"
#property link      "http://www.free-knowledge.com"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Yellow
#property indicator_color3 LimeGreen
#property indicator_color4 LimeGreen
#property indicator_color5 Blue
#property indicator_color6 Blue
#property indicator_color7 Red
#property indicator_color8 Red
//---- input parameters

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
int KG;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT,1,Yellow);
   SetIndexDrawBegin(0,KG-1);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"Resistance M15");
   SetIndexArrow(0, 158);
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,1,Yellow);
   SetIndexDrawBegin(1,KG-1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"Support M15");
   SetIndexArrow(1, 158);
   SetIndexStyle(2,DRAW_ARROW,STYLE_DOT,1,LimeGreen);
   SetIndexDrawBegin(2,KG-1);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexLabel(2,"Resistance H1");
   SetIndexArrow(2, 158);
   SetIndexStyle(3,DRAW_ARROW,STYLE_DOT,1,LimeGreen);
   SetIndexDrawBegin(3,KG-1);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexLabel(3,"Support H1");
   SetIndexArrow(3, 158);
   SetIndexStyle(4,DRAW_ARROW,STYLE_DOT,1,Blue);
   SetIndexDrawBegin(4,KG-1);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexLabel(4,"Resistance H4");
   SetIndexArrow(4, 158);
   SetIndexStyle(5,DRAW_ARROW,STYLE_DOT,1,Blue);
   SetIndexDrawBegin(5,KG-1);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexLabel(5,"Support H4");
   SetIndexArrow(5, 158);
   SetIndexStyle(6,DRAW_ARROW,STYLE_DOT,1,Red);
   SetIndexDrawBegin(6,KG-1);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexLabel(6,"Resistance D1");
   SetIndexArrow(6, 158);
   SetIndexStyle(7,DRAW_ARROW,STYLE_DOT,1,Red);
   SetIndexDrawBegin(7,KG-1);
   SetIndexBuffer(7,ExtMapBuffer8);
   SetIndexLabel(7,"Support D1");
   SetIndexArrow(7, 158);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//------------------------------------------------------------------  
bool Fractal (string M,int P, int shift)
  {
   if (Period()>P) return(-1);
   P=P/Period()*2+MathCeil(P/Period()/2);
   if (shift<P)return(-1);
   if (shift>Bars-P)return(-1); 
   for (int i=1;i<=P;i++)
     {
      if (M=="U")
        {
         if (High[shift+i]>High[shift])return(-1);
         if (High[shift-i]>=High[shift])return(-1);     
        }
      if (M=="L")
        {
         if (Low[shift+i]<Low[shift])return(-1);
         if (Low[shift-i]<=Low[shift])return(-1);
        }        
     }
   return(1);   
Reason: