下载MetaTrader 5

请观看如何免费下载自动交易

有趣的脚本?
因此发布一个链接 -
让其他人评价

喜欢这个脚本? 在MetaTrader 5客户端尝试它

显示:
351
等级:
投票: 24
已发布:
2017.11.16 10:04

"Pending orders DOWN" 脚本程序设置一个低于当前价格的挂单网格。


输入参数

  • Gap for pending orders DOWN from the current price (in pips) - 当前价格与第一个挂单之间的距离.
  • Step between orders DOWN (in pips) - 挂单之间的距离.
  • Type of pending orders DOWN - 挂单的类型 (可以是限价买入或者是止损卖出).
  • DOWN quantity - 设置的挂单数量.
  • Lots - 每个挂单的交易量.
  • Stop Loss (in pips) - 止损值.
  • Take Profit (in pips) - 获利值.

该脚本通过使用异步交易操作来确保最快地发送交易请求来设置挂单:

   m_trade.SetAsyncMode(true);

这里是一个发送5个挂单请求的例子:

2017.08.28 09:00:30.227 Scripts script Pending orders DOWN (AUDCAD,Daily) loaded successfully
2017.08.28 09:00:35.272 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98893 sl: 0.99143 tp: 0.98693
2017.08.28 09:00:35.272 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98743 sl: 0.98993 tp: 0.98543
2017.08.28 09:00:35.273 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98593 sl: 0.98843 tp: 0.98393
2017.08.28 09:00:35.273 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98443 sl: 0.98693 tp: 0.98243
2017.08.28 09:00:35.273 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98293 sl: 0.98543 tp: 0.98093
2017.08.28 09:00:35.274 Scripts script Pending orders DOWN (AUDCAD,Daily) removed

五个挂单是在1毫秒之内发送的!

这里是完整报告,从脚本开始到删除 (第一个订单发送的时间是 2017.08.28 09:00:35.272):

2017.08.28 09:00:30.227 Scripts script Pending orders DOWN (AUDCAD,Daily) loaded successfully
2017.08.28 09:00:35.272 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98893 sl: 0.99143 tp: 0.98693
2017.08.28 09:00:35.272 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98743 sl: 0.98993 tp: 0.98543
2017.08.28 09:00:35.273 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98593 sl: 0.98843 tp: 0.98393
2017.08.28 09:00:35.273 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98443 sl: 0.98693 tp: 0.98243
2017.08.28 09:00:35.273 Trades  '6121033': sell stop 0.01 AUDCAD at 0.98293 sl: 0.98543 tp: 0.98093
2017.08.28 09:00:35.274 Scripts script Pending orders DOWN (AUDCAD,Daily) removed
2017.08.28 09:00:35.340 Trades  '6121033': accepted sell stop 0.01 AUDCAD at 0.98893 sl: 0.99143 tp: 0.98693
2017.08.28 09:00:35.341 Trades  '6121033': order #164992356 sell stop 0.01 / 0.01 AUDCAD at market done in 68.657 ms
2017.08.28 09:00:35.341 Trades  '6121033': accepted sell stop 0.01 AUDCAD at 0.98743 sl: 0.98993 tp: 0.98543
2017.08.28 09:00:35.342 Trades  '6121033': order #164992357 sell stop 0.01 / 0.01 AUDCAD at market done in 69.645 ms
2017.08.28 09:00:35.342 Trades  '6121033': accepted sell stop 0.01 AUDCAD at 0.98593 sl: 0.98843 tp: 0.98393
2017.08.28 09:00:35.343 Trades  '6121033': order #164992358 sell stop 0.01 / 0.01 AUDCAD at market done in 70.006 ms
2017.08.28 09:00:35.343 Trades  '6121033': accepted sell stop 0.01 AUDCAD at 0.98443 sl: 0.98693 tp: 0.98243
2017.08.28 09:00:35.343 Trades  '6121033': order #164992359 sell stop 0.01 / 0.01 AUDCAD at market done in 70.346 ms
2017.08.28 09:00:35.343 Trades  '6121033': accepted sell stop 0.01 AUDCAD at 0.98293 sl: 0.98543 tp: 0.98093
2017.08.28 09:00:35.343 Trades  '6121033': order #164992360 sell stop 0.01 / 0.01 AUDCAD at market done in 70.312 ms

当最后一个挂单被确认的时间是 2017.08.28 09:00:35.343. 所有的操作总共才花费了 71 毫秒!

在脚本运行的开始,要检查指定交易量正确性:

//+------------------------------------------------------------------+
//| 脚本程序起始函数                         |
//+------------------------------------------------------------------+
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 Software Corp. 撰写的俄文原文
官方代码: https://www.mql5.com/ru/code/19025

Pending orders UP Pending orders UP

这个脚本程序在比当前价格高的地方设置多个挂单。

历史交易与订单 历史交易与订单

'历史交易与订单(History Deals and Orders)'脚本程序显示了在给定时间段的交易历史中的交易和订单所有属性。

Burg Extrapolator Burg Extrapolator

本EA交易使用Burg的方法来进行线性预测。

Carbophos Carbophos

本EA交易设置一个限价卖出和限价买入挂单的网格。