,欢迎光临!
加入收藏设为首页在线咨询
您当前位置:网站首页 >> 投资软件 >> MT4/MT5 >> MT4-MQL4 编程入门(第21节 交易函数)

MT4-MQL4 编程入门(第21节 交易函数)

2010-12-27 14:11:02 来源:《008财富网》 浏览:13463

免费QQ群号94337889( 外盘期货/恒指期货交流)

第二十一节 交易函数 [Trading Functions]

 

 

int HistoryTotal( ) 返回历史数据的数量 // retrieving info from trade history int i,hstTotal=HistoryTotal(); for(i=0;i< } to break; ---- check selection result if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)="=false)" Print(?Access history failed error (?,GetLastError(),?)?); some work with order>

 

bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE) 对订单进行平仓操作。 :: 输入参数 ticket - 订单编号 lots - 手数 price - 平仓价格 slippage - 最高划点数 Color - 标记颜色 示例: if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75) { OrderClose(order_id,1,Ask,3,Red); return(0); }

 

 bool OrderCloseBy( int ticket, int opposite, color Color=CLR_NONE) 对订单进行平仓操作。 :: 输入参数 ticket - 订单编号 opposite - 相对订单编号 Color - 标记颜色 示例: if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75) { OrderCloseBy(order_id,opposite_id); return(0); }

 

double OrderClosePrice( ) 返回订单的平仓价 示例: if(OrderSelect(ticket,SELECT_BY_POS)==true) Print("Close price for the order ",ticket," = ",OrderClosePrice()); else Print("OrderSelect failed error code is",GetLastError());

 

datetime OrderCloseTime( ) 返回订单的平仓时间 示例: if(OrderSelect(10,SELECT_BY_POS,MODE_HISTORY)==true) { datetime ctm=OrderOpenTime(); if(ctm>0) Print("Open time for the order 10 ", ctm); ctm=OrderCloseTime(); if(ctm>0) Print("Close time for the order 10 ", ctm); } else Print("OrderSelect failed error code is",GetLastError());

 

string OrderComment( ) 返回订单的注释 示例: string comment; if(OrderSelect(10,SELECT_BY_TICKET)==false) { Print("OrderSelect failed error code is",GetLastError()); return(0); } comment = OrderComment(); // ...

 

double OrderCommission( ) 返回订单的佣金数 示例: if(OrderSelect(10,SELECT_BY_POS)==true) Print("Commission for the order 10 ",OrderCommission()); else Print("OrderSelect failed error code is",GetLastError());

 

 bool OrderDelete( int ticket) 删除未启用的订单 :: 输入参数 ticket - 订单编号 示例: if(Ask>var1) { OrderDelete(order_ticket); return(0); }

 

datetime OrderExpiration( ) 返回代办订单的有效日期 示例: if(OrderSelect(10, SELECT_BY_TICKET)==true) Print("Order expiration for the order #10 is ",OrderExpiration()); else Print("OrderSelect failed error code is",GetLastError());

 

double OrderLots( ) 返回选定订单的手数 示例: if(OrderSelect(10,SELECT_BY_POS)==true) Print("lots for the order 10 ",OrderLots()); else Print("OrderSelect failed error code is",GetLastError());

 

 int OrderMagicNumber( ) 返回选定订单的指定编号 示例: if(OrderSelect(10,SELECT_BY_POS)==true) Print("Magic number for the order 10 ", OrderMagicNumber()); else Print("OrderSelect failed error code is",GetLastError()); bool OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE) 对订单进行平仓操作。 :: 输入参数 ticket - 订单编号 price - 平仓价格 stoploss - 止损价 takeprofit - 获利价 expiration - 有效期 Color - 标记颜色 示例: if(TrailingStop>0) { SelectOrder(12345,SELECT_BY_TICKET); if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()< } OrderModify(OrderTicket(),Ask-10*Point,Ask-35*Point,OrderTakeProfit(),0,Blue); return(0);>

 

double OrderOpenPrice( ) 返回选定订单的买入价 示例: if(OrderSelect(10, SELECT_BY_POS)==true) Print("open price for the order 10 ",OrderOpenPrice()); else Print("OrderSelect failed error code is",GetLastError());

 

datetime OrderOpenTime( ) 返回选定订单的买入时间 示例: if(OrderSelect(10, SELECT_BY_POS)==true) Print("open time for the order 10 ",OrderOpenTime()); else Print("OrderSelect failed error code is",GetLastError());

 

void OrderPrint( ) 将订单打印到窗口上 示例: if(OrderSelect(10, SELECT_BY_TICKET)==true) OrderPrint(); else Print("OrderSelect failed error code is",GetLastError());

 

