Date,Time,Time Zone,Currency,Event,Importance,Actual,Forecast,Previous
Really thanks for the hint, I've corrected it.
int handle = FileOpen("Calendar.csv",FILE_READ|FILE_CSV,',');
Although, at this moment still the same issue occurs, is there anything else I am doing wrong?
For clearance, the 'issue', is that the values that should be read and appear as text on the label object still do not appear. From that I suspect they are not selected correct.
Edit: Now I am rushing a bit too much, I believe my FindString function is wrong, since when I remove the 'while' condition, the correct variables appear on my chart.
while(StringFind(NewsEvent,Event,0)==false)
What does StringFind return?
-1: Substring not found. But I really do not get why it does not recognises it. Is there a possibility you could provide me with another hint?
Edit: Of course, I've got it! Thanks for the informative and educative course :)
Hi, Maarten91
If you haven't solved your problem yet I think I can offer some insight. What I think is wrong with your use of the StringFind function is that NewsEvent and Event don't have any values. StringFind directs the search to look for the second string within the first string and the position in the first string that you want to start the search at. Neither string you're passing has a value yet so there's nothing for it to find and nothing for it to search. Also, all StringFind will tell you is the position in the first string the the second string starts at. That's not at all what you want. Try something like this:
if (FileIsEnding(handle)==false) // Make sure there's data to read { int i = 0; // Array indexer string arrNewsData[9]; // Declare a string array to hold all the News Event items in the current line in the file while (FileLineIsEnding(handle)==false) // Spin through the current line to get the items, quit when you've reached the end of the line { arrNewsData[i] = FileReadString(handle); // Read the item string from the file line(the delimiter you specified earlier makes sure you're only getting one item at a time), // set the current array item to the news item i++; // Increment the array index so that the next item is placed in the correct position in the array } }
If I understand the way MQL does things correctly, this should give you the info you're looking for. You can then use the array items to set the text in your objects. Arrays are 0 based, so the first item in the array would be arrNewsData[0] and would hold the Date string, the second would be arrNewsData[1] and would hold the NewsTime string, etc. When setting the Time label text, for example, you would replace NewsDate with arrNewsData[0], NewsTime with arrNewsData[1] and NewsTimeZone with arrNewsData[2]. You can set all the news item text for the objects using the array - just be sure you use the correct array index for the correct news item. Again, remember that arrays are zero based so for your 9 element array, the indexes would run from 0 - 8 NOT 1 - 9. Hope this makes sense and helps. :-)
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
Done, Raptor. Thanks for the heads up. Being as I'm relatively new to the forum, is there a "rules" thread I can go through to make sure that I'm not violating forum etiquette? I do see the directions below the comment box. I didn't notice them when I was posting earlier.
Done, Raptor. Thanks for the heads up. Being as I'm relatively new to the forum, is there a "rules" thread I can go through to make sure that I'm not violating forum etiquette? I do see the directions below the comment box. I didn't notice them when I was posting earlier.
No rules thread as such, there are the Forum rules when you registered . . . https://www.mql5.com/en/users/register
Just read a few pages of past posts and you will get the gist of what is appreciated and what is not . . .
No rules thread as such, there are the Forum rules when you registered . . . https://www.mql5.com/en/users/register
Just read a few pages of past posts and you will get the gist of what is appreciated and what is not . . .
Just read the directives on the registration page. Don't be a scammer, spammer or a butthole to other members and pay attention to what mods and admin tell you. Makes perfect sense to me. Glad to be here and I look forward to getting to know everybody. I hope I'll turn out to be a valuable contributing member.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello all,
Currently I am trying to make an EA which suppose to make my life a bit easier. In the end it should be able to automatically import an Economic Calendar. At the EA initalisation I specifie the Buy and Sell thresholds. So Manual analysis has been made, and if Indicator XXX comes out <=2.1% it should sell, if the indicator comes out >= 2.4% it should send a buy order. Also I want the data retrieved from the calendar plotted on the chart.
I started out this morning, and at this moment I am really struggling with reading the file. This is what I would like to have working first, before starting with automatically downloading. Also, I must say that I was -until today - unfamiliar with File functions, so don't go to hard on me please :)
A question on which I could not found the answer. Data in the Calendar.csv is presented in this format:
While using the FileReadString() function to read the data, how does this work? I thought that every FileReadString() function reads a variable, so that we need to have 8( Date, Time, TimeZone, Currency, Event, Importance, Actual, Forecast, and Previous) variables to store them in? After copying those 8 values, it goes to the next 8 variables(which is the next line).
At initalisation I must fill in keywords that able the StringFind() function to stop when the correct order is selected.
Am I correct in this thought process or does it not work this way?
Relevant code (Every GetLastError() function returns 0. Also, the Calendar.csv is been put in manually for now, so it really is there and it is read)
Also added is the document as a whole. But, it is not closed to finish yet, but everything to make this part work should be in it!
Any help would be greatly appreciated,
Regards,
Maarten