Open Forex4you Account

Server รัน EA 1000 / ปี

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

Author Topic: สอบถามเกี่ยวกับ ea ครับ  (Read 5663 times)

ao_junk

  • Newbie
  • *
  • Posts: 3
สอบถามเกี่ยวกับ ea ครับ
« on: ตุลาคม 19, 2011, 01:27:18 pm »
ea ที่ว่าจะเปิดทั้ง buy และ sell ครับ อยากจะรบกวนสอบถามครับว่า  เมื่อ price ไปแตะ take profit ฝั่งใดฝั่งหนึ่งแล้วจะให้ close ทุก order เราจะเขียนอย่างไรบ้างครับ

preeyada

  • Jr. Member
  • **
  • Posts: 67
Re: สอบถามเกี่ยวกับ ea ครับ
« Reply #1 on: ตุลาคม 21, 2011, 11:38:31 am »
void CloseAll() { 
   int total =OrdersTotal();
   for(int i=total;i>=0;i--) {
         OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
         int type = OrderType();
         if (type == OP_BUY) {OrderClose(OrderTicket(), OrderLots(),NormalizeDouble(OrderClosePrice(),Digits), 5, Blue );}
         if (type == OP_SELL) {OrderClose(OrderTicket(), OrderLots(),NormalizeDouble(OrderClosePrice(),Digits), 5, Red );}         
      }
   return(0);
}

เอา module นี้ไปไว้ล่างสุด แล้วเรียกใช้เมื่อตรงตามเงื่อนไขเลยครับ :)