bool OrderSelect( int index, int select, int pool=MODE_TRADES) 选定订单 :: 输入参数 index - 订单索引 select - 选定模式,SELECT_BY_POS,SELECT_BY_TICKET pool - Optional order pool index. Used when select parameter is SELECT_BY_POS.It can be any of the following values: MODE_TRADES (default)- order selected from trading pool(opened and pending orders), MODE_HISTORY - order selected from history pool (closed and canceled order). 示例: if(OrderSelect(12470, SELECT_BY_TICKET)==true) { Print("order #12470 open price is ", OrderOpenPrice()); Print("order #12470 close price is ", OrderClosePrice()); } else Print("OrderSelect failed error code is",GetLastError());

 

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) 发送订单 :: 输入参数 symbol - 通货标示 cmd - 购买方式 volume - 购买手数 price - 平仓价格 slippage - 最大允许滑点数 stoploss - 止损价 takeprofit - 获利价 comment - 注释 magic - 自定义编号 expiration - 过期时间(只适用于待处理订单) arrow_color - 箭头颜色 示例: 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); } }

 

double OrderStopLoss( ) 返回选定订单的止损 示例: if(OrderSelect(ticket,SELECT_BY_POS)==true) Print("Stop loss value for the order 10 ", OrderStopLoss()); else Print("OrderSelect failed error code is",GetLastError()); int Or

 

dersTotal( ) 返回总订单数 示例: int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t"); if(handle<0) return(0); // write header FileWrite(handle,"#","open price","open time","symbol","lots"); int total=OrdersTotal(); // write open orders for(int pos=0;pos OS++) { if(OrderSelect(pos,SELECT_BY_POS)==false) continue; FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots()); } FileClose(handle);

 

int OrdersTotal( ) 返回总订单数 示例: if(OrderSelect(order_id, SELECT_BY_TICKET)==true) Print("Swap for the order #", order_id, " ",OrderSwap()); else Print("OrderSelect failed error code is",GetLastError());

 

 double OrderSwap( ) 返回指定订单的汇率 示例: if(OrderSelect(order_id, SELECT_BY_TICKET)==true) Print("Swap for the order #", order_id, " ",OrderSwap()); else Print("OrderSelect failed error code is",GetLastError());

 

string OrderSymbol( ) 返回指定订单的通货标识 示例: if(OrderSelect(12, SELECT_BY_POS)==true) Print("symbol of order #", OrderTicket(), " is ", OrderSymbol()); else Print("OrderSelect failed error code is",GetLastError());

 

 double OrderTakeProfit( ) 返回指定订单的获利点数 示例: if(OrderSelect(12, SELECT_BY_POS)==true) Print("Order #",OrderTicket()," profit: ", OrderTakeProfit()); else Print("OrderSelect() âåðíóë îøèáêó - ",GetLastError());

 

 int OrderTicket( ) 返回指定订单的编号 示例: if(OrderSelect(12, SELECT_BY_POS)==true) order=OrderTicket(); else Print("OrderSelect failed error code is",GetLastError());

 

 int OrderType( ) 返回指定订单的类型 示例: int order_type; if(OrderSelect(12, SELECT_BY_POS)==true) { order_type=OrderType(); // ... } else Print("OrderSelect() âåðíóë îøèáêó - ",GetLastError());

发表评论
网名:
评论:
验证:
共有0人对本文发表评论查看所有评论(网友评论仅供表达个人看法,并不表明本站同意其观点或证实其描述)
  • 联系邮箱:service#918008.com(请把#换成@) - 在线QQ:77446881
  • 外盘期货|外盘开户|恒指期货|恒指期货期权开户|外盘期货开户|外盘期权开户|新华富时A50指数开户|恒指开户|恒指配资|恒指软件|
  • 外盘配资|外盘期货配资|外汇软件|恒指期权开户|美原油软件|恒指喊单软件|期货配资|恒指分析软件
  • 苏ICP备17053501号 Copyright 2018, 版权所有 www.918008.com.
在线客服 客服软件
在线客服系统

免责申明:本网站刊载的内容,部份搜集自网络,供大家免费浏览,所有相关权益归原作者所有,《008财富网》无意侵犯任何人、任何机构的权益!如果其中有您的文章不想被我们转载,请告诉我们!本网站刊载的所有内容,不构成投资建议,仅供参考,风险自负。任何投机交易在具体高度收益性的同时也具有高度风险性,通常只适合于能够承担相应风险的人士。鉴于存在的这些风险,您应该在完全了解所涉及交易的性质以及自身面临风险的程度后才进行交易。投资有风险,入市须谨慎!所有解释权归《008财富网》所有。