ถ้าเลื่อน TP เอา code นี้ไปใส่เพิ่มแล้วเรียกใช้ฟังก์ชั่นแบบในตัวอย่าง
extern int Trailing =10;
int start()
{
if(OrdersTotal()==0)
{
OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"EX6",0,0,Green);
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"EX6",0,0,Red);
}
trailingstop();
return(0);
}
void trailingstop() {
for(int count=0;count<OrdersTotal();count++)
{OrderSelect(count,SELECT_BY_POS,MODE_TRADES);
if(OrderType() == OP_BUY )
{if(Trailing > 0){
if(Bid - OrderOpenPrice() > Trailing*Point)
{if(OrderStopLoss()==0 || (Bid - OrderStopLoss()> Trailing*Point))
{OrderModify(OrderTicket(), OrderOpenPrice(),Bid - Trailing*Point, OrderTakeProfit(), 0, Blue); }
}
}
}
if(OrderType() == OP_SELL )
{ if(Trailing > 0)
{if(OrderOpenPrice() - Ask > Trailing*Point)
{
if(OrderStopLoss() == 0 || ( OrderStopLoss()-Ask > Trailing*Point ) )
{OrderModify(OrderTicket(), OrderOpenPrice(),Ask + Trailing*Point, OrderTakeProfit(), 0, Red); }
}
}
}
}
}