[MT4/MQL4] Order Handle Guild / 訂單處理說明

Create / 建立

OrderSend

The main function used to open market or place a pending order.
int  OrderSend(
   string   symbol,              // symbol
   int      cmd                // operation
   double   volume,              // volume
   double   price,               // price
   int      slippage,            // slippage
   double   stoploss           // stop loss
   double   takeprofit,          // take profit
   string   comment=NULL,        // comment
   int      magic=0            // magic number
   datetime expiration=0,        // pending order expiration
   color    arrow_color=clrNONE  // color
   );

Ref: https://docs.mql4.com/trading/ordersend


Show how many Orders / 全部的訂單有幾筆

OrdersTotal

Returns the number of market and pending orders.
int  OrdersTotal();
Ref: https://docs.mql4.com/trading/orderstotal


Select Order (in Transaction by Position or by Order ID; All of the following actions go through this action) / 查詢訂單(以下所有行為都要經過此動作)

OrderSelect

The function selects an order for further processing.
bool  OrderSelect(
   int     index,            // index or order ticket
   int     select,           // flag
   int     pool=MODE_TRADES  // mode
   );
Ref: https://docs.mql4.com/trading/orderselect

The OrderSelect() function copies order data into program environment and all further calls of
OrderClosePrice()
OrderCloseTime()
OrderComment()
OrderCommission()
OrderExpiration()
OrderLots()
OrderMagicNumber()
OrderOpenPrice()
OrderOpenTime()
OrderPrint()
OrderProfit()
OrderStopLoss()
OrderSwap()
OrderSymbol()
OrderTakeProfit()
OrderTicket()
OrderType()

Modify an Order / 修改

OrderModify

Modification of characteristics of the previously opened or pending orders.
bool  OrderModify(
   int        ticket,      // ticket
   double     price,       // price
   double     stoploss,    // stop loss
   double     takeprofit,  // take profit
   datetime   expiration,  // expiration
   color      arrow_color  // color
   );
Ref: https://docs.mql4.com/trading/ordermodify


Delete Order / 刪除(Order Pending/BuyLimit/BuyStop/SellLimit/SellStop)

OrderDelete

Deletes previously opened pending order.
bool  OrderDelete(
   int        ticket,      // ticket
   color      arrow_color  // color
   );

Ref: https://docs.mql4.com/trading/orderdelete


Close Order / 關閉(Order Execution/Buy/Sell)

OrderClose

Closes opened order.
bool  OrderClose(
   int        ticket,      // ticket
   double     lots,        // volume
   double     price,       // close price
   int        slippage,    // slippage
   color      arrow_color  // color
   );
Ref: https://docs.mql4.com/trading/orderclose


留言

這個網誌中的熱門文章

[MT4/MQL4] Error Code / 程式錯誤代碼

Edit MQL4 on VSCode