How can I fetch the latest released value of an economic announcement using MQL4
to be compared with another variable called x
?
I need to compare the fetched data (variable x
) with the manually entered variable y
value of 170000
.
If x > y
, a function is executed, and if x < y
a different function is executed.
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
}
}
Using extern int
, if I set x = 1
and x = 3
(or any other numbers) manually, the script works correctly. I'm just wondering if extern int
will be a suitable method to fetch a value and turn it in to a number so that I can compare them both via x > y
or x < y
?
I have found a SLOC from another website where somebody wanted to import a whole economic calendar in to their algorithm (despite the fact that I only require one single, latest value) which I thought may be somewhat useful to include in this question. It imports data from a .csv
file, so maybe I could attempt this method also. The SLOC:
extern string HtmlAdress = "http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv";
I understand that latency will be a prominent issue with this method, but is this possible to achieve nonetheless?
How?
1.
find a stable and reliable source of the published data ( delay of publication, validity of data )
2.
check, how / if they operate some means of technical dissemination or remote-access to macro-data ( RSS
-feed for data, not just the news-wire, flat / "ondulated" plain html
web-table(s), statically named file updates etc. )
3.
Implement a proxy-scanner, that will implement (2)
autonomously to external operations of the MetaTrader Terminal and it's internal code-execution units.
4.
Equip the (3)
with an integration-ready means of protocol-agnostic, multi-platform, online communications with MT4
processes ( ZeroMQ
, nanomsg
, et al )
5.
Implement MT4
ExpertAdvisor
code to include fast and efficient communication exchange and idle-handshaking with proxy-scanner (3)
.
Tools?
after many years doing this in large scale systems integration, the most efficient approach consists of a rapid prototyping development (2+3+4)
a python-2.x
is a reasonable option for doing this and ZeroMQ
or nanomsg
provide reasonably wide ported framework for (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>
more components means more places to implement error-recovery strategies
solution is ultimately dependent on the state of (2)
( implementing 1+1 source of updates possible )
finally, any tiny change in (2)
renders your processing line to stop and enforces your implementation to loop back to (2)
and re-starts re-engineering, re-implementation and re-testing steps again.