If else error

 

Hi I built a test code but suprisingly it wont work 


the code is :


void OnStart ()

  {

    double test  = 0;

    

    if ( double == 1) 

      {

          Alert "yes" ;

      }

      else{

       Alert "no" ; 

        }       

    

  }


 I keep getting this error

'==' - unexpected token cl.mq4 17 17

'yes' - open parenthesis expected cl.mq4 19 17
'yes' - some operator expected cl.mq4 19 17
'no' - open parenthesis expected cl.mq4 22 14
'no' - some operator expected cl.mq4 22 14



does anyone know why this is happening?

any help is gratefully appreciated


thank you 

 
Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.

double is not a variable, test is.

 
Keith Watford:
Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.

double is not a variable, test is.

yup figured it out thanks 


void OnStart ()

  {

    double test  = 0;

    

    if ( test == 1) 

      {

          Alert ("yes") ;

      }

      else{

       Alert ("no") ; 

        }       

    

  }

 
Subhan Sadad:

yup figured it out thanks 


void OnStart ()

  {

    double test  = 0;

    

    if ( test == 1) 

      {

          Alert ("yes") ;

      }

      else{

       Alert ("no") ; 

        }       

    

  }

You need a condition of 'what to do' and 'when' for example i write a small code for you to demonstrate. This code will say 'Yes' with alerting/comment if day of week is Monday or Thursday alerting only once per change, not and endless alerting which would be annoying right... Run it visually in strategy tester to see the 'chart comment' or look in log for printout. 'Alert' function will only print in tester. Good luck and i hope this shed some light over your issue

#property copyright ""
#property link      ""
#property version   ""
#property strict
double
test=0;
int
flagA=0,
flagB=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
//Example of condition;
   if(DayOfWeek()==1||DayOfWeek()==4)//'What day' condition, monday (1) or Thursday (4)
      test=1;
   else
      test=0;
   if(test==1&&flagA==0)
     {
      flagA=1;
      flagB=0;
      Comment("yes, it's ",DayOfWeek());
      Alert("Yes, it's ",DayOfWeek());
     }
   if(test==0&&flagB==0)
     {
      flagA=0;
      flagB=1;
      Comment("no");
      Alert("no");
     }
  }
//+------------------------------------------------------------------+
 

Subhan Sadad:

Keith Watford:
Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.

double is not a variable, test is.

yup figured it out thanks 

You quote my post and yet still ignore it and post your new code without using the code button or Alt+S.