如何使用 MQL4
获取经济公告的最新发布值与另一个名为 x
的变量进行比较?
我需要将获取的数据(变量 x
)与手动输入变量 y
进行比较170000
的值。
如果x > y
,执行一个函数,并且如果 x < y
执行不同的函数。
extern int x = 170000;
extern int y = ...; //Fetch latest value of economic announcement
//to compare to extern int x
void OnStart()
{
if(x>y){
//Executes a function
}
else
if (x<y){
//Executes a different function
}
}
使用extern int
,如果我设置 x = 1
和x = 3
(或任何其他数字)手动,脚本工作正常。我只是想知道是否 extern int
将是获取值并将其转换为数字的合适方法,以便我可以通过 x > y
比较它们。或x < y
?
我从另一个网站找到了一个 SLOC,其中有人想要将整个经济日历导入到他们的算法中(尽管事实上我只需要一个最新值),我认为将其包含在这个问题中可能有点有用。它从 .csv
导入数据文件,所以也许我也可以尝试这个方法。 SLOC:
extern string HtmlAdress = "http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv";
我知道延迟将是此方法的一个突出问题,但这仍然可以实现吗?
最佳答案
可以实现吗?是:
如何?
<强> 1.
找到稳定可靠的发布数据来源(发布延迟、数据有效性)
<强> 2.
检查他们如何/是否操作某种技术传播或远程访问宏观数据的手段( RSS
-数据源,而不仅仅是新闻专线、平面/“ondulated"普通 html
网络表、静态命名文件更新等)
<强> 3.
实现一个代理扫描器,它将实现 (2)
自主执行 MetaTrader 终端 的外部操作及其内部代码执行单元。
<强> 4.
装备 (3)
具有与协议(protocol)无关的、多平台的、与 MT4
在线通信的集成就绪方式 进程( ZeroMQ
、 nanomsg
等)
<强> 5.
实现 MT4
ExpertAdvisor
代码包括快速高效的通信交换和空闲握手 proxy-scanner (3)
。
工具?
经过多年大规模系统集成的实践,最有效的方法是快速原型(prototype)开发 (2+3+4)
一个python-2.x
是执行此操作的合理选择并且 ZeroMQ
或nanomsg
为 (4+5)
提供相当广泛的移植框架
例子?是:
https://www.dailyfx.com/calendar/index_iframe.html?tz=2&sort=date&week=today&eur=true&usd=true&jpy=true&gbp=true&chf=true&aud=true&cad=true&nzd=true&cny=true&high=true&medium=true&low=true
Brings an algorithmically parse-ablehtml
-table as a source of the needed value(s):<tr class ="e-cal-row" id ="eventrow10" onClick ="commentOnOff('...xml',10,'english')"> <td></td> <td>
10:00
</td> <td><div class="flag-32-eur"></div></td> <td width="100%">
EUR German IFO - Expectations (AUG)
</td> <td class="evImportance medium"><span></span></td> <td style="color:red" nowrap="nowrap"> <span style="color:red">
100.1
</span></td> <td nowrap="nowrap">
102.4
</td> <td style="color:red" nowrap="nowrap"> <span style="color:red">
102.2
</span></td> <td align="right"><div class="arrow"></div></td> </tr>
有风险吗?是:
更多的组件意味着更多的地方可以实现错误恢复策略
解决方案最终取决于
(2)
的状态(可以实现1+1更新源)最后,
(2)
中的任何微小变化 使您的处理线停止并强制您的实现循环回(2)
并重新再次开始重新工程、重新实现和重新测试步骤。
关于trading - MQL4:如何获取经济日历的事件值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39142966/