Discussing the article: "MQL5 Wizard Techniques you should know (Part 21): Testing with Economic Calendar Data"

 

Check out the new article: MQL5 Wizard Techniques you should know (Part 21): Testing with Economic Calendar Data.

Economic Calendar Data is not available for testing with Expert Advisors within Strategy Tester, by default. We look at how Databases could help in providing a work around this limitation. So, for this article we explore how SQLite databases can be used to archive Economic Calendar news such that wizard assembled Expert Advisors can use this to generate trade signals.

Economic Data can be the source of a trading edge or advantage in a trading system since it leans more towards the ‘fundamentals’ of securities as opposed to the ‘technicals’ that are more prevalent in the form of traditional indicators, custom-indicators, and other price action tools. These ‘fundamentals’ can take on the form of inflation rates, central bank interest rates, unemployment rates, productivity data, and a slew of other news data points that typically have a high impact on security prices as evidenced with their volatility whenever there is a release. The most famous of these probably could be the non-farm-payroll that are released on almost every first Friday of the month. In addition, there most certainly are other key news data points that do not get their requisite spotlight and are thus overlooked by most traders which is why testing strategies based on these Economic News Data points could help uncover some of these and therefore deliver an edge(s) to the prospecting trader.


SQLite databases can be created within the MetaEditor IDE and since they are data repositories, on paper, we should be able to use these as a data source to an Expert Advisor such that they act as indicator buffers. More than this though they can store the economic data locally, that can easily allow for offline testing and also use in the event that the news data source gets corrupted for unknown reasons, which is an ongoing risk as some (or inevitably most) data points get old. So, for this article we explore how SQLite databases can be used to archive Economic Calendar news such that wizard assembled Expert Advisors can use this to generate trade signals.

Author: Stephen Njuki

 

Caching the built-in economic calendar for testing and optimizing EAs was described in the algotrading book.

Your implementation of Read-ing events (CSignalEconData::Read) is inefficient and hardly practical.

PS. For working with SQLite from the tester, one should create/place the database into the common folder and open it with DATABASE_OPEN_COMMON flag.

MQL5 Book: Advanced language tools / Economic calendar / Transferring calendar database to tester
MQL5 Book: Advanced language tools / Economic calendar / Transferring calendar database to tester
  • www.mql5.com
The calendar is available for MQL programs only online, and therefore testing news trading strategies poses some difficulties. One of the solutions...
 
Stanislav Korotky #:

Your implementation of reading events (CSignalEconData::Read) is inefficient and hardly useful.

What is hidden under this phrase? How is efficiency measured?

 
Aleksey Vyazmikin #:

What is hidden under this phrase? How is efficiency measured?

The search of specific datetime is implemented via a straightforward loop through entire array of events on every call, which will load CPU in geometric progression. Moreover, on each iteration StringToTime and StringToDouble are called.

During a test with a year or more of thousands of economic events it will slow down significantly, not to say about optimization.

 
Stanislav Korotky #:

The search for a specific date time is implemented through a direct loop through the entire array of events at each call, which loads the processor exponentially. In addition, StringToTime and StringToDouble are called at each iteration.

When testing a year or more of thousands of economic events this will slow down significantly, not to mention optimise.

Thanks for the clarification.