Open Forex4you Account

Server รัน EA 1000 / ปี

สั่งชื้อคู่มือการโปรแรกม MQL4

Author Topic: code ตัวอย่างที่ 8 tailing stop ไม่ทำงาน  (Read 7024 times)

taezar

  • Newbie
  • *
  • Posts: 3
code ตัวอย่างที่ 8 tailing stop ไม่ทำงาน
« on: มีนาคม 29, 2017, 11:28:45 am »
ได้ลองนำ code มาใน cd มาใช้ในบัญชี demo และ testback พบว่า มีการออกไม้ buy sell จากนั้นก็ไม่มีอะไรเกิดขึ้นอีกเลย ไม่มีการทำงานของ tailing stop หรือการปิด order เกิดขึ้น

tanakrit99

  • Newbie
  • *
  • Posts: 23
Re: code ตัวอย่างที่ 8 tailing stop ไม่ทำงาน
« Reply #1 on: มีนาคม 29, 2017, 12:28:23 pm »
ลองเปลี่ยนค่าใน Trainling Stop ให้สูงกว่า  15 ดูครับ เช่น 20

taezar

  • Newbie
  • *
  • Posts: 3
Re: code ตัวอย่างที่ 8 tailing stop ไม่ทำงาน
« Reply #2 on: มีนาคม 29, 2017, 01:45:07 pm »
ลองเปลี่ยนแล้วครับ เป็น 30 แต่ก็ไม่ทำงานครับ คู่ EU

tanakrit99

  • Newbie
  • *
  • Posts: 23
Re: code ตัวอย่างที่ 8 tailing stop ไม่ทำงาน
« Reply #3 on: มีนาคม 29, 2017, 02:14:14 pm »
ผมตั้งแบบนี้

extern int Trailing=20;
//+------------------------------------------------------------------+
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);                                   
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+