下市價單或是掛限價單
int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)
Parameters:
symbol - 交易貨幣對名稱, ex:EURUSE, GBPUSD
cmd - 開單類型, ex: buy or sell in 市價單或限價單
volume - 下單手數, ex: 0.1 lot or 1 lot
price - 開單價格
slippage - 允許的最大滑點數 for buy or sell orders.
stoploss - 止損價格
takeprofit - 盈利價格
comment - 訂單註解, Last part of the comment may be changed by server.
magic - 訂單指定碼, May be used as user defined identifier.
expiration - 定單有效期限 (for pending orders only,只限掛單).
arrow_color - 圖表上箭頭顏色. If parameter is missing or has CLR_NONE value opening arrow is not drawn on the chart.
Sample:
int ticket;
if(iRSI(NULL,0,14,PRICE_CLOSE,0)<25)
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}
Returns
Symbol(): 下本貨幣對的單
OP_BUY: 下市價買單
1: 下單手數是1手
ASK: 下單價格是目前的買價(ask price)
3: 允許最大滑點數3點
Ask-25*Point: 停損價格
Ask+25*Point: 停利價格
My Order #2: 做為自我識別的號碼
16384: 給這筆單子一個編號16384
0: 此筆訂單不設定有效期限
Green: 圖示上的箭頭設置為綠色(因為在EA下單後,會在K線圖上把開單的價格標示出來)
number of the ticket assigned to the order by the trade server or -1 if it fails.
如果下單成功,則回傳值為此筆單子的訂單號碼,如果下單失敗則回傳值為 -1