Ready-to-use examples for <b>FastNL</b>, the pure MQL5 economic calendar library: expert advisors, utility scripts and a small web viewer for the calendar data files.<br/>
Every example is a working starting point: copy the part you need into your own bot.
</p>
---
## Main Features
- **News filter EA**: a minimal bot skeleton that pauses trading a few seconds around every high/medium/low impact event, ready to receive your own strategy
- **News trader EA**: opens buy/sell positions when an event is released, using the expected market reaction of the event, with full risk management
- **Calendar scripts**: generate the calendar data files, translate event codes to ids, and inspect the history of any event
- **Calendar file viewer**: a static web page that opens the calendar event `.bin` files and shows the event info and its values table, without installing anything
### News filter: `FilterNewsEaSimple.mq5`
Creates the calendar, filters it by the chart symbol, subscribes all countries and draws the events on the chart. When an event is about to be released, `OnTickEvent` returns `true` once, so you can suspend your own logic for a few seconds:
// true only once, right when the "seconds before the event" are reached
if(g_calendar.OnTickEvent(time_curr))
suspended_time=time_curr+(seg_antes_despues*2);
if(time_curr>suspended_time)
{
// Your EA code
}
}
```
### News trader: `EAs\NewsTrader`
A strategy hooked to the calendar. When the events of the day are released, it asks the library for the theoretical movement of the event and opens a position in that direction:
```mql5
TSN::calendar.AddHook(&strategy);// the strategy receives the events
- **Event lists per currency**: USD, EUR, CAD, CHF, GBP, AUD, NZD and JPY, each one a comma-separated list of MQL5 calendar event codes you can edit
- **Take profit / stop loss**: by fixed points or by ATR multiplier
- **Risk management**: lot by risk per operation, maximum daily/weekly/total loss, maximum daily profit and a dynamic risk per operation (GMLPO), for personal accounts or prop firms
> Warning: These results were generated using OCHLM1 data on FTMO. Using real tick data yields similar, though slightly lower, results—but the issue isn't whether the system works; it’s the conditions required for it to function.
> Backtests simulate scenarios where the current value of an event—which is necessary for predicting the direction of the subsequent market move—is delivered within a few hundred milliseconds (the faster, the better). However, since this Expert Advisor (EA) relies on the MQL5 calendar, data delivery can take anywhere from 5 to 60+ seconds, or even days.
> Consequently, this EA will not perform well in a live environment and will likely open very few trades. For it to function effectively, it would require access to a low-latency, paid API capable of delivering current event data within a few hundred milliseconds—or even less—to allow for rapid reaction.
| `Generador Archivos CSV Calendario.mq5` | Generates the calendar data files from a start date (all importances by default) |
| `EventCodeToId.mq5` | Converts US MQL5 event codes (e.g. `producer-price-index-mm`) into their event ids, or prints the full info of an id when the input starts with `#` |
| `Test2.mq5` | Loads a list of events and prints their last value: actual, forecast, previous, impact, unit and country |
| `Test.mq5` | Experiment: computes the Kendall correlation between the recent values of the US events and a target event (US CPI m/m) |
├── EAs/ # Example bots (news filter and news trader)
├── Scripts/ # Calendar utility scripts and experiments
└── CalendarFormat/ # Web viewer for the calendar event files
```
---
## ⚠️ License Notice
A **FastNL license** is required to use these examples. Get it on [The Bot Place](https://www.thebotplace.com/bot/fast-newslibrary): the purchase gives you your **TBP user id**, which the examples need to initialize the calendar. Without a license the examples will not run.
---
## Requirements
See [dependencies.json](./dependencies.json) for the full list.
Requires the `tsndep` package, available on [PyPI](https://pypi.org/project/tsndep). It automatically downloads and installs all declared dependencies.
---
## Quick Start
You need your **TBP user id** first: it comes with the [FastNL license](https://www.thebotplace.com/bot/fast-newslibrary).
### Option A: ready-made bots (no compiling)
**1.** Download `NewsFilter` or `NewsTrader` from the [Releases](https://forge.mql5.io/nique_372/FastNLExamples/releases) page and copy the `.ex5` to `MQL5\Experts`.
**2.** Attach it to a chart and paste your TBP user id in the `InpTbpLicense` input.
### Option B: compile from source
**1. Enable the public mode:** at the top of `Src\EAs\FilterNewsEaSimple.mq5` (or `Src\EAs\NewsTrader\Bot.mq5`), before the includes, uncomment `PUBLIC_VERSION` and define `REPOSECRETS_MQH`, so the author's private `Secrets.mqh` is not included (you can also just delete that `#include`):
**2. Compile and run:** press `F7` in MetaEditor, attach the EA to a chart and paste your TBP user id in the `InpTbpLicense` input. The events appear on the chart and, around each event, `suspended_time` tells you when your own logic should wait.
2026-11-05 22:13:30 -05:00
**3. Scripts:** The scripts do not use InpTbpLicense; instead, they use your ID as specified via a `#define` directive (located in `TSN\ConfigTbpId.mqh`). Therefore, you only need to define `REPOSECRETS_MQH`.
Generate the calendar files first with `Generador Archivos CSV Calendario.mq5`, using the same start date as the EA input `fecha_desde_incio_noticias`.
---
## License
**[Read Full License](./LICENSE)**
By downloading or using this repository, you accept the license terms.