What is wrong with this small pice of code? - page 2

 

There are 3 possible explanations (that I can currently see):

  1. this part of the code is never executed
  2. the order is placed and you didn't notice
  3. the order fails and you didn't notice the errors in the Experts tab (Journal tab if using Strategy tester)
I suspect the answer is no. 1. The OrderSend is not dependant on bOrders being equal to 0 so the OrderSend will always happen . . . hence I suspect that this part of the code isn't being run.

if (bOrders == 0)    // <------------  this line determines . . . .
 
       if (IsTradeContextBusy()) Sleep(10);   //  if this line  <------  gets executed.  Nothing else . . . .

if you want to check if this line is being executed . . . 

BuyTicket = OrderSend(Symbol(),OP_BUYSTOP,LotSize,BuyPrice,UseSlippage,BuyStopLoss,BuyTakeProfit,"Buy Stop Order",MagicNumber,0,Green);

add this line before it . . . and keep an eye on the Experts tab (Journal tab if using the Strategy tester)

Print("About to place BUYSTOP order . . .  ");
 
if (bOrders == 0) if (IsTradeContextBusy()) Sleep(10);
BuyTicket = OrderSend(

I doubt that is what you meant.

Add print statements around

Print("Calling openNewOrders");
openNewOrders();
Print("Called openNewOrders");
if openNewOrders doesn't then you know where the problem lies. If it isn't called you also know where the problem lies.