Down from 18 errors to 5. Little help please

 
//+------------------------------------------------------------------+
//|                       Down_to_5_Errors.mq4                       |
//+------------------------------------------------------------------+
/*Thank you for the help earlier.It did prove to be helpful.
Have taken the errors down from 18 to 5 errors. 
It looks good to me, apparently the compilier does not.

'==' left parenthesis expected
')' left parenthesis expected
'else' unexpected token
'==' left parenthesis expected
')' left parenthesis expected
*/

bool Buy_1 = false;  
bool Sell_1 = false;
double ATR;
double Slippage;
double StopLoss;
double TakeProfit;
double Lots;
//--------Trade Criteria-------------

extern double Open_Level_ATR ;
extern double Close_level_ATR ;


//------------------------------------

int start()
  {
    if (OrdersTotal() == 0)
      {
        if (true == (Ask > (High[iHighest(NULL,0,MODE_HIGH,10, 1)])))
          {
            ATR = iATR(NULL,0,20,1);                                   
            int Buy = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point);                         
          }                                                     
        } 
        
//-------------------------------
              
     else
      {                                                           
        if (true == (Bid < (Low[iLowest(NULL,0,MODE_LOW,10, 1)])))
           {                                                        
             ATR = iATR(NULL,0,20,1);                                
             int Sell = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid-StopLoss*Point,Bid+TakeProfit*Point);
           }                                              
          return(0);       
        }                                                                   
                                                                       
//------------- Closing Orders -----------------

double Amount;
double total;

for(Amount=0; Amount < total; Amount++)
{                                                                  
  OrderSelect(Amount, SELECT_BY_POS, MODE_TRADES);
  if(OrderType() <= OP_SELL &&                                                    //Any open SHORT position? 
                                                  //My question to the above '<=', LESS than or EQUAL to SELL,
                                                  //where as program accepts '==', expression EQUAL to BUY??
                                                  //It seems that both block are asking for what type of 
                                                  //position and symbol, yet expressions are not the same??
                                                  //I would understand '!==' or '==', but '<=='??
     OrderSymbol()==Symbol())                                                     //What is the symbol?
       {                                              
         if (OrderType() == OP_BUY &&                                             //Any open LONG position? 
            OrderSymbol() == Symbol())                                            //What is the symbol?
               {                                   
                 if  (OrderTakeProfit == (OrderSelect(OrderOpenPrice) - (ATR*2))) //<<<<<<<<<<<<<<<
                      OrderClose(OrderTicket(),OrderLots(),Ask,3,Blue);           //Position closed
               }
            }
                                                              
      else
       {                                          
         if (OrderTakeProfit == (OrderSelect(OrderOpenPrice) + (ATR*2)))          //Should it be closed?                                                  
             OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);                     // Position closed
       }                                              
     return(0);                                                                   //Exit Algorithm
   }  
}                                                                                //Exit start()
 
Huckleberry:
//+------------------------------------------------------------------+
//|                       Down_to_5_Errors.mq4                       |
//+------------------------------------------------------------------+
/*Thank you for the help earlier.It did prove to be helpful.
Have taken the errors down from 18 to 5 errors. 
It looks good to me, apparently the compilier does not.

'==' left parenthesis expected
')' left parenthesis expected
'else' unexpected token
'==' left parenthesis expected
')' left parenthesis expected
*/

bool Buy_1 = false;  
bool Sell_1 = false;
double ATR;
double Slippage;
double StopLoss;
double TakeProfit;
double Lots;
//--------Trade Criteria-------------

extern double Open_Level_ATR ;
extern double Close_level_ATR ;


//------------------------------------

int start()
  {
    if (OrdersTotal() == 0)
      {
        if (true == (Ask > (High[iHighest(NULL,0,MODE_HIGH,10, 1)])))
          {
            ATR = iATR(NULL,0,20,1);                                   
            int Buy = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point);                         
          }                                                     
        } 
        
//-------------------------------
              
     else
      {                                                           
        if (true == (Bid < (Low[iLowest(NULL,0,MODE_LOW,10, 1)])))
           {                                                        
             ATR = iATR(NULL,0,20,1);                                
             int Sell = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid-StopLoss*Point,Bid+TakeProfit*Point);
           }                                              
          return(0);       
        }                                                                   
                                                                       
//------------- Closing Orders -----------------

double Amount;
double total;

for(Amount=0; Amount < total; Amount++)
{                                                                  
  OrderSelect(Amount, SELECT_BY_POS, MODE_TRADES);
  if(OrderType() <= OP_SELL &&                                                    //Any open SHORT position? 
                                                  //My question to the above '<=', LESS than or EQUAL to SELL,
                                                  //where as program accepts '==', expression EQUAL to BUY??
                                                  //It seems that both block are asking for what type of 
                                                  //position and symbol, yet expressions are not the same??
                                                  //I would understand '!==' or '==', but '<=='??
     OrderSymbol()==Symbol())                                                     //What is the symbol?
       {                                              
         if (OrderType() == OP_BUY &&                                             //Any open LONG position? 
            OrderSymbol() == Symbol())                                            //What is the symbol?
               {                                   
                 if  (OrderTakeProfit() == (OrderOpenPrice() - (ATR*2))) //<<<<<<<<<<<<<<<
                      OrderClose(OrderTicket(),OrderLots(),Ask,3,Blue);           //Position closed
               }
            }
                                                              
      else
       {                                          
         if (OrderTakeProfit() == (OrderOpenPrice() + (ATR*2)))          //Should it be closed?                                                  
             OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);                     // Position closed
       }                                              
     return(0);                                                                   //Exit Algorithm
   }  
}                                                                                //Exit start()
 

Hucklebery, next time don't open a new thread for the same problem. That just makes the forum messy.


Observations:

  • Your indentation is still messy and inconsistent. For example the whole section that starts at 'Closing Orders' should have the same indentation level as -> if(OrdersTotal()==0)...
  • I recommend you read about indentation here: http://en.wikipedia.org/wiki/Indent_style.
  • The location of both return(0) statements doesn't make any sense. The 2nd statement actually quits start() after the first loop iteration (so the loop never goes beyond Amount = 0).
  • The loop itself should be decrementing since it does an operation that affects the indexing of the order pool itself. Read here -> https://www.mql5.com/en/forum/119840.
 
if (true == (Ask > (High[iHighest(NULL,0,MODE_HIGH,10, 1)])))
Simplify, simplify
if (Ask > High[iHighest(NULL,0,MODE_HIGH,10, 1)]) {
//I would understand '!==' or '==', but '<=='??
var = value; so you need == for equality. <== is invalid, <= is sufficient.
double total;

for(Amount=0; Amount < total; Amount++)
already answered in the previous thread. If you are closing positions you must count down. Also you never initialize total. so the loop won't work.
Reason: