fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Backtest newsfilter MT4 (Tutorial) (CSV)

    Tutorials by Users
    6
    9
    3676
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      padletut last edited by

      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 🙂

      Z 1 Reply Last reply Reply Quote 1
      • P
        padletut last edited by

        I forgot to delete the "Chart symbol for news" it's not in use, it reads the value from the chart. You can delete it.

        l'andorrà 1 Reply Last reply Reply Quote 0
        • l'andorrà
          l'andorrà @padletut last edited by

          @padletut Absolutely impressive! 😮 Thank you very much for sharing.

          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

          P 1 Reply Last reply Reply Quote 0
          • P
            padletut @l'andorrà last edited by

            @l-andorrà Thank you 🙂 Sharing is caring 🙂

            1 Reply Last reply Reply Quote 0
            • S
              skytrader last edited by skytrader

              thank you for sharing the script. pls note that your script will be failed for broker with several symbol like Gold, Silver. can modify your base_currency & quote_currency like this (in block "read news"):

              filehandle = FileOpen(filename,FILE_READ|FILE_CSV,',');
              base_currency = StringSubstr(Symbol(),0,3);
              quote_currency = StringSubstr(Symbol(),3,3);
              if(StringSubstr(Symbol(),0,4) == "GOLD"){
              base_currency = "XAU";
              quote_currency = "USD";
              }
              if(StringSubstr(Symbol(),0,6) == "SILVER"){
              base_currency = "XAG";
              quote_currency = "USD";
              }
              //base_currency = Symbol();
              Print("base_currency: ", base_currency, ", quote_currency: ", quote_currency, ", Symbol: ", Symbol() );

              l'andorrà 1 Reply Last reply Reply Quote 0
              • l'andorrà
                l'andorrà @skytrader last edited by

                @skytrader Thank you for sharing.

                (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                1 Reply Last reply Reply Quote 0
                • M
                  Markwigginton last edited by

                  I am using icefxnews indicator in live trading with my EA but I would like to be able to backtest in mt4 with a news filter being considered.. would this fix you mention above make this possible?

                  1 Reply Last reply Reply Quote 0
                  • Z
                    zac1987 @padletut last edited by

                    @padletut The backtesting process very slow because you check csv file on every tick. Is it posible to check csv file on every candle? let say i am using h1 chart, so it check csv file every 1 hour, in this case backtest speed will be faster alot.

                    1 Reply Last reply Reply Quote 0
                    • I
                      Indra_Pras last edited by

                      where can I put my block order ?

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post

                      Online Users

                      T
                      E
                      B
                      A
                      N
                      L
                      A
                      M

                      23
                      Online

                      146.6k
                      Users

                      22.4k
                      Topics

                      122.6k
                      Posts

                      Powered by NodeBB Forums | Contributors