Script to download 1M currency data ?

 

Does anyone know of a more efficient way to grab 1M currency data via an EA script? This is what I am currently doing, but I was looking for something more clever...

int outputCurrencyData(int handle1, string currencyPair, int days=1) {
        if(handle1 < 0) return (-1);
        datetime currentTime, startingTime = TimeCurrent();
        int shift;
        double open, high, low, close, volume;
        FileWrite(handle1, "Current Time", "Open[0]", "High[0]", "Low[0]", "Close[0]", "Volume[0]");
        for(int i=0; i < 60*24*days; i++) {
                currentTime = startingTime - 60*i;
                shift = iBarShift(currencyPair, PERIOD_M1, currentTime, true);
                open = iOpen(currencyPair, PERIOD_M1, shift);
                high = iHigh(currencyPair, PERIOD_M1, shift);
                low = iLow(currencyPair, PERIOD_M1, shift);
                close = iClose(currencyPair, PERIOD_M1, shift);
                volume = iVolume(currencyPair, PERIOD_M1,shift);
                
                FileWrite(handle1, TimeToStr(currentTime, TIME_MINUTES),open, high, low, close, volume);
        }
        
        return(0);
}
 

Hi,

Isn't that code a part of a function to write data to somewhere out of MT4 say to CSV file or other format !!!

Ok, how about this code in this thread then:

https://www.mql5.com/en/forum/110015

Best wishes,

SF

 
yes, it shifts through the bars in reverse order and writes out each line in a CSV file. I assumed that this sort of thing would be standard, so there would be a more standardized approach.
 
vgoklani:
yes, it shifts through the bars in reverse order and writes out each line in a CSV file. I assumed that this sort of thing would be standard, so there would be a more standardized approach.


I believe you are right, but I have no idea how to do that. I guess I might think about it whenever I have free time.

Thanks for the useful info,

SF