Try this :
PHP Code:
int start()
{
int cnt, totalOrders;
totalOrders = OrdersTotal();
if (totalOrders>0) // open orders identified
{
for (cnt=1;cnt<totalOrders;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if ((OrderType() == OP_BUY) && ((Bid-OrderOpenPrice())>TrailingStop))
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),YellowGreen);
return(0);
}
}
else ((OrderType() == OP_SELL) && (OrderOpenPrice()-Ask)>(TrailingStop))
{
if ((OrderStopLoss()>Ask+TrailingStop*Point) || (OrderStopLoss()=0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Tra ilingStop*Point,OrderTakeProfit(),Red);
return (0);
}
}
}
}
}
Hope this help
