Download MetaTrader 5
To add comments, please log in or register
The Market has more than 400 indicators. Try any of them!
ailanshi_7
13
ailanshi_7 2016.04.25 21:14 

I was practicing to make a simple E.A.but the following errors occurs .

"        '}' - semicolon expected                             "

"        'else' - illegal 'else' without matching 'if'       " 

Can anyone please point out my mistake in the following program  and make the correction.


#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern int period = 14;


void OnTick()
{
   bool bill;
   bill = rsi();
    if (bill == true)
   {
    OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask+20*Point,Ask-30*Point,NULL,0,0)
   }
  
    else if(bill == false)
   { 
        OrderSend(Symbol(),OP_SELL,0.1,Bid,Bid-20*Point,Ask+30*Point,Null,0,0)
   }
   else
   {
   Alert("there is something wrong");
   }
 
 
}

bool rsi()
{
double point;

point =  iRSI(Symbol(),0,period,PRICE_TYPICAL,0);
if(point>60)
return(true);
else if(point<30)
return(false);
else
return(EMPTY_VALUE);
}
Fernando Carreiro
1429
Fernando Carreiro 2016.04.25 21:45  
  • Please use the "SRC" button to submit code samples!
  • You are missing ";" terminators on the OrderSend lines.
  • You are missing the slippage parameter on your 2nd OrderSend.
  • Don't use "if (bill == true)". Just use "if(bill)" or "if(!bill)" because it is already a Boolean.
  • Boolean values only have two states, true or false. There is no third state as is implemented in your code "if(bill == true) ... else if(bill == false) ... else ..."
  • Always check the results of the "OrderSend" and other such functions.
  • There is no predefined "Null". It is case sensitive, so use "NULL".
  • There are several other mistakes, but start with these.

/
To add comments, please log in or register