News Calendar Storage and Filtering for Backtesting and Live

MQL5 专家

指定

Objective

Develop an MQL5 Expert Advisor (EA) that:

1. Saves historical economic news data** from MetaTrader’s economic calendar into a `.csv` file for backtesting purposes.

2. Implements news event filtering** for both backtesting and live trading, based on user-defined parameters such as event impact level, currency, and pre/post event trade restrictions.

Scope of Work

The EA must perform the following tasks:

1. Historical News Data Retrieval and Storage:

   - Retrieve news events from MetaTrader’s built-in calendar, with user-defined filtering options for the news data to be saved (date range, importance level, and currency).

   - Save this data to a `.csv` file in the `MQL5/Files` directory.

   2. Live Trading News Event Filter:

   - Apply news event filters in live trading based on the MetaTrader calendar to prevent trading before and after high-impact news events.

   - Users should be able to customize the impact level, currencies, and the pre/post news window for the filter.

3. Backtesting with News Event Filter:

   - During backtesting, read the saved news data from the `.csv` file and apply the same news event filters to simulate how the strategy would perform under real-time news conditions

Functional Requirements

1. User Input Parameters

The EA should allow users to customize the following parameters:

1. News Data Retrieval Inputs:

   - StartYear** (`int`): The starting year for retrieving historical news data.

   - EndYear** (`int`): The ending year for retrieving historical news data.

   - Currencies*(`string`): A comma-separated list of currencies (e.g., `USD,EUR,GBP`) to filter which currencies' news data is saved.

   - ImportanceLevel (`enum`): A selection of impact levels (`High`, `Medium`, `Low`) for filtering news events during data retrieval.

   2. News Event Filter Inputs:

   - PreNewsFilterMinutes (`int`): The number of minutes before a news event during which trading should be restricted.

   - PostNewsFilterMinutes(`int`): The number of minutes after a news event during which trading should be restricted.

   - FilterCurrencies (`string`): Currencies to be filtered during live trading and backtesting (comma-separated, e.g., `USD,EUR`).

   - FilterImportance (`enum`): The impact level for news filtering (`High`, `Medium`, `Low`).

   3. File Name for Saving/Loading News Data:

   - CsvFileName (`string`): Name of the `.csv` file where news data is saved and from which it is read during backtesting.

2. News Data Retrieval and CSV File Writing

The EA should retrieve historical economic calendar data from MetaTrader, filtered by the user inputs. Once the data is retrieved, it should be saved into a `.csv` file in the `MQL5/Files` directory.

Filtering Logic for News Data Retrieval:

- Retrieve the news data using the `CalendarValueHistory` function for historical events.

- Filter the data based on the user-selected currencies, importance level, and the date range defined by `StartYear` and `EndYear`.

  3. Reading News Data for Backtesting

During backtesting, the EA should read the news events from the previously saved `.csv` file. The news events should be filtered based on the user-defined parameters (`FilterCurrencies`, `FilterImportance`) and applied to the strategy to simulate how it would perform around news events.

 

Key Features for Backtesting:

- The same filtering logic used during live trading should be applied during backtesting.

- The strategy should prevent trading before and after news events based on the `PreNewsFilterMinutes` and `PostNewsFilterMinutes` inputs.

 

4. Live Trading News Event Filter

During live trading, the EA should use MetaTrader’s built-in calendar to filter out trades around news events. The filter should prevent trades from being opened within the specified time window before and after a news event.

 

Steps for Live News Event Filtering:

1. Retrieve Upcoming News Events:

   - Use MetaTrader’s `EconomicCalendarValue` function to get the upcoming news events.

   2. **Apply Filter to Trading Logic:

   - Prevent trades from being opened within the specified pre/post news time window.

   - Filter based on the currencies and importance levels selected by the user.

 

User-Defined Inputs for Live Trading Filter:

-Currencies to Filter: Users should specify which currencies are relevant for filtering.

- Importance Levels: The EA should only consider news events of the specified importance level (e.g., High).

 

5. Additional Considerations

1. Error Handling:

   - Ensure that the EA handles file read/write errors gracefully (e.g., if the `.csv` file is missing or cannot be opened).

   - Implement proper logging for debugging purposes.

