I am trying to read a txt file and am not sure what the best way to do this in mql4 is. (I am not very familiar with mql4)
In mql5 I use the following method to read the txt file and use that data as a string variable called NewsFile within my program:
But in mql4 it seems that .txt files are not allowed as resources. I get the error: "unknown resource type" when compiling.
Does someone know what the best method of reading a txt file and storing the data within it in a string type variable in mql4 is?
Thanks for your reply. I am using this function only to backtest. I have a news filter that uses webrequest to get future data. I want to include the txt file in order to backtest a strategy that only operates around high impact news releases. And I want the txt file to be included in the compiled ex4 file, without the need of the user to store the txt file on their computer.
Thanks for your reply. I am using this function only to backtest. I have a news filter that uses webrequest to get future data. I want to include the txt file in order to backtest a strategy that only operates around high impact news releases. And I want the txt file to be included in the compiled ex4 file, without the need of the user to store the txt file on their computer.
Ok, will try to do that. One more question: If I write the entire file with the date and time of high impact news as a string, what will be the best way to write this without having to write it all in one line. The format of the news release data is:
2022.11.24,15:30
2022.11.25,12:00
2022.11.25,14:00
So the date and time is separated by a ",", and each news event is on its own line.
As far as I know, a string variable has to be defined in a single line of text. However, It will be pretty bothersome if I have to write it all in one line, and separate the events with a delimiter, like ";" or "|". For example, like this:
string NewsData = "2022.11.24,15:30|2022.11.25,12:00|2022.11.25,14:00";
The txt file with news events is pretty large, so writing all the events in a single line will be very messy.
If you have any suggestions how to create the string type variable so that I can keep each line in its own row would be much appreciated.
Thanks again for your help!
Ok, will try to do that. One more question: If I write the entire file with the date and time of high impact news as a string, what will be the best way to write this without having to write it all in one line. The format of the news release data is:
2022.11.24,15:30
2022.11.25,12:00
2022.11.25,14:00
So the date and time is separated by a ",", and each news event is on its own line.
As far as I know, a string variable has to be defined in a single line of text. However, It will be pretty bothersome if I have to write it all in one line, and separate the events with a delimiter, like ";" or "|". For example, like this:
string NewsData = "2022.11.24,15:30|2022.11.25,12:00|2022.11.25,14:00";
The txt file with news events is pretty large, so writing all the events in a single line will be very messy.
If you have any suggestions how to create the string type variable so that I can keep each line in its own row would be much appreciated.
Thanks again for your help!
string var = ""
+ ""
+ "";
string var = "";
var += "";
var += "";
var += "";
var+= "Line 1\n";
var+= "Line 2\n";
Ok, will try to do that. One more question: If I write the entire file with the date and time of high impact news as a string, what will be the best way to write this without having to write it all in one line. The format of the news release data is:
You can use the built-in feature of MetaEditor to insert your file as an array of strings.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to read a txt file and am not sure what the best way to do this in mql4 is. (I am not very familiar with mql4)
In mql5 I use the following method to read the txt file and use that data as a string variable called NewsFile within my program:
But in mql4 it seems that .txt files are not allowed as resources. I get the error: "unknown resource type" when compiling.
Does someone know what the best method of reading a txt file and storing the data within it in a string type variable in mql4 is?