unbalanced parentheses issues, can anyone assist ?

 

Hi Guys, 

Could anyone help, i can't seem to correctly balance the parentheses.

Any help would be appreciated. 

thanks

Tim


int SmallSMA = 5;
int BigSMA = 15;
int BuyOrderNumber;
int SellOrderNumber;
#define MAGICSMA  202006
extern double TakeProfit = 500;
extern double Lots = 0.01;
extern double TrailingStop = 300;


int start()
  {
   string signal ="";
   double SMA = iMA(_Symbol,_Period,SmallSMA,0,MODE_SMA,PRICE_CLOSE,0);
   double BMA = iMA(_Symbol,_Period,BigSMA,0,MODE_SMA,PRICE_CLOSE,0);   
   double SMA1 = iMA(_Symbol,_Period,SmallSMA,0,MODE_SMA,PRICE_CLOSE,1);
   double BMA1 = iMA(_Symbol,_Period,BigSMA,0,MODE_SMA,PRICE_CLOSE,1);
   double SMA2 = iMA(_Symbol,_Period,SmallSMA,0,MODE_SMA,PRICE_CLOSE,2);
   double BMA2 = iMA(_Symbol,_Period,BigSMA,0,MODE_SMA,PRICE_CLOSE,2);
   int cnt, ticket ;
   int total=OrdersTotal();
  
     // check for long position (BUY) possibility      
      if (SMA > BMA && SMA1 < BMA1) 
        signal="BUY";
        {
         RefreshRates();
          if (signal=="BUY" && OrdersTotal()==0)
           {
            ticket=OrderSend(_Symbol,OP_BUY,Lots,Ask,3,0,TakeProfit,NULL,MAGICSMA,0,Green);
            if(ticket>0)
             {
              if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
              }
             }
            }
           else Print("Order failed with error - ",GetLastError());      
           return (0);
       
      // check for short position (SELL) possibility    
      if (SMA < BMA && SMA1 > BMA1) 
        signal="SELL";
        {
         RefreshRates();
          if (signal=="SELL" && OrdersTotal()==0)
           {
            ticket=OrderSend(_Symbol,OP_SELL,Lots,Bid,3,0,TakeProfit,NULL,0,MAGICSMA,Blue);
            if(ticket>0)
             {
              if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
              }
             }
            }
           else Print("Order failed with error - ",GetLastError());      
           return (0);
           
   for(cnt=0;cnt<total;cnt++)
     {
      if OrderSelect(cnt, SELECTunbalanced parentheses issues, can anyone assist ? _BY_POS, MODE_TRADES);
         {
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol())// long position is open?
           {
            if(SMA1 < BMA1 && SMA2 > BMA2) // should it be closed?
             {
              OrderClose(OrderTicket(),OrderLots(),Bid,3,White); // close position
              return(0); // exit
              }
             }
            }
           }
      else // go to short position
         {
          if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())// short position is open? 
           {
            if(SMA1 > BMA1 && SMA2 < BMA2) // should it be closed?
             {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
               return(0); // exit
               }
              }
             }
Files:
 

Paste the section of code using the code  button (Alt+S)


In future please post in the correct section

I will move your topic to the MQL4 and Metatrader 4 section.

 
Keith Watford:

Paste the section of code using the code  button (Alt+S)


In future please post in the correct section

I will move your topic to the MQL4 and Metatrader 4 section.

Thank you, Pasted above. 

 
Jonetia:

Thank you, Pasted above. 

one close } missing at the end

 
Ahmet Metin Yilmaz:

one close } missing at the end

Hi, I tried that, Unfortunately it does't work - it creates a whole host of errors, 

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

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

'if' - open parentheses expected 

'orderClose' should be checked

 
Jonetia:

Hi, I tried that, Unfortunately it does't work - it creates a whole host of errors, 

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

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

'if' - open parentheses expected 

'orderClose' should be checked

you asked unbalanced parantheses and I just take alook your codes for this issue

read the mql4 document for all other error if you wanna be a coder

or?

 
Ahmet Metin Yilmaz:

you asked unbalanced parantheses and I just take alook your codes for this issue

read the mql4 document for all other error if you wanna be a coder

or

fair comment. thanks for looking anyway. 

 
if OrderSelect(cnt, SELECTunbalanced parentheses issues, can anyone assist ? _BY_POS, MODE_TRADES);

What the hell is this??

Post your proper code, //use comments.

Where is the ( after the if?

Why are you following an if() with a semicolon?

 
Keith Watford:

What the hell is this??

Post your proper code, //use comments.

Where is the ( after the if?

Why are you following an if() with a semicolon?

Apologies, looks like a pasting issue. 

will review and correct. 

Reason: