modify order error 4051 - page 2

 

The Dealer assigns ticket numbers, not you.

If you want to know a ticket number, you have two ways to find it:

1. ticket = OrderSend(..., ..., ..., ...); Remember a ticket number when an order is opened.

2. OrderSelect( indexNumber, SEL_BY_POSITION, MODE_TRADES or MODE_HISTORY)

ticket = OrderTicket(); -- the selected ticket number is returned.

Using this method usually requires additional queries to determine you have selected the ticket that you are interested in.

 
ok, making sense now...
if...open order conditions are true....
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
           }
         else Print("Error opening SELL order : ",GetLastError()); 
         return(0); 
        }
so this code here would not only open an order, but assign the orders ticket number to the int 'ticket'. and I am assuming that the int 'ticket' can be any int, like ticket_two or ticket_three...
 
Looks ok.