Updated 2025-Mar-05: Posted new versions 'v1.02' of P4L_News.mqh, and P4L_Download_News.mq4 (and identical .mq5).
Updated 2025-Mar-02: Posted new versions 'v1.01' of P4L_News.mqh, and P4L_Download_News.mq4 (and identical .mq5).
Thread's Target Audience: *Programmers* of various News indicators/EA's that download one-or-more of the FF weekly news files.
As of August 2024, ForexFactory now limits the downloading of *weekly* news file(s) to a maximum of 2 every 5 minutes (**subject to change), regardless of the file type chosen (.xml .json .ics .csv). The affected URLs are:
https://nfs.faireconomy.media/ff_calendar_thisweek.xml
https://nfs.faireconomy.media/ff_calendar_thisweek.json
https://nfs.faireconomy.media/ff_calendar_thisweek.ics
https://nfs.faireconomy.media/ff_calendar_thisweek.csv
When the limit is exceeded, instead of returning raw data, a "DOCTYPE html" content page appears that says:
"Request Denied"
"You've exceeded the limit for Calendar Export requests. Please wait five minutes before trying again."
"The Calendar export file is only updated once per hour. Requesting it more than that is unnecessary and can result in being blocked."
This is aper-computer per-IP/LAN (Local Area Network) limit. This new limit is due to growing explosive demand on the FF news server, exceeding 4 BILLION requests/month. To protect and maintain access to this free resource, it is now essential that news programs *coordinate* and *share* the downloading of the desired news file(s) to vastly reduce the server load!
The provided "#include <P4L_News.mqh>" program (compatible with both MT4 and MT5), along with the MT4 "P4L_Download_News.mq4" (and identical MT5 "P4L_Download_News.mq5") programs, demonstrate ONLY the *downloading* of ForexFactory weekly news file(s) for one or more of the 4 FF provided format types: .xml .json .ics .csv
The news file(s) are saved to the user's Common\Files\ folder normally found at:
C:\Users\___your_name___\AppData\Roaming\MetaQuotes\Terminal\Common\Files\
... with filenames: "ff_calendar_thisweek" + one of the 4 file type extensions.
(Easy Common folder access: In the *MetaEditor*, File menu->Open Common Data Folder)
Note: This is the same "Common" folder shared by both MT4 and MT5.
The indicator program and included functions DO NOT parse the data, nor display news on your chart!
This code is not intended for direct use by end-users of MT4/MT5!
The *point* of the indicator is provide -- TO OTHER MQL4/MQL5 PROGRAMMERS -- a demonstration of the include function "get_FF_news(...)" as defined in the "P4L_News.mqh" file.
Download the files and copy them as follows:
File menu->Open_Data_Folder => Navigate into MQL4 (or MQL5)
Copy the appropriate indicator into folder \MQL#\Indicators\
Copy the "P4L_News.mqh" into folder \MQL#\Include\
For MQL5 only: Copy "errordescription.mqh" into \MQL5\Include\
This file originally came from: https://www.mql5.com/en/code/79
... but line 82 is commented out because of undefined 'ERR_CHART_WRONG_TIMER_PARAMETER'
MQL4/MQL5 PROGRAMMERS of any news tools that download, parse, and display weekly news should use this new function to handle the *download* task, so that the downloaded file(s) can then be shared by ALL news tools. By not requesting any updates sooner than, say, 8hrs, or 60 minutes (or perhaps 30 minutes, but never less than 5 minutes), the multiple download requests can be coordinated to stay within the new ForexFactory weekly news download limits!
Every call of the function will check the age of the shared file. If too old, it attempts to download a fresh copy, and ONLY if successful, it will replace the existing shared file. If NOT too old, or if the download attempt fails, it will still return the previous saved news file, which is very likely reasonably acceptable as-is.
*NO DOUBT, programmers may well think my code is too verbose, too complicated, or too... whatever. But it is my attempt to solve the complexities of asynchronous requests for the news file(s), and to be as fault-tolerant as possible if any simultaneous collisions occur. What I can say it that it has been working flawlessly for me for several weeks.
The current status quo is mayhem! Many users add one or more weekly news indicators to several charts. Many users also run multiple copies of MT4 or MT5 at once. Consider that most such news indicators download a fresh copy of the weekly news file for every instance of each news indicator on all of those charts, for all of those MT4's or MT5's. They often re-download the news with every change of chart Period, and/or re-download with a short wait between downloads, sometimes every minute, or 5 minutes, or ... perhaps an hour (which is better), BUT is still too often when considering that all indicators are downloading independent of any schedule. A restart of MT4 or MT5 is likely to trigger every news indicator on every chart to download multiple fresh new copies. A few of the better written news indicators download only one-per-MT4/MT5, and some check the timestamp first. The best might download to the Common\Files folder.
However, if not coordinated and shared with any other news tools running, OR if too frequently downloaded, the new limit is still easily exceeded.
To solve this problem, there MUST be coordination and sharing of the downloaded file(s), and all news indicators that download the weekly FF data files should limit the frequency to a minimum of every 30 to 60 minutes, even better if 8 hrs. The function "get_FF_news(...)" handles all of that coordination, but it is essential to get all news indicators to adopt either this code, or use similar code that accomplishes the same goal, which is to download and share (in the Common\Files\ folder) one or more of the weekly news format files. (Using the same name, too!)
By the way, ForexFactory does not update the weekly files more than once-per-hour, and the number of actual changes per week is MUCH less often than that! The most common change is that the timestamp of when news was expected (especially if "tentative") is updated after the news event to reflect the actual event time. Occasionally, brand new news events are added; or sometimes news events are cancelled, or are removed simply because there was an error.
Note that the weekly news files do NOT contain the "actual" nor "revised" values for what was reported by a news event. It only lists the "forecast" and "previous" values. Therefore, it is really no big problem at all to use a weekly news file that is ~60 minutes old, even 8hrs old, or older!
===============================
The bigger picture:
We need a solution to the new FF limit! My code is only a "solution" if programmers incorporate my code (or similar) into their weekly news programs, to coordinate and share Common folder news file(s).
Another alternative would be for the user's computer to intercept the 4 specific URL's that retrieve the weekly news files, and to instead control the download frequency (to stay within the limit), and to then seamlessly provide the already-downloaded file to any program making the URL request. I do not yet know how to do this! If anyone would provide further information how, it would be most appreciated as an alternative -- and perhaps better -- solution!
UPDATE: This "man-in-the-middle" hypothetical 'solution' is probably disallowed by operating systems, and would be far too difficult for the typical user to implement and maintain. The BEST solution will be for new programs to 'play nice' with each other and use my code -- or equivalent -- that downloads and *shares* the file in the MT4/MT5 Common /Files/ folder!
===============================
The most recent attachments will always be here in post#1. Any alternatives shared by others will also be linked to from here!
NOTE: I've only provided code to *download* and share the weekly news file(s). By itself, this would not be useful to most MT4/MT5 users, because it does not display any news events on a chart. The target audience is MQL4/MQL5 experienced programmers.
Updated 2025-Mar-02: Posted new versions 'v1.01' of P4L_News.mqh, and P4L_Download_news.mq4 (and identical .mq5).
The new versions do a better job to download the fresh weekly news files (updated by FF every Sunday at 00:00 NewYork; my code downloads after UTC 06:00, which is either 01:00 EST or 02:00 EDT). Longer intervals between updates are better supported; default = 8hrs; the news files do not update very often, hourly at most and usually small changes, if any.
Updated 2025-Mar-05: Posted new versions 'v1.02' of P4L_News.mqh, and P4L_Download_news.mq4 (and identical .mq5).
FF just approved a request to provide four independent 2X-per-5minutes limits for each of the for file types, rather than just one combined limit!
The 'Download' indicators have a new var, 'runNoMoreOftenThanOncePer__seconds' (5), and minor performance improvements.
A typical download (rare) takes around 125ms per file type. The ticks in between (now skipped for a full 5 seconds) each take ~200 microseconds (very small).
Updated 2025-Mar-02: Posted new versions 'v1.01' of P4L_News.mqh, and P4L_Download_News.mq4 (and identical .mq5).
Thread's Target Audience: *Programmers* of various News indicators/EA's that download one-or-more of the FF weekly news files.
As of August 2024, ForexFactory now limits the downloading of *weekly* news file(s) to a maximum of 2 every 5 minutes (**subject to change), regardless of the file type chosen (.xml .json .ics .csv). The affected URLs are:
https://nfs.faireconomy.media/ff_calendar_thisweek.xml
https://nfs.faireconomy.media/ff_calendar_thisweek.json
https://nfs.faireconomy.media/ff_calendar_thisweek.ics
https://nfs.faireconomy.media/ff_calendar_thisweek.csv
When the limit is exceeded, instead of returning raw data, a "DOCTYPE html" content page appears that says:
"Request Denied"
"You've exceeded the limit for Calendar Export requests. Please wait five minutes before trying again."
"The Calendar export file is only updated once per hour. Requesting it more than that is unnecessary and can result in being blocked."
This is a
The provided "#include <P4L_News.mqh>" program (compatible with both MT4 and MT5), along with the MT4 "P4L_Download_News.mq4" (and identical MT5 "P4L_Download_News.mq5") programs, demonstrate ONLY the *downloading* of ForexFactory weekly news file(s) for one or more of the 4 FF provided format types: .xml .json .ics .csv
The news file(s) are saved to the user's Common\Files\ folder normally found at:
C:\Users\___your_name___\AppData\Roaming\MetaQuotes\Terminal\Common\Files\
... with filenames: "ff_calendar_thisweek" + one of the 4 file type extensions.
(Easy Common folder access: In the *MetaEditor*, File menu->Open Common Data Folder)
Note: This is the same "Common" folder shared by both MT4 and MT5.
The indicator program and included functions DO NOT parse the data, nor display news on your chart!
This code is not intended for direct use by end-users of MT4/MT5!
The *point* of the indicator is provide -- TO OTHER MQL4/MQL5 PROGRAMMERS -- a demonstration of the include function "get_FF_news(...)" as defined in the "P4L_News.mqh" file.
Download the files and copy them as follows:
File menu->Open_Data_Folder => Navigate into MQL4 (or MQL5)
Copy the appropriate indicator into folder \MQL#\Indicators\
Copy the "P4L_News.mqh" into folder \MQL#\Include\
For MQL5 only: Copy "errordescription.mqh" into \MQL5\Include\
This file originally came from: https://www.mql5.com/en/code/79
... but line 82 is commented out because of undefined 'ERR_CHART_WRONG_TIMER_PARAMETER'
MQL4/MQL5 PROGRAMMERS of any news tools that download, parse, and display weekly news should use this new function to handle the *download* task, so that the downloaded file(s) can then be shared by ALL news tools. By not requesting any updates sooner than, say, 8hrs, or 60 minutes (or perhaps 30 minutes, but never less than 5 minutes), the multiple download requests can be coordinated to stay within the new ForexFactory weekly news download limits!
Every call of the function will check the age of the shared file. If too old, it attempts to download a fresh copy, and ONLY if successful, it will replace the existing shared file. If NOT too old, or if the download attempt fails, it will still return the previous saved news file, which is very likely reasonably acceptable as-is.
*NO DOUBT, programmers may well think my code is too verbose, too complicated, or too... whatever. But it is my attempt to solve the complexities of asynchronous requests for the news file(s), and to be as fault-tolerant as possible if any simultaneous collisions occur. What I can say it that it has been working flawlessly for me for several weeks.
The current status quo is mayhem! Many users add one or more weekly news indicators to several charts. Many users also run multiple copies of MT4 or MT5 at once. Consider that most such news indicators download a fresh copy of the weekly news file for every instance of each news indicator on all of those charts, for all of those MT4's or MT5's. They often re-download the news with every change of chart Period, and/or re-download with a short wait between downloads, sometimes every minute, or 5 minutes, or ... perhaps an hour (which is better), BUT is still too often when considering that all indicators are downloading independent of any schedule. A restart of MT4 or MT5 is likely to trigger every news indicator on every chart to download multiple fresh new copies. A few of the better written news indicators download only one-per-MT4/MT5, and some check the timestamp first. The best might download to the Common\Files folder.
However, if not coordinated and shared with any other news tools running, OR if too frequently downloaded, the new limit is still easily exceeded.
To solve this problem, there MUST be coordination and sharing of the downloaded file(s), and all news indicators that download the weekly FF data files should limit the frequency to a minimum of every 30 to 60 minutes, even better if 8 hrs. The function "get_FF_news(...)" handles all of that coordination, but it is essential to get all news indicators to adopt either this code, or use similar code that accomplishes the same goal, which is to download and share (in the Common\Files\ folder) one or more of the weekly news format files. (Using the same name, too!)
By the way, ForexFactory does not update the weekly files more than once-per-hour, and the number of actual changes per week is MUCH less often than that! The most common change is that the timestamp of when news was expected (especially if "tentative") is updated after the news event to reflect the actual event time. Occasionally, brand new news events are added; or sometimes news events are cancelled, or are removed simply because there was an error.
Note that the weekly news files do NOT contain the "actual" nor "revised" values for what was reported by a news event. It only lists the "forecast" and "previous" values. Therefore, it is really no big problem at all to use a weekly news file that is ~60 minutes old, even 8hrs old, or older!
===============================
The bigger picture:
We need a solution to the new FF limit! My code is only a "solution" if programmers incorporate my code (or similar) into their weekly news programs, to coordinate and share Common folder news file(s).
Another alternative would be for the user's computer to intercept the 4 specific URL's that retrieve the weekly news files, and to instead control the download frequency (to stay within the limit), and to then seamlessly provide the already-downloaded file to any program making the URL request. I do not yet know how to do this! If anyone would provide further information how, it would be most appreciated as an alternative -- and perhaps better -- solution!
UPDATE: This "man-in-the-middle" hypothetical 'solution' is probably disallowed by operating systems, and would be far too difficult for the typical user to implement and maintain. The BEST solution will be for new programs to 'play nice' with each other and use my code -- or equivalent -- that downloads and *shares* the file in the MT4/MT5 Common /Files/ folder!
===============================
The most recent attachments will always be here in post#1. Any alternatives shared by others will also be linked to from here!
NOTE: I've only provided code to *download* and share the weekly news file(s). By itself, this would not be useful to most MT4/MT5 users, because it does not display any news events on a chart. The target audience is MQL4/MQL5 experienced programmers.
Updated 2025-Mar-02: Posted new versions 'v1.01' of P4L_News.mqh, and P4L_Download_news.mq4 (and identical .mq5).
The new versions do a better job to download the fresh weekly news files (updated by FF every Sunday at 00:00 NewYork; my code downloads after UTC 06:00, which is either 01:00 EST or 02:00 EDT). Longer intervals between updates are better supported; default = 8hrs; the news files do not update very often, hourly at most and usually small changes, if any.
Updated 2025-Mar-05: Posted new versions 'v1.02' of P4L_News.mqh, and P4L_Download_news.mq4 (and identical .mq5).
FF just approved a request to provide four independent 2X-per-5minutes limits for each of the for file types, rather than just one combined limit!
The 'Download' indicators have a new var, 'runNoMoreOftenThanOncePer__seconds' (5), and minor performance improvements.
A typical download (rare) takes around 125ms per file type. The ticks in between (now skipped for a full 5 seconds) each take ~200 microseconds (very small).
Attached File(s)