脚本: 导出仓位历史

 

导出仓位历史:

从一个对冲账户里导出已平仓位的历史记录至 .csv 文件。

要导出整个交易历史记录,请将 Start dateEnd date 保留为默认值 (1970.01.01 00:00:00)。

作者: amrali

 
可以看到,所有封闭位置的重建方式与the History tab of the MetaTrader 5 terminal 相同。
遗憾的是,这种展示方式并不方便。因为您看不到交易头寸的连续平仓是如何进行的
 
fxsaber:
遗憾的是,这种演示方式并不方便。因为您无法看到交易头寸是如何连续平仓的。

我的脚本尽量采用与 MetaTrader 5 终端 "历史 "选项卡中相同的显示方式。如果您更喜欢以方便的方式显示按平仓时间排序的历史交易,可以使用我的另一个脚本"导出历史交易"。

https://www.mql5.com/zh/code/24608

Export Deals History
Export Deals History
  • www.mql5.com
Accelerator Oscillator (AC) The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force. MACD Signals Indicator edition for new platform.
 

新增按开仓时间 或平仓时间排序平仓的选项。


 

你们好、

回溯测试 中运行我的 EA 后,我将脚本拖放到图表中,但得到的 csv 结果却是空的。只有标签。我做错了什么?

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 
filipe197:

你们好

回溯测试 中运行我的 EA 后,我将脚本拖放到图表中,但得到的 csv 结果却是空的。只有标签。我做错了什么?

脚本应该在真实账户上运行
 
amrali:
该脚本应在真实账户上运行

感谢您的回复。我明白,但我不能用这个脚本来提取与回溯测试 相关的交易信息吗?

 
filipe197:

感谢您的回复。我明白了,但我不能用这个脚本来提取与回溯测试 相关的交易信息吗?

请修改您的 EA,并将脚本代码粘贴到 EA 的 OnTester() 函数中。

 

你好

我运行了这个脚本,它向 XL 传递了一个未按列结构编排的 mush。


