Open Forex4you Account

Server รัน EA 1000 / ปี

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

Author Topic: การ closeOrder  (Read 6509 times)

sherlockh

  • Newbie
  • *
  • Posts: 9
การ closeOrder
« on: สิงหาคม 13, 2014, 06:09:37 pm »
ผมอยากจะทราบว่าการใช้คำสั่ง Orderclose() ใช้ยังไง

และอยากจะได้code การปิดออร์เดอร์ buy อย่างเดียวหรือ sell อย่างเดียวอะครับ


ขอบคุณครับ :)

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
Re: การ closeOrder
« Reply #1 on: สิงหาคม 13, 2014, 08:28:14 pm »
ลองเอา close all EA ไปศึกษาดูครับ

int start()
  {   int total =OrdersTotal();

for(int i=0;i<total;i++)


    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   
       int type   = OrderType();
               
       bool result = false;
             
       switch(type)
          {
         
          case OP_BUY  : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Pink);
                         break;     
          case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Pink);
                         
          }
   
   
   

}

return(0);
 }

sherlockh

  • Newbie
  • *
  • Posts: 9
Re: การ closeOrder
« Reply #2 on: สิงหาคม 13, 2014, 11:18:23 pm »
ขอบคุณครับ