
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Do not use this code. It is very poorly written. There is a good library https://www.mql5.com/ru/code/32430 here.
Hello Alain,
Unfortunately i got to the same conclusion. I am pretty new in MQL5 coding and very confused about all the curious error messages.
Meanwhile i have solved the error, mentioned in my post before. Nevertheless, when i am using the news.next Class. it doesnt show me the red line with the next upcoming news event (in the backtester mode)
Do you know something that works well? Or can you help me with this issue?
Thank You!
I am not sure why you think it's a good library ? In my opinion it's equally "poorly written".
Because it works, is flexible and fast.
Granted, saber has a style of coding not everybody likes. Personally i do not see any issues with the code.
Because it works, is flexible and fast.
Granted, saber has a style of coding not everybody likes. Personally i do not see any issues with the code.
Is this code correct?
int idx=news.next(0,"EUR",false,0); //will fetch next news from current time
datetime time = news.event[idx].time; //gets the time of the next news found above
int imp = news.event[idx].importance; // gets the importance of the next news found above
if(imp>=2 && (time-TimeTradeServer()>0 && time-TimeTradeServer()<=checknewsduration)) return true; //if news is importance medium and above, and is within nextnewsducartion(24), do not open new trades.
I am using the latest version of this code and I am getting an error that say Array out of range. I increases the size of the three array to 500000, and even larger numbers as suggested, but I still get that error. I am using the code below, which should plot the news as vertical lines...Any suggestion of how to fix this?
Anybody found a way to use a different calendar like from investing dot com? (w/o webscraping ofc)
This is regarding the "out of range" error many are encountering with the "News.mqh" file provided by Chris70.
Increasing the array size does not work.
As others have indicated, this error occurs at line 400, column 16 in "News.mqh" (see the attached file, "out_of_range_error.png")
This is basically an "off-by-one" error. On line 399, the code is looking for the last event where the time of the event is less than the current time GMT:
If that event happens to be at the end of the array, then the next line, line 400, will throw the error, as index hasn't been decremented and still equal to ArraySize(event):
Increasing the array size does nothing in this case, where index points to ArraySize(event), rather than ArraySize(event) - 1. (Remember array index counting is 0-based; the first element is located at index 0, the last element is located at ArraySize(myArray) - 1.)
FIX:
Update the while loop on line 400 with a check of the index against ArraySize(event), short-circuiting the rest of the condition if index is not less than ArraySize(event):
Next, on line 401, add a check to verify that index does equal ArraySize(event) and adjust the index to correctly point to the last element, remaining inside the bounds of the array. This will prevent the "out-of-range" error from cascading down into the subsequent lines where index is used to access various items in the event array:
Thank you for reading.
Cheers