依赖于经纪商的交易函数库, 可以在脚本和EA交易代码中使用.
您可以在文章"使用信号灯指标的简单交易系统"中获得基于本函数库的EA交易.
在代码库中, 很多EA交易都使用了这个函数库, 它可以支持在MetaTrader 5客户终端上使用EA进行交易的任何经纪商:
- 支持提供非零点差并允许在建立仓位的同时设置止损和获利的经纪商;
- 支持提供零点差 并允许在 建立仓位的同时设置止损和获利的经纪商;
- 支持提供非零点差并允许在建立仓位之后设置止损和获利的经纪商;
- 支持提供零点差并允许在建立仓位之后设置止损和获利的经纪商;
所有的功能都归档在一个文件中- TradeAlgorithms.mqh. 对于在代码库中使用了这个函数库的EA交易, 只允许把 TradeAlgorithm.mqh文件按名称放置到一个客户终端的 terminal_data_folder\MQL5\Include\ 目录下!
在移动了此库文件以后, 使用它的所有EA交易都应该被编译. 为了这样做, 重启 MetaEditor, 打开浏览器窗口, 用鼠标右键单击 MQL5 标签并在弹出菜单中选择 "Compile".
函数
本函数库包含以下的主要交易函数:
bool BuyPositionOpen ( bool &BUY_Signal, // 允许交易的标志 const string symbol, // 交易品种 const datetime &TimeLevel, // 当前交易后多久可以进行下一个交易 double Money_Management, // 资金管理 int Margin_Mode, // 手数计算方法 uint deviation, // 滑点数 int StopLoss, // 止损点数 int Takeprofit // 获利点数 ); bool SellPositionOpen ( bool &SELL_Signal, // 允许交易的标志 const string symbol, // 交易品种 const datetime &TimeLevel, // 当前交易后多久可以进行下一个交易 double Money_Management, // 资金管理 int Margin_Mode, // 手数计算方法 uint deviation, // 滑点数 int StopLoss, // 止损点数 int Takeprofit // 获利点数 ); bool BuyPositionOpen ( bool &BUY_Signal, // 允许交易的标志 const string symbol, // 交易品种 const datetime &TimeLevel, // 当前交易后多久可以进行下一个交易 double Money_Management, // 资金管理 int Margin_Mode, // 手数计算方法 uint deviation, // 滑点数 double dStopLoss, // 止损的图表价格单位 double dTakeprofit // 获利的图表价格单位 ); bool SellPositionOpen ( bool &SELL_Signal, // 允许交易的标志 const string symbol, // 交易品种 const datetime &TimeLevel, // 当前交易后多久可以进行下一个交易 double Money_Management, // 资金管理 int Margin_Mode, // 手数计算方法 uint deviation, // 滑点数 double dStopLoss, // 止损的图表价格单位 double dTakeprofit // 获利的图表价格单位 ); bool BuyPositionClose ( bool &Signal, // 允许交易的标志 const string symbol, // 交易品种 uint deviation // 滑点数 ); bool SellPositionClose ( bool &Signal, // 允许交易的标志 const string symbol, // 交易品种 uint deviation // 滑点数 ); bool BuyPositionModify ( bool &Modify_Signal, // 允许修改的标志 const string symbol, // 交易品种 uint deviation, // 滑点数 int StopLoss, // 止损点数 int Takeprofit // 获利点数 ); bool SellPositionModify ( bool &Modify_Signal, // 允许修改的标志 const string symbol, // 交易品种 uint deviation, // 滑点数 int StopLoss, // 止损点数 int Takeprofit // 获利点数 );
由MetaQuotes Ltd译自俄语
原代码: https://www.mql5.com/ru/code/1578