I've developed an include file that can be added to any EA that works on the shorter timeframes (eg 1M, 5M and 15M) to give them the opportunity to be out of the market during news events.
It has a detailed explanation of how it works included in the file, including the following suggestion on avoiding news:
#include NewsTrackerV1_0.mqh
string strNews;
datetime NewsTime;
// avoid buying if within 5 minutes of news event
if (MyBuySignal && !NewsEvent(5,strNews,NewsTime)) DoMyBuying();
// close all positions if within 5 minutes of news event
if (OpenOrders() && NewsEvent(5,strNews,NewsTime)) CloseOrDeleteAllOrders();
The NewsLoggerV1_0 EA that uses NewsTracker is also attached as another example. It creates records of news events and stores them in experts\files
Copy NewsTrackerV1_0.mqh to experts\include and don't compile
Copy NewsLoggerV1_0 files to experts
Copy NewsItems.csv to experts\files and update with news events as they become knownGreat job. Very usefull routines. Thank you.
Eli
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've developed an include file that can be added to any EA that works on the shorter timeframes (eg 1M, 5M and 15M) to give them the opportunity to be out of the market during news events.
It has a detailed explanation of how it works included in the file, including the following suggestion on avoiding news:
#include NewsTrackerV1_0.mqh
string strNews;
datetime NewsTime;
// avoid buying if within 5 minutes of news event
if (MyBuySignal && !NewsEvent(5,strNews,NewsTime)) DoMyBuying();
// close all positions if within 5 minutes of news event
if (OpenOrders() && NewsEvent(5,strNews,NewsTime)) CloseOrDeleteAllOrders();
The NewsLoggerV1_0 EA that uses NewsTracker is also attached as another example. It creates records of news events and stores them in experts\files
Copy NewsTrackerV1_0.mqh to experts\include and don't compile
Copy NewsLoggerV1_0 files to experts
Copy NewsItems.csv to experts\files and update with news events as they become known