 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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» |
|