将网站数据拉入CSV并每五分钟刷新一次

问题描述 投票:0回答:2

我正在使用MQL4开发一个程序,这需要从特定网页中提取一些数据片段。

如何每5分钟将其转储到.csv文件中?

我被困在怎样才能解决这个问题。

结构体

  1. .html页面转储的一些数据
  2. 插入.csv文件
  3. 阅读MQL4
algorithmic-trading mql4
2个回答
2
投票

由于你的问题是如此笼统(不是特定的编码问题),而且它太广泛了。我将提供一个概括性的答案,指出你正确的方向。你需要做自己的研究。

第1部分 - 安排活动

  • 在您的EA中,在OnInit()中;用EventSetTimer(5*60)创建一个计时器。
  • 这将触发事件OnTimer()事件。 5 * 60 = 5分钟。
  • 在那次OnTimer()活动中,请致电您的下载程序(参见第2部分)

第2部分 - 下载HTML

  • 您可以在不使用第三方DLL的情况下实现此目的。内置的Windows Wininet.DLL具有适合此的API: import "wininet.dll" //Put a # in-front of import int InternetAttemptConnect (int x); int InternetOpenW(string sAgent, int lAccessType, string sProxyName = "", string sProxyBypass = "", int lFlags = 0); int InternetOpenUrlW(int hInternetSession, string sUrl, string sHeaders = "", int lHeadersLength = 0, int lFlags = 0, int lContext = 0); int InternetReadFile(int hFile, int& sBuffer[], int lNumBytesToRead, int& lNumberOfBytesRead[]); int InternetCloseHandle(int hInet); import //Put a # in-front of import
  • 这应该让你开始下载部分(自己做一些研究)。
  • 首先是使用OpenW创建浏览器会话,然后使用OpenURLW打开URL,然后使用ReadFile API读取页面内容;最后,与CloseHandle结束会议。
  • 将MT4代码中的字符串变量放入HTML后,您只需按照自己的方式进行按摩即可。

第3部分 - 写入.CSV

要执行文件写入操作,您将查看FileOpen()FileWriteString()FileClose() MQL4函数。

第4部分 - 阅读.CSV

  • 要读取CSV文件,就像使用FileReadString()一样简单。
  • 您可以使用StringSplit()函数将字符串拆分为CSV。

0
投票

简短版本

  1. 是的,可能 - 通过独立于MQL4的外部流程,由于控制和同步需求,通过ZeroMQ连接到.ex4(ZMQ具有适用于许多生产级环境的端口/包装器,因此可以将MQL4集成到任何需求中
  2. 是的,可能 - 小学,亲爱的华生......(参考文献#1,如果需要,可以跳过)
  3. 是的,可能 - 可以在流程到流程中提供(参考#1和#2)

Check this and other MQL4/ZeroMQ posts on Stack Overflow

Another MQL4 Real-time output, being remote-logged and animated

© www.soinside.com 2019 - 2024. All rights reserved.