开盘时间、票据、类型、成交量、符号、开盘价、S/L、T/P、收盘时间、收盘价、佣金、掉期、盈利、盈利点数、余额、魔数、持续时间、开盘原因、收盘原因、开盘评论、收盘评论、成交票据、成交票据
2022.01.04 17:57:39,268558289,buy,0.01,EURUSD,1.13147,,,2022.01.04 17:58:06,1.13110,0.00,0.00,-0.37,-37.0,-0.37,0,00:00:27,client,client,,,222353427,222353591
2022.01.05 10:20:42,268646473,sell,0.01,EURUSD,1.13046,1.13411,1.11571,2022.01.05 10:31:27,1.13106,0.00,0.00,-0.60,-60.0,-0.97,910200201,00:10:45,expert,client,Expert id 910200201,,222420468,222422518
2022.01.05 10:31:28,268648565,sell,0.01,EURUSD,1.13087,1.13450,1.11612,2022.01.05 10:31:40,1.13105,0.00,0.00,-0.18,-18.0,-1.15,910200201,00:00:12,expert,client,Expert id 910200201,,222422519,222422538
2022.01.05 10:15:49,268646116,sell,0.04,EURUSD,1.13048,1.13372,1.11573,2022.01.05 10:31:51,1.13104,0.00,0.00,-2.24,-56.0,-3.39,910200001,00:16:02,expert,client,Expert id 910200001,,222420132,222422609
2022.01.05 10:31:41,268648590,sell,0.01,EURUSD,1.13088,1.13451,1.11613,2022.01.05 11:04:37,1.13050,0.00,0.00,0.38,38.0,-3.01,910200201,00:32:56,expert,client,Expert id 910200201,,222422542,222425801
2022.01.05 10:31:53,268648657,sell,0.02,EURUSD,1.13087,1.13386,1.11613,2022.01.05 14:59:39,1.13083,0.00,0.00,0.08,4.0,-2.93,910200001,04:27:46,expert,client,Expert id 910200001,,222422611,222453837
2022.01.10 08:06:11,269221228,buy,0.02,EURUSD,1.13324,1.12940,1.14391,2022.01.10 16:02:16,1.12938,0.00,0.00,-7.72,-386.0,-10.65,910800101,07:56:05,expert,sl,Expert id 910800101,[sl 1.12940],222926543,223004606
2022.01.10 16:02:17,269306301,sell,0.02,EURUSD,1.12938,1.13322,1.11871,2022.01.10 19:05:19,1.13323,0.00,0.00,-7.70,-385.0,-18.35,910800101,03:03:02,expert,sl,Expert id 910800101,[sl 1.13322],223004623,223050972
2022.01.10 18:47:33,269352794,buy,0.01,EURUSD,1.13219,1.12839,1.14286,2022.01.12 18:42:15,1.14286,0.00,-0.14,10.67,1067.0,-7.82,918002201,1d 23:54:42,expert,tp,Expert id 918002201,[tp 1.14286],223048016,223364473
2022.01.10 19:05:21,269356116,buy,0.02,EURUSD,1.13324,1.12943,1.14391,2022.01.12 19:23:07,1.14391,0.00,-0.28,21.34,1067.0,13.24,910800101,2d 00:17:46,expert,tp,Expert id 910800101,[tp 1.14391],223050998,223372986
2022.01.18 15:05:45,270467218,buy,0.08,EURJPY,130.423,130.057,131.356,2022.01.18 17:04:34,130.056,0.00,0.00,-25.63,-367.0,-12.39,918001202,01:58:49,expert,sl,Expert id 918001202,[sl 130.057],223957533,223990938
2022.01.18 15:14:24,270469968,buy,0.08,EURUSD,1.13694,1.13313,1.14777,2022.01.18 18:24:26,1.13312,0.00,0.00,-30.56,-382.0,-42.95,918003201,03:10:02,expert,sl,Expert id 918003201,[sl 1.13313],223960298,224011365
2022.01.18 15:14:24,270469969,buy,0.16,EURUSD,1.13694,1.13313,1.14777,2022.01.18 18:24:26,1.13312,0.00,0.00,-61.12,-382.0,-104.07,918002201,03:10:02,expert,sl,Expert id 918002201,[sl 1.13313],223960299,224011366
2022.01.18 15:14:24,270469970,buy,0.16,EURUSD,1.13694,1.13313,1.14777,2022.01.18 18:24:26,1.13312,0.00,0.00,-61.12,-382.0,-165.19,918001201,03:10:02,expert,sl,Expert id 918001201,[sl 1.13313],223960300,224011367
2022.01.18 18:24:28,270523706,sell,0.08,EURUSD,1.13313,1.13695,1.12231,2022.01.19 05:21:19,1.13257,0.00,-0.06,4.48,56.0,-160.77,918001201,10:56:51,expert,client,Expert id 918001201,,224011423,224067576
2022.01.19 05:39:48,270601882,sell,0.08,EURUSD,1.13264,1.13649,1.12185,2022.01.20 03:31:12,1.13650,0.00,-0.19,-30.88,-386.0,-191.84,918001201,21:51:24,expert,sl,Expert id 918001201,[sl 1.13649],224068787,224228196
2022.01.18 17:55:05,270515118,buy,0.02,EURUSD,1.13457,1.13074,1.14536,2022.01.20 03:47:54,1.13618,0.00,-0.55,3.22,161.0,-189.17,918004201,1d 09:52:49,expert,client,Expert id 918004201,,224003250,224229770
2022.01.18 18:24:28,270523703,sell,0.04,EURUSD,1.13313,1.13695,1.12231,2022.01.20 05:17:30,1.13543,0.00,-0.13,-9.20,-230.0,-198.50,918003201,1d 10:53:02,expert,client,Expert id 918003201,,224011421,224236469
2022.01.18 18:24:28,270523704,sell,0.08,EURUSD,1.13313,1.13695,1.12231,2022.01.20 05:17:32,1.13543,0.00,-0.25,-18.40,-230.0,-217.15,918002201,1d 10:53:04,expert,client,Expert id 918002201,,224011422,224236472
2022.01.20 03:31:13,270804486,buy,0.08,EURUSD,1.13652,1.13267,1.14731,2022.01.20 05:17:41,1.13526,0.00,0.00,-10.08,-126.0,-227.23,918001201,01:46:28,expert,client,Expert id 918001201,,224228209,224236474
2022.01.18 17:17:36,270506158,sell,0.04,EURJPY,130.206,130.137,129.273,2022.01.20 18:28:00,129.273,0.00,-0.25,32.73,933.0,-194.75,918001202,2d 01:10:24,expert,tp,Expert id 918001202,[tp 129.273],223994747,224343794
2022.01.21 09:16:27,271086908,buy,0.01,EURUSD,1.13344,1.12959,1.14423,2022.01.21 09:17:30,1.13329,0.00,0.00,-0.15,-15.0,-194.90,918001201,00:01:03,expert,client,Expert id 918001201,,224466262,224466404
2022.01.21 09:17:32,271087081,sell,0.02,EURUSD,1.13329,1.13704,1.12250,2022.01.27 02:56:17,1.12361,0.00,-0.11,19.36,968.0,-175.65,918001201,5d 17:38:45,expert,mobile,Expert id 918001201,,224466406,225291747
2022.02.02 13:40:29,273129032,sell,0.01,EURJPY,129.424,129.430,129.414,2022.02.03 07:15:14,129.414,0.00,-0.05,0.09,10.0,-175.61,918001202,17:34:45,expert,tp,Expert id 918001202,[tp 129.414],226220541,226335079
2022.02.03 07:15:14,273268357,sell,0.01,EURJPY,129.391,129.397,129.381,2022.02.03 08:06:51,129.401,0.00,0.00,-0.09,-10.0,-175.70,918001202,00:51:37,expert,sl,Expert id 918001202,[sl 129.397],226335080,226337418
 
这段代码非常好用!我想知道你们是否有 mq4 版本?