Can someone help me with this MA expert code?

 
I've been trying to code an expert that buys when the faster MA crosses above the slower MA and sells when it crosses below. The expert enters trades correctly but it won't close a trade and start a new one when the MA's cross. Can someone tell me what I'm doing wrong?
int start()
  {
  double MA5C,MA20C,MA5P,MA20P,slip,lot;
  int total,ticket,cnt;
  
  MA5C=iMA(NULL,0,3,-4,MODE_SMMA,PRICE_CLOSE,0);
  MA20C=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0);
   
  total=OrdersTotal();
  slip=0.00;
  lot=AccountBalance()/1000;
  
  if(total<1)
      {
      if((MA5C<MA20C)
         {
         ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,10,0,0,0,0,0,Yellow);
         if(ticket<0)
            {
            Print("OrderSend failed with error #",GetLastError());
            return(0);
            }       
         }
      if(MA5C>MA20C)
         {
         ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,10,0,0,0,0,0,Yellow);
         if(ticket<0)
            {
            Print("OrderSend failed with error #",GetLastError());
            return(0);
            }       
         }
      }
  for(cnt=0;cnt<total;cnt++)
      {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_SELL)
         {
        if(MA5C>MA20C) 
            {
            OrderClose(OrderTicket(),OrderLots(),Ask,10,Green); 
            return(0); 
            }
         }
     if(OrderType()==OP_BUY)
         {
        if(MA5C<MA20C) 
            {
            OrderClose(OrderTicket(),OrderLots(),Bid,10,Green); 
            return(0); 
            }
         }
       }
    }


The compiling also says that I have an " 'end_of_program/'-unbalanced left paranthesis" error on the very last line but I can't figure out how to fix it. Any help would be greatly appreciated.

 
Your unbalanced left parenthesis is in your first "if"

if((MA5C<MA20C)



I think the problem with not closing your orders is that if there is only one order, your FOR loop is only executing with cnt=0 and never executes with cnt=1 because you are only iterating while cnt is less than total:

for(cnt=0;cnt<total;cnt++)



If you do it while cnt is less than or equal to total like this:

for(cnt=0;cnt<=total;cnt++)


then it will also execute where cnt=1.

Hope this helps.