What doesn't this script work?

 
Can anyone please help me find the bug in this script. It works in the EA, but wouldn't work standalone.
int start()
 {
//Input constants
   double Lots = 0.05;        //Lot size
   int SLN = 250;             //Normal Stop Loss
   int SLR = 250;             //Reverse Stop Loss
   int TPN = 700;             //Normal Take Profit
   int TPR = 500;             //Reverse Take Profit
   int total, cnt;
      {
                 //Open the TREND SELL order
                  Alert(Symbol(),": TO TREND-SELL ",Lots," lot at the Open Price of ", Open[0]);
                  //-----
                  OrderSend(Symbol(),OP_SELL,Lots,Bid,5,0,0,"Trend",255,0,CLR_NONE);
                  //Modify the last order by adding StopLoss and TakeProfit
                  total=OrdersTotal(); 
                  for(cnt=total-1;cnt>=0;cnt--)
                     {
                        OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
                        if(OrderType()==OP_SELL && OrderSymbol()== Symbol()&& OrderComment()== "Trend")
                        {
                           OrderModify(OrderTicket(),5,OrderOpenPrice()+(SLN*Point),OrderOpenPrice()-(TPN*Point),0,CLR_NONE);
                           Alert(Symbol(),": OPEN the TREND-SELL Order ", OrderTicket());
                        }
                     }
                  //Alert(GetLastError());
                  //                          
                  //return;
      }
  //----
   return(0);
  }
 

Unless I'm missing something, it worked fine for me as a script. opened a sell and fired 2 alerts...

V

edit: and updated sl/tp

This website uses cookies. Learn more about our Cookies Policy.