
This blogpost presents some additional outcomes of experiments with information buying and selling primarily based on the built-in calendar of MetaTrader 5 and MQL5.
Initially, the concept was applied within the algotrading e book as a set of lessons for calendar caching and filtering, that permits for transferring the calendar information into the tester after which operating backtests and optimizations pushed by information.
The technology of calendar cache information (*.cal) and their replay within the tester was applied in indicator CalendarMonitorCached.mq5, which is now outmoded by its improved modification CalendarMonitorCachedTZ.mq5 accessible in the codebase. Principal enchancment is that the timestamps of occasions within the historical past saved within the cache can now be adjusted in line with (almost certainly modified in previous) timezones of the server. With out this correction occasions usually are not synchronized in historical past with corresponding bars, and because of this, information backtesting will not be correct. Please discover extra particulars on the web page for the indicator and likewise on the web page of the associated script CalendarCSVForDates.mq5.
Along with the lessons and indicator the e book accommodates the instance of skilled adviser CalendarTrading.mq5.
Let’s remind you, that the robotic selects solely vital occasions with quantitative metrics and opens trades in line with reported precise impression (optimistic/damaging).
It is higher to check it on a Foreign exchange main like EURUSD. With all settings by default you solely must specify the title of a cache file in CalendarFile enter. This file needs to be generated by CalendarMonitorCachedTZ.mq5 indicator after which manually copied into the widespread folder for all terminals. This fashion you do not have a must specify the file within the #property tester_file directive within the supply code of the robotic and recompile it (which should be repeated each time for an additional cache file).
Right here we publish a barely up to date model of the skilled adviser (with all dependencies within the supply code) and evaluate 2 backtests of it – with and with out corrections of occasions within the cache.
In different phrases, because the preparation for the analysis there have been generated 2 cache information: fastened.cal and unfixed.cal. To create any sort of those caches you want to present the title of the cal-file in CalendarCacheFile enter of CalendarMonitorCachedTZ indicator. For a cache with corrected occasions (fastened) it’s best to moreover fill in FixCachedTimesBySymbolHistory enter, the place you write an emblem with most dependable and full historical past – XAUUSD or EURUSD (or their analogues) are really useful. The underlying lib (TimeServerDaylighSavings) will empirically deduce actual timezone offsets on the historical past utilizing stats of opening hours of buying and selling weeks, and modify calendar occasions accordingly.
Listed below are the outcomes of exams on EURUSD,H1 for the interval 01.01.2022-11.11.2024.
Backtest buying and selling with unfixed calendar cache
Backtest buying and selling with fastened calendar cache
They each appear not so spectacular (what we’ll focus on beneath), however the fastened calendar cache labored slightly higher.
And listed below are the fragments of the logs displaying efficiency of trades made by particular occasion sort.
Unfixed cache log:
[event_id] [country] [currency] [money] [count] [pf] [name] [ 0] 840200001 "US" "USD" -113.90 140 0.64 "EIA Crude Oil Shares Change" [ 1] 840020008 "US" "USD" -43.71 27 0.26 "New Residence Gross sales" [ 2] 840180002 "US" "USD" -27.52 26 0.56 "CB Client Confidence Index" [ 3] 840120001 "US" "USD" -25.62 32 0.57 "Current Residence Gross sales" [ 4] 840030021 "US" "USD" -24.97 21 0.27 "JOLTS Job Openings" [ 5] 840010007 "US" "USD" -23.33 26 0.33 "GDP q/q" [ 6] 840190001 "US" "USD" -21.58 33 0.39 "ADP Nonfarm Employment Change" [ 7] 276010008 "DE" "EUR" -10.94 16 0.60 "GDP q/q" [ 8] 999030001 "EU" "EUR" -4.09 3 0.03 "Employment Change q/q" [ 9] 840040003 "US" "USD" 2.98 31 1.09 "ISM Non-Manufacturing PMI" [10] 840020010 "US" "USD" 4.20 32 1.09 "Retail Gross sales m/m" [11] 840020014 "US" "USD" 5.30 24 1.26 "Core Sturdy Items Orders m/m" [12] 840020005 "US" "USD" 5.61 33 1.12 "Constructing Permits" [13] 276070001 "DE" "EUR" 6.27 31 1.17 "ZEW Financial Sentiment Indicator" [14] 250010005 "FR" "EUR" 9.60 15 1.87 "GDP q/q" [15] 999030016 "EU" "EUR" 14.08 23 1.63 "GDP q/q" [16] 840120003 "US" "USD" 18.11 34 1.48 "Pending Residence Gross sales m/m" [17] 276030003 "DE" "EUR" 20.66 31 1.70 "Ifo Enterprise Local weather" [18] 840040001 "US" "USD" 25.79 25 1.86 "ISM Manufacturing PMI" [19] 840030016 "US" "USD" 36.52 35 1.77 "Nonfarm Payrolls" [20] 999030003 "EU" "EUR" 48.38 33 2.69 "Retail Gross sales m/m"
Fastened cache log:
[event_id] [country] [currency] [money] [count] [pf] [name] [ 0] 840200001 "US" "USD" -80.69 140 0.71 "EIA Crude Oil Shares Change" [ 1] 840180002 "US" "USD" -28.07 26 0.51 "CB Client Confidence Index" [ 2] 840120001 "US" "USD" -15.41 32 0.68 "Current Residence Gross sales" [ 3] 840020008 "US" "USD" -15.34 27 0.61 "New Residence Gross sales" [ 4] 840020014 "US" "USD" -11.95 24 0.63 "Core Sturdy Items Orders m/m" [ 5] 840030021 "US" "USD" -11.35 22 0.66 "JOLTS Job Openings" [ 6] 276010008 "DE" "EUR" -10.95 16 0.56 "GDP q/q" [ 7] 276070001 "DE" "EUR" -3.65 31 0.92 "ZEW Financial Sentiment Indicator" [ 8] 840120003 "US" "USD" -2.47 34 0.95 "Pending Residence Gross sales m/m" [ 9] 999030001 "EU" "EUR" -1.60 3 0.10 "Employment Change q/q" [10] 840040003 "US" "USD" 1.17 31 1.03 "ISM Non-Manufacturing PMI" [11] 999030003 "EU" "EUR" 1.28 33 1.03 "Retail Gross sales m/m" [12] 840190001 "US" "USD" 1.63 33 1.05 "ADP Nonfarm Employment Change" [13] 276030003 "DE" "EUR" 7.61 31 1.20 "Ifo Enterprise Local weather" [14] 840040001 "US" "USD" 13.72 24 1.41 "ISM Manufacturing PMI" [15] 840010007 "US" "USD" 14.21 26 1.48 "GDP q/q" [16] 250010005 "FR" "EUR" 18.40 15 3.93 "GDP q/q" [17] 840020010 "US" "USD" 19.25 32 1.52 "Retail Gross sales m/m" [18] 999030016 "EU" "EUR" 28.23 23 2.57 "GDP q/q" [19] 840020005 "US" "USD" 36.06 33 2.04 "Constructing Permits" [20] 840030016 "US" "USD" 49.50 35 2.21 "Nonfarm Payrolls"
The distribution of earnings/losses by occasion sort didn’t change so much and might verify roughly secure results (even when timing is inaccurate) for occasions that are usually thought of most impactful for the market, equivalent to NFPs, Retail gross sales, PMI. With corrected timing of occasions one can examine their affect on the historical past extra completely.
Now let’s speculate on why the outcomes are nonetheless not so good.
- The skilled adviser reads the sector “impact_type” crammed by the calendar supplier to acquire commerce indicators, however we do not understand how precisely this discipline is crammed. For instance, precise worth within the information document may be technically handled pretty much as good, however it may be worse than anticipated, which might produce damaging impact. There’s a variety of area to probe for higher buying and selling indicators technology using extra fields from the calendar.
- From the desk above it is apparent that tradable occasion varieties needs to be fastidiously chosen for every particular algorithm (for instance, volatility technique would give almost certainly totally different responces for these occasion varieties), and the default markings of significance usually are not enough.
- The skilled adviser doesn’t analyze market situations proper earlier than every occasion, and it is parameters weren’t in any means optimized.