OrderTicket function


for example, forex

This function returns the ticker of the order/position selected by the OrderSelect() function.

   int err;
   if (OrderType() == OP_BUY)
     {
       // long position
       if ((Bid-OrderOpenPrice())>=(TrailingStop*Point))
         {
           // place Stop Loss
           if (OrderModify(OrderTicket(), OrderOpenPrice(), Bid-TrailingStop*Point,
                                    OrderTakeProfit(), 0))
             Print("#", OrderTicket(),": trailing stop ", Bid-TrailingStop*Point);
           else
             {
              err = GetLastError(); 
              Print("#", OrderTicket(),": trailing stop error ", err);
             }
         }
     }
   else
     {
       // short position
       if ((OrderOpenPrice()-Ask)>=(TrailingStop*Point))
         {
           // place Stop Loss
           if (OrderModify(OrderTicket(), OrderOpenPrice(), Ask+TrailingStop*Point,
                                    OrderTakeProfit(), 0))
             Print("#", OrderTicket(),": trailing stop ", Ask+TrailingStop*Point);
           else
             {
              err = GetLastError(); 
              Print("#", OrderTicket(),": trailing stop error ", err);
             }
         }
     }

In this example we use the OrderTicket() function:

   int OrderTicket()


Next article: "OrderProfit function"

+7 (495) 710-76-76
© 1998—2008 «Alpari»

close

Your Personal Area

For alpari.classic enter your account number (a letter and 4 figures) and the code word for the Personal Area.

For alpari.micro account: enter your login (6 figures) and the password for MT.

Open an account!Forgotten your password?