Importing CSV Data From TradingView or Other Sources Outside MT4

 

I have been writing and working with MT4 EAs and indicators for more than 10 years. But I am, at best, very unskilled. So, I'm not sure if I just need to be pointed in the right direction or whether I need to hire someone (tough to contemplate right now) to help with the following.

From time to time, I like to consider .csv data from other applications in my MT4 EAs or indicators. For example, I can generate .csv data from TradingView charts that I would like to import or include in an EA by (I assume) converting that .csv data into a MQL4 array or one or more variables. I don't know how to do this. the .csv data from the third-party source (whether TradingView or otherwise) is downloaded to my machine and arrives in my machine's Download file. I don't know how I can access that data from my MT4 coding to run it through a "for" or "while" loop. I don't even know if this is possible, but if it is and there is a a way that I could read articles or documentation to figure this out, I would greatly appreciate someone pointing me in the right direction. If this is possible but requires a more expert hand, then it would be helpful if I could be directed to someone who could help code this process. If this is impossible, then that would be good to know, and I could stop wasting my time thinking about it.

The end product that I am attempting to create is the coding for (likely) a "for" loop to access .csv data in the "Download" file in my computer. Most commonly, the .csv data is the OHLC data, line by line, for each time period, e.g., M01, M05, etc.

Thanks.

 
NassauPrecepts:

I have been writing and working with MT4 EAs and indicators for more than 10 years. But I am, at best, very unskilled. So, I'm not sure if I just need to be pointed in the right direction or whether I need to hire someone (tough to contemplate right now) to help with the following.

From time to time, I like to consider .csv data from other applications in my MT4 EAs or indicators. For example, I can generate .csv data from TradingView charts that I would like to import or include in an EA by (I assume) converting that .csv data into a MQL4 array or one or more variables.

I don't know how to do this. the .csv data from the third-party source (whether TradingView or otherwise) is downloaded to my machine and arrives in my machine's Download file.

I don't know how I can access that data from my MT4 coding to run it through a "for" or "while" loop. I don't even know if this is possible, but if it is and there is a a way that I could read articles or documentation to figure this out, I would greatly appreciate someone pointing me in the right direction. If this is possible but requires a more expert hand, then it would be helpful if I could be directed to someone who could help code this process. If this is impossible, then that would be good to know, and I could stop wasting my time thinking about it.

The end product that I am attempting to create is the coding for (likely) a "for" loop to access .csv data in the "Download" file in my computer. Most commonly, the .csv data is the OHLC data, line by line, for each time period, e.g., M01, M05, etc.

Thanks.

WebRequest - download the CSV (assuming they have a direct link to a CSV file). Or you can skip this step if you want to manually download the file then place it in the MQL4/Files directory.

FileOpen - Open the file and loop through its contents using while(!FileIsEnding). Here's a list of all the file functions in MT4

Structures - since the information has data that shares a relationship, create a struct with member variables for the types of information in the CSV file, then store the data in a struct object (or, more specifically, an array of struct objects).

In your situation, it would probably look like this:

struct SBar
  {
   string symbol;
   int period;
   double open;
   double high;
   double low;
   double close;
   datetime time;
  };

The above links include documentation and examples, so be sure to go through it. If you get stuck on one particular issue or have a question, feel free to ask.

WebRequest - Common Functions - MQL4 Reference
WebRequest - Common Functions - MQL4 Reference
  • docs.mql4.com
WebRequest - Common Functions - MQL4 Reference