#property tester_file "events.csv"
int h = FileOpen("events.csv", FILE_READ|FILE_CSV|FILE_ANSI, ','); Also the Calendar* functions don't return anything in the tester anyway, so loading your own CSV is the right way to go.
Hi all!
I'm trying to deal with resource management and/or path resolution when consuming resources that are supposed to be shipped with the Expert Advisor or are supposed to be used during Backtesting. This is in the context of me writing my own Expert Advisor. Not someone elses.
For example: I have a CSV File of historical Economic Calendar Events that I want to consume and use since when I run try to use CalendarEvent lookups in backtests it refuses to consume the Countries, Events or Values I ask it to consume.
Any form of PATH lookups for files doesn't let me load something relative to the EA or from the EA Experts binary directory and only provides me the terminal directory.
This makes filtering for known blackswan events a little more difficult since I know I will want to take advantage of EC announcements to avoid unnecessary volatility. Unfortunately that's not possible it seems.
My asks are:
- Is there a way to ask for an EA Binary relative path on execution, not on compile to load a CSV file of my choice?
- Resources equally expects me to hardcode a full directory path rather than use a relative path if I so chose. Is there a better solution?
Alternative Approaches:
- Throwing the file as a resource into the resources directory away from my repository/project directory, which is annoying and clunky, especially for collaborative projects.
- Setting an Input field to paste the full path into, which is ugly and clunky in my opinion. If I can't bootstrap the project with minimal setup from a cloned project repository, I'm failing on-boarding and quick deployment, turnaround times and QA for a project. But maybe that is just my high standard.
Any help would be appreciated.
For a fixed historical CSV, Amul’s resource suggestion works. To keep the file alongside your source, we tested this layout inside MQL5\Experts :
MyEA\ MyEA.mq5 events.csv
Add this at the top of your EA:
#resource "events.csv" as string g_events_csv
The CSV contents are then available in g_events_csv for your code to parse. You don’t need FileOpen() to read the embedded data.
We checked this on build 6230: after compiling, we renamed the original CSV and ran the EX5 in the local Strategy Tester. It still printed the CSV contents correctly. So you only need to distribute the EX5.
Updating the embedded data means recompiling. One caveat: the same relative-path examples failed to compile outside the MQL5 folder in our test, so the layout above is the one we verified.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all!
I'm trying to deal with resource management and/or path resolution when consuming resources that are supposed to be shipped with the Expert Advisor or are supposed to be used during Backtesting. This is in the context of me writing my own Expert Advisor. Not someone elses.
For example: I have a CSV File of historical Economic Calendar Events that I want to consume and use since when I run try to use CalendarEvent lookups in backtests it refuses to consume the Countries, Events or Values I ask it to consume.
Any form of PATH lookups for files doesn't let me load something relative to the EA or from the EA Experts binary directory and only provides me the terminal directory.
This makes filtering for known blackswan events a little more difficult since I know I will want to take advantage of EC announcements to avoid unnecessary volatility. Unfortunately that's not possible it seems.
My asks are:
- Is there a way to ask for an EA Binary relative path on execution, not on compile to load a CSV file of my choice?
- Resources equally expects me to hardcode a full directory path rather than use a relative path if I so chose. Is there a better solution?
Alternative Approaches:
- Throwing the file as a resource into the resources directory away from my repository/project directory, which is annoying and clunky, especially for collaborative projects.
- Setting an Input field to paste the full path into, which is ugly and clunky in my opinion. If I can't bootstrap the project with minimal setup from a cloned project repository, I'm failing on-boarding and quick deployment, turnaround times and QA for a project. But maybe that is just my high standard.
Any help would be appreciated.