I'm stuck with this

 
'\end_of_program' - ending bracket '}' expected C:\Program Files\Go Trader MT4\experts\workbook_nick_all the time.mq4 (83, 1)


Why?


I tested the OrderSend lines on their own, they are fine. Problem is with the OrdersSelect parts, I just can't fit them into this properly. As always help hugely appreciated!

This is the code:

int start()
  {
//----
        
      
      
      if(OrdersTotal()==0)                                              // If there are no live trades, proceed
        {
         for (int i=0; i<=OrdersTotal(); i++)                           //Creating a counter which is then used to cycle through trades history
            if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)      //Select last order in the trades history, if such is selected (true) then proceed
             {
               if (OrderClosePrice()<OrderOpenPrice())                  //If the last history order had the ordercloseprice below the orderopenprice, proceed
                  OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-StopLoss*pips,Ask+TakeProfit*pips,NULL,MagicNumber,0,Green);   //then buyorder open
               else
               OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+StopLoss*pips,Bid-TakeProfit*pips,NULL,MagicNumber,0,Red);       // if last history order didn't have the openprice<close price then sellorder open
             {
            OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+StopLoss*pips,Bid-TakeProfit*pips,NULL,MagicNumber,0,Red);              //if OrderSelect above doesn't find a last order (i.e. no history) then sellorder open 
          
        }          
  


//----
   return(0);
  }
//+------------------------------------------------------------------+
 
niko:
'\end_of_program' - ending bracket '}' expected C:\Program Files\Go Trader MT4\experts\workbook_nick_all the time.mq4 (83, 1)


Why?


I tested the OrderSend lines on their own, they are fine. Problem is with the OrdersSelect parts, I just can't fit them into this properly. As always help hugely appreciated!

This is the code:

You have 2 } and 4 { so you are missing a }

Maybe . . .

OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+StopLoss*pips,Bid-TakeProfit*pips,NULL,MagicNumber,0,Red);       // if last history order didn't have the openprice<close price then sellorder open
             {    
            OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+StopLoss*pips,Bid-TakeProfit*pips,NULL,MagicNumber,0,Red); 

should be . . .

OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+StopLoss*pips,Bid-TakeProfit*pips,NULL,MagicNumber,0,Red);       // if last history order didn't have the openprice<close price then sellorder open
             }      
            OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+StopLoss*pips,Bid-TakeProfit*pips,NULL,MagicNumber,0,Red); 
 
Also, you need to test the return values from your trading functions so you know what is wrong if they go wrong and you can then also print out the relevant variables to enable you to diagnose the issue after the event, read and implement this: What are Function return values ? How do I use them ?
 

Thank you Raptor!