เพื่อเรียนรู้วิธีการทำให้ EA มีการ Trailing Stop ติดตาม Order ที่เปิดอยู่ ตลอดเวลา
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;count0){ 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); } } } } } }
ไม่มีความคิดเห็น:
แสดงความคิดเห็น