Help with for loop - page 2

 

It doesn't print to the logs when you are Optimizing . . . :-)

Take a look at the stuff near the bottom of the page : https://www.mql5.com/en/articles/1512

 
RaptorUK:

It doesn't print to the logs when you are Optimizing . . . :-)

Take a look at the stuff near the bottom of the page : https://www.mql5.com/en/articles/1512


:-) - nothing is printed even when not optimizing
 
gulzaar:

:-) - nothing is printed even when not optimizing
Ah I see . . . why not ? add some more Print statements . .
 
gulzaar:
which is odd because the orders close well enough(which code is under the same if bracket, and uses the same OrderType() statement)
Do they get closed or do they hit SL or TP ?
 
RaptorUK:
Do they get closed or do they hit SL or TP ?

They either get closed by the original close logic in the start of the if(OrderType == OP_SELL) or hit the original SL(which is assigned at the time of OrderSend() - I will change that later to be NFA compatible)

    
   if(SellOne == true && SellTwo == true
         && SellThree == true 
         && Close[0] < TwentyEMA)
      {
      Ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,MarketInfo(Symbol(),MODE_SPREAD),0,0,NULL,MagicNumber,0,Red); 
      BarCount = Bars;
      double SellStop = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,0);//Same principle as above
      OrderModify(OrderTicket(),OrderOpenPrice(),SellStop,0,0,CLR_NONE);
      if (Ticket==-1)   ShowERROR(Ticket,0,0);

      }      
 
Ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,MarketInfo(Symbol(),MODE_SPREAD),0,0,NULL,MagicNumber,0,Red); 
      OrderModify(OrderTicket(),OrderOpenPrice(),SellStop,0,0,CLR_NONE);

You can NOT use OrderTicket, OrderOpenPrice, etc until you do a orderSelect. Always test return codes.
    int ticket = OrderSend(...)
    if (ticket < 0)
       Alert("OrderSend failed: ", GetLastError());
    else if (!OrderSelect(ticket, SELECT_BY_TICKET))
       Alert("OrderSelect failed: ", GetLastError());
    else if (!OrderModify(OrderTicket()...)
       Alert("OrderModify failed: ", GetLastError());
Reason: