Download Retrieve high impact events from Forex Factory. com and display them in your indicator or Expert Advisor for MetaTrader 4

Retrieve high impact events from Forex Factory. com and display them in your indicator or Expert Advisor

Retrieve high impact events from Forex Factory. com and display them in your indicator or Expert Advisor

This software component for MetaTrader 4 is built to enhance the capabilities of your trading environment. This Expert Advisor serves as automated trading software. It is utilized to monitor financial markets and execute trades based on predefined algorithmic rules, enabling precise position management without the need for constant manual oversight.

MT4 expert Pack 📂

How to Setup and Use Retrieve high impact events from Forex Factory. com and display them in your indicator or Expert Advisor

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

Description & Settings


As I'm currently developing an Expert Advisor for Crude Oil and Brent, I wanted to get from ForexFactory.com the exact date and time of the 'Crude Oil Inventory' report. This report is typically issued on Wednesday's at 10:30am Eastern but when there's a holiday, the release date can change. As this is an important report for my EA, the only way was to check an online service to validate the release date.
Next is to define a structure in your code to store the events. This is placed somewhere at the top of your code which will declare 'DailyEvents' as a global variable with a maximum number of stored event defined by the 'MaxDailyEvents' variable.
Next we need to retrieve the HTML code from ForexFactory.com and parse it. If you don't understand HTML code, don't worry, I'll step you thru it :)
We first need to build the URL for the WebRequest. As I only wanted their calendar for the day and not the default (all week), we can do so by setting the 'day' parameter of the request to today's date and sending the request.
Then we send the request, check the error code (if any) and convert the returned character array to a string. This makes it easier to parse the HTML code.
If there's no error, we then convert the character array 'result' to an string for better parsing.
Now that we have a string, we can use the 'StringFind' function to locate HTML elements. The first thing is to make sure the returned HTML is indeed for today's date and cut anything before this HTML tag. The function 'GetHTMLElement' is used to parse the HTML code and return the value between the HTML tags specified. See below for it's definition.
Definition of the 'GetHTMLElement' function.
Ok, now that we've made sure the calendar returned is for today's date, let's start parsing each of the table row and extract the elements we need. Namely event time, event currency, event impact and event title. We need to do this for each table row there is in the HTML code until the end of the calendar or the MaxDailyEvents has been reached.
Once the data for each row has been extracted, we add it to the DailyEvents structure.
Once we have parsed all table rows and reached the end of the calendar, we need to display the events on the chart. If the event is in the future, I want a vertical line displayed and if in the past, no line.
If the events that are on the future, I want to notify the user of an upcoming in event if it's within 5 minutes of the current time and remove the vertical line. This is done by adding some code in your 'start()' function of the EA or indicator.
And finally, we need to get the daily events. This is done by adding a line in your OnInit() function.
Nice and simple. You can of course modify the code to display all events for the currency pair or add an input parameters to your indicator or EA to specify which impact to display (high, medium or low) and of course add a check for midnight turn around to get a new list of daily event, but I'll let you play with that :)
Cheers!
-Claude.

You May Also Like

RobotFX does not own any of the code provided on this platform. All tools are freely available on the internet; we simply index and re-offer them for download. We are not responsible for any financial losses that may occur. Trading responsibilities rely solely on the traders downloading and using the displayed Expert Advisors, indicators, and scripts. These tools are provided for educational purposes only and may require modification or optimization to align with a trader's specific strategy or needs.
© ROBOTFX - Best MetaTrader Expert Advisors & Indicators