2. Optimization:

   - Efficiently manage large news data files, particularly if retrieving several years' worth of news events.

3. Performance Monitoring:

   - Include detailed logging for when trades are skipped due to news events.

 

 


反馈

1
开发者 1
等级
(379)
项目
403
31%
仲裁
64
19% / 69%
逾期
51
13%
已载入
2
开发者 2
等级
(17)
项目
18
61%
仲裁
3
0% / 100%
逾期
1
6%
工作中
3
开发者 3
等级
(8)
项目
18
17%
仲裁
3
67% / 0%
逾期
0
空闲
4
开发者 4
等级
(81)
项目
98
44%
仲裁
4
50% / 50%
逾期
2
2%
空闲
5
开发者 5
等级
(9)
项目
13
23%
仲裁
1
0% / 0%
逾期
0
空闲
6
开发者 6
等级
(1)
项目
1
0%
仲裁
0
逾期
0
空闲
7
开发者 7
等级
(63)
项目
197
73%
仲裁
4
100% / 0%
逾期
1
1%
工作中
8
开发者 8
等级
项目
1
0%
仲裁
0
逾期
1
100%
工作中
相似订单
Hi Auto trading robot in mt4 need to be develop simple price action strategy i can pay 30 usd for this interested coder can ask for more details then i can share strategy details who is ready to do it
i am looking for experienced programmers who can help me out make my expert with zero lags and run smoothly and develop it in any possible way that make the accuracy way higher i need in addition to make this expert advisor linked on mt4 and mt5 also link the ea to WhatsApp and telegram bot where it giveS signals of the expert on it
Mr fano 30+ USD
I want a robot that will teach me how to be a good Forex trader, teach me the necessary requirements,and also teach me how the save. And a robot that will understand my needs and support me when I'm lost or don't understand a certain thing.. The robot should have good trading skills. Thank you
I need help with this, Hi i want a bot that will send orders to efood delivery app If you have experience about message to get started immediately pls i need it urgent
I have multiple fx accounts with a couple of brokers and I use myfxbook to monitor daily/weekly/monthly profits of these accounts. I would like view all the accounts Daily/Weekly/Monthly profits on a single page which is not possible with myfxbook currently. If someone can code an EA (or an API) to send these details to a Web Request, I can code on the client side to display them. Details I would like to get: -
Hi I need a simple dashboard for manual trading. must be an EA and must work in the strategy tester but also on live/demo account and must allow me to open/close/partially close. required elements: instruments (A & B) lot size to open for each instrument ticket identification for the orders to amend (whatever is required to identify precisely the order to amend). open/close Close can be full or partial If partial the
Tenho um EA que preciso: Desde correções como conectar filtros existentes à lógica já inserida no sistema. insira novos filtros no ea com nova lógica e conecte-se com a lógica existente. Há várias pequenas tarefas a serem concluídas, gosto de fazê-las em partes para que haja uma avaliação adequada e depois passar para a próxima etapa. ea contém +6k linhas de código e está em português. Embora eu não entenda de
Fellow devs, I need help converting a futures trading bot from python into MQL5. Code base for the bot already exists, backtests in python look good, however I need to be able to backtest it on tick data with MT5. Would appreciate someone who has experience with futures bots specifically, and even better if you have experience with AMP brokers, and can provide guidance and improvement criteria. A point you note, I
I wanna earn money in the right way on meta 5 trader, i wanna trade to make profit through my incomes and investing a lot of money on meta 5 trader. I already know how to trade on meta 5 trader because i got a demo account on meta 5 trader then now i wanna make real money on meta 5 trader, im ready to invest my money on meta 5 trader to make more profitable investments. Meta 5 trader is a great app to open a real
I have just installed a Script which is running on MT4 and MT5 on Mac . The script was made for me by an MQL5 community programmer. The script creates a .csv of the Account History to folder location: users/drive_c/metatrader64/crossover/ApplicationData/MetaQuotes/Terminal/Common/Files/Accounts History I have the following problem: The Scripts require that I manually activate them every time I open MT4 and MT5

项目信息

预算
50+ USD
截止日期
 1  5 天

客户

所下订单1
仲裁计数0