Pending orders UP - MetaTrader 5脚本
- 显示:
- 2171
- 等级:
- 已发布:
- 2017.11.16 10:03
- 已更新:
- 2018.02.28 16:06
- 需要基于此代码的EA交易或指标吗?请在自由职业者服务中订购 进入自由职业者服务
"Pending orders UP (向上挂单)" 脚本程序在高于当前价格处设置多个挂单组成网格。
输入参数
- Gap for pending orders UP from the current price (in pips) - 当前价格与第一个挂单之间的距离.
- Step between orders UP (in pips) - 挂单之间的距离.
- Type of pending orders UP - 挂单的类型 (可以是止损买入或者限价卖出).
- UP quantity - 需要设置的挂单数量.
- Lots - 每个挂单的交易量.
- Stop Loss (in pips) - 止损值.
- Take Profit (in pips) - 获利值.
该脚本通过使用异步交易操作来确保最快地发送交易请求来设置挂单:
m_trade.SetAsyncMode(true);
这里是一个发送5个挂单请求的例子:
2017.08.28 08:50:22.246 Scripts script Pending orders UP (AUDCAD,Daily) loaded successfully 2017.08.28 08:50:24.095 Trades '6121033': buy stop 0.01 AUDCAD at 0.99262 sl: 0.99011 tp: 0.99462 2017.08.28 08:50:24.095 Trades '6121033': buy stop 0.01 AUDCAD at 0.99412 sl: 0.99161 tp: 0.99612 2017.08.28 08:50:24.095 Trades '6121033': buy stop 0.01 AUDCAD at 0.99562 sl: 0.99311 tp: 0.99762 2017.08.28 08:50:24.096 Trades '6121033': buy stop 0.01 AUDCAD at 0.99712 sl: 0.99461 tp: 0.99912 2017.08.28 08:50:24.096 Trades '6121033': buy stop 0.01 AUDCAD at 0.99862 sl: 0.99611 tp: 1.00062 2017.08.28 08:50:24.097 Scripts script Pending orders UP (AUDCAD,Daily) removed
五个挂单是在1毫秒之内发送的!
这里是完整报告,从脚本的开始到它被删除 (发送第一个订单的时间是 2017.08.28 08:50:24.095):
2017.08.28 08:50:22.246 Scripts script Pending orders UP (AUDCAD,Daily) loaded successfully 2017.08.28 08:50:24.095 Trades '6121033': buy stop 0.01 AUDCAD at 0.99262 sl: 0.99011 tp: 0.99462 2017.08.28 08:50:24.095 Trades '6121033': buy stop 0.01 AUDCAD at 0.99412 sl: 0.99161 tp: 0.99612 2017.08.28 08:50:24.095 Trades '6121033': buy stop 0.01 AUDCAD at 0.99562 sl: 0.99311 tp: 0.99762 2017.08.28 08:50:24.096 Trades '6121033': buy stop 0.01 AUDCAD at 0.99712 sl: 0.99461 tp: 0.99912 2017.08.28 08:50:24.096 Trades '6121033': buy stop 0.01 AUDCAD at 0.99862 sl: 0.99611 tp: 1.00062 2017.08.28 08:50:24.097 Scripts script Pending orders UP (AUDCAD,Daily) removed 2017.08.28 08:50:24.169 Trades '6121033': accepted buy stop 0.01 AUDCAD at 0.99262 sl: 0.99011 tp: 0.99462 2017.08.28 08:50:24.170 Trades '6121033': order #164991202 buy stop 0.01 / 0.01 AUDCAD at market done in 107.907 ms 2017.08.28 08:50:24.170 Trades '6121033': accepted buy stop 0.01 AUDCAD at 0.99412 sl: 0.99161 tp: 0.99612 2017.08.28 08:50:24.174 Trades '6121033': order #164991203 buy stop 0.01 / 0.01 AUDCAD at market done in 78.513 ms 2017.08.28 08:50:24.174 Trades '6121033': accepted buy stop 0.01 AUDCAD at 0.99562 sl: 0.99311 tp: 0.99762 2017.08.28 08:50:24.175 Trades '6121033': order #164991204 buy stop 0.01 / 0.01 AUDCAD at market done in 79.283 ms 2017.08.28 08:50:24.175 Trades '6121033': accepted buy stop 0.01 AUDCAD at 0.99712 sl: 0.99461 tp: 0.99912 2017.08.28 08:50:24.175 Trades '6121033': accepted buy stop 0.01 AUDCAD at 0.99862 sl: 0.99611 tp: 1.00062 2017.08.28 08:50:24.175 Trades '6121033': order #164991205 buy stop 0.01 / 0.01 AUDCAD at market done in 79.516 ms 2017.08.28 08:50:24.175 Trades '6121033': order #164991206 buy stop 0.01 / 0.01 AUDCAD at market done in 79.565 ms
当设置最后一个挂单被确认的时间是 2017.08.28 08:50:24.175. 所有操作总共花费的时间只有 80 毫秒那么少!
在脚本运行的开始,要检查指定交易量的正确性:
//+------------------------------------------------------------------+ //| 脚本程序起始函数 | //+------------------------------------------------------------------+ void OnStart() { //--- if(InpLots<=0.0) { Print("\"Lots\" 不能小于或者等于0"); return; } //--- if(!m_symbol.Name(Symbol())) // 设置交易品种名称 return; if(!RefreshRates()) return; string err_text=""; if(!CheckVolumeValue(InpLots,err_text)) { Print(err_text); return; } //---
由MetaQuotes Ltd译自俄语
原代码: https://www.mql5.com/ru/code/19024