8 May 2021, 18:29

Hello, I was really missing newsfilter for backtesting EA.
So I figured out how to make a newsfilter for backtesting, the newsfilter is reading a csv file and plots the news in the backtester chart.

Link for the project: https://fxdreema.com/shared/iz0WMIVJd
Source code of the project: 0_1620495687291_Backtest newsfilter.mq4

A screenshot of how it looks like in backtester:

0_1620495768506_23d46e69-a16e-4b4b-a722-53ad92c9fa08-image.png

If you use the project share link and not import the source code, here's the Constants and variables to add in pictures below:

0_1620495952690_c2c8f4e9-9ad5-49d4-aa18-d6cfbbab501b-image.png
0_1620495982105_bba29520-cd03-4264-8ab7-c08aa6a9c1f8-image.png

Now you will need to download the news from FXStreet

First you choose the period for news, it looks like max period at time is 3 months. So if you want more than 3 months historical data then you will need to download all periods and merge it to a csv file.

0_1620496217515_8ed932f8-37d4-4f99-b3d6-83363113e042-image.png

After you choose period for news you will need to download the list, like in picture below:

0_1620496378577_4e31ea46-c94e-4e53-8d3d-893e11a8267a-image.png

After the newslist is downloaded, you will need to edit the list. I am using EmEditor for that.
Open your csv file in EmEditor (Ctrl-O)

File open in editor:
0_1620496538398_62398db9-19b8-48b6-a6a2-f93262c84571-image.png

First thing to do is to delete the first column, right click on the top of the first column and select delete column

0_1620496646476_5c985e75-4d99-4c89-bbb2-82186bbeab8e-image.png

Column deleted:

0_1620496690038_3447132f-2391-4125-8c35-36daf4cfc18d-image.png

Now we need to split the date and time column, rightclick on the Date time column and select "Split column"

0_1620496837474_6ed972d8-ac58-4648-a89e-196d5248c760-image.png

In the Split column window, make one space(spacrebar) in Seperator entry and click Ok button

0_1620496927984_035232c3-e8d6-44b0-9ded-2dd5cbf0b18a-image.png

The Date and Time(hours) is now splitted into 2 columns
0_1620497025247_1300eb46-9996-41f3-a641-f526fb9548a1-image.png

Next step is to convert the Date format so MT4 can use it, open replace window (Ctrl-H)
In the "Find" you write exactly this string: ([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})
In the "Replace with" you enter exactly this string: \3.\1.\2
Choose regular Expressions and click on "replace all" button.

0_1620497310748_e4adf126-e4e4-485e-8874-be2fe74836d6-image.png

The list now looks like this:
0_1620497363958_a21f2f4d-6746-4843-acf1-816d97294ea5-image.png

Now select all columns in the first row, then rightclick and select "Delete" from the dropdown menu.

0_1620497570961_de2fc6d7-1c41-4e37-9ca8-ab200af41b17-image.png

Ok! 🙂 The list is now finnished, you can now save it.

0_1620497622328_3112139f-1fe0-4ec9-a19d-40376dc8726f-image.png

You need to put the list(csv file) in your terminal ./tester/files/ folder

0_1620497951724_f4234cdc-7b26-474b-b897-6499652cc26c-image.png

In MT4 backtesting Expert properties remember to write in the file name for the file you just putted in the tester/files folder.

0_1620498068048_932eded1-5435-4a53-9aa0-a77148971700-image.png

That's it, I hope you enjoy my newsfilter for backtesting 🙂