I'm lookin for a solution, how to export currency exchange from metatrader (4 or 5) to web (json, csv, xml...)
I saw that it is possible export to excel file.
I'm lookin for a solution, how to export currency exchange from metatrader (4 or 5) to web (json, csv, xml...)
I saw that it is possible export to excel file.
MT4 can serve as anEventFACTORY
process and send live-Quote(s) aka "Tick(s)" to further processing, be it internal ( via a function call ) or external ( via a ZeroMQ or nanomsg communication framework )
MT4 has a default internal EventLOOP that triggers int start(){ <_code-block_> }
upon each Quote arrival in both Expert Advisor and Custom Indicator. Besides that a Script can handle Quote arrivals on it's own near-RT loop with a use of bool RefreshRates()
MT4 has rather a poor TimeDOMAIN resolution and can work down to about 1 msec via int GetTickCount()
MT4 cannot run more than one Expert Advisor + one Script + a few Custom Indicators per MT4.Graph
MT4 threading is rather a fragile fabric to build any high-workload software
MT4 code inside MQL4 can block the whole "receiving engine" of the MT4 ( not speaking about MT4.TradingCONTEXT
... , so be carefull and place reasonable void Sleep( int msecs2sleep )
where not in an RT-sensitive part of any code.
MT4 fileIO
blocks, avoid as much as possible and if pressed to, cache and deferr disk write(s) to situations, where you are sure to have 15-40 msec "free-time" to rest in a fileIO-blocked
<code-block> execution <state>. While this may seem funny on a first sight, this may hang your MT4
platform if you happen to arrange such "export" processing in a poor manner and MT4
threading model get beyond their MUTEX/LOCKs resilience treshold.
Yes.
Correct.
Try to use such an approach to use a thin-soft-RT-client inside MT4 and either cache-writes as MQL4 RT-scanners TAMARA & SONAR do, where you will see, that it soon takes several minutes (MINUTES) of a sustained-fileIO-write
-s to store just a few majors on localhost
disk ... , or better -- distribute locally collected data-chunks to a remote loggerPROCESS
( syslog alike ) or any other { online | offline } post-processing
You can create an EA to do that. I personally collect the rates (every tick) and push to an SQL server. Pushing to an SQL server is more tricky (I use a custom DLL to do that). But you can easily just append it to a csv or tab-delimited file. This will give you a tab-delimited file which you can import into Excel. But be warned that this can get really huge. Also, although there is a time element in there, the TimeCurrent()
is accurate to the second only. To get accuracy down to milisecond, you will need something more tricky. But the rates will be appended in sequence.
int start() {
logRates();
return(0);
}
void logRates( string pvsSymbol, double pviAsk, double pviBid ) {
string vsFilename = "Rates (" + Symbol() + ") " + Month() + "-" + Day() + ".txt";
int handle = FileOpen(vsFilename + ".txt", FILE_CSV|FILE_READ|FILE_WRITE, '\t');
if(handle>0) {
FileSeek(handle, 0, SEEK_END);
FileWrite(handle, TimeCurrent(), pvsSymbol, pviBid, pviAsk);
FileClose(handle);
}
}