-1

To work with the data and time series of the financial market in real time, most of the brokers that offer the platform metratrader allows the download of historical data of the pairs and indexes; This process is done manually to create a csv file. I need to automate this process to download the historical data of 96 markets every 10 days and no bibliography or information about it.

  • Why can't you use quantmod? or tidyquant? `tq_get("AAPL", get = "stock.prices", from = "2009-01-01", to = "2018-01-01")` or get the whole S&P500 `tq_index("sp500")` – user113156 Sep 30 '18 at 19:53
  • because I am working with fractal series so I need cadences per minute, for 5 minutes, for 15 minutes, for 30 minutes, for 60 minutes, 4 hours, 12 hours, 1 day, a week, etc. ..... and restrict them by the offer and asking of the market. I understand that with the quantity options of quantmod I can only opt for the closings and I do not have information of the commission agents. – Andres Felipe Estrada Rodrigue Sep 30 '18 at 20:19
  • This question lacks a data specification and a clear description of the expected output. – IRTFM Sep 30 '18 at 23:35

1 Answers1

1

If the question is how to organize the contact between MT4 and R, there are three general ways: 1. Use files, pipe channel as alternative. 2. REST, you need web server for that. 3. DLL( standard WinAPI, write DLL file, use websocket or contact broker). The latter might be the easiest way, try ZeroMQ. If you need to download some data from MT4, you should write a small script that will collect the data. Something like

bool getData(string symbol,int timeframe,int startFrom,string fileName)
{
  string message="";
  for(int i=startFrom;i>=0;i--)
  {
     message=message+StringFormat("%s;%.5f;%.5f;%.5f;%.5f",
        TimeToString(iTime(symbol,timeframe,i)),
        iOpen(symbol,timeframe,i),
        iHigh(symbol,timeframe,i),
        iLow(symbol,timeframe,i),
        iClose(symbol,timeframe,i));
  }
  int handle=FileOpen(fileName,FILE_READ|FILE_WRITE,FILE_CSV);
  if(handle==INVALID_HANDLE)return(false);
  FileSeek(CUR_END);
  FileWrite(message);
  FileClose(handle);
  return(true);
}
Daniel Kniaz
  • 4,338
  • 2
  • 11
  • 18