Define Order Status Problem

 

Hi all,

Can anyone can correct my code, i'm having problem on selecting order to define their status..

Really appreciate. Thanks


extern   double StopLoss = 200;     // StopLoss

extern   double TakeProfit = 100;   //Takeprofit

extern   double LotSize = 0.1;        //LotSize

extern   int Slippage = 3;

int start()

{

   int Sell;

   int Buystop;

   int close1, close2;

    //opening order

   if(OrdersTotal()==0)

   {

   //Opening SELL

   double SL = Bid + (StopLoss*Point);

   double TP = Bid - (TakeProfit*Point);

   double Lot = LotSize;  

   Sell = OrderSend (Symbol(),OP_SELL,Lot,Bid,Slippage,SL,TP,NULL,0,0);    

   //Opening BUYSTOP

   double nBid = Bid + (100*Point);

   double nSL = nBid - (StopLoss*Point);

   double nTP = nBid + (TakeProfit*Point); 

   Buystop = OrderSend (Symbol(),OP_BUYSTOP,Lot,nBid,Slippage,nSL,nTP,NULL,0,0); 

   if(OrderSelect(2,SELECT_BY_TICKET)==OP_BUY) //<-----------------------------If Buystop(2nd order) turn to Buy, set Sellstop order

   {

   //Opening SELLSTOP

   double mBid = Bid - (100*Point);

   double mSL = nBid + (StopLoss*Point);

   double mTP = nBid - (TakeProfit*Point); 

   Buystop = OrderSend (Symbol(),OP_BUYSTOP,Lot,mBid,Slippage,mSL,mTP,NULL,0,0);

   }  

   if (OrderSelect(1,SELECT_BY_TICKET)==false) //<-----------------------------If Sell(1st order) hit SL or TP, close all pending order

   {

   close1 = OrderDelete(Buystop);

   close2 = OrderDelete(Sellstop);

   }

   }

   return(0);

}