Pipsgrowth EX16058 Trend
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX16058 News_Stopper_MT5 -- News event management tool that closes trades and halts auto-trading around high-impact news, full 12-layer stack.
Overview
Pipsgrowth EX16058 Trend is a specialized news management utility — not a signal generator. It attaches to an MT5 chart alongside any other EA and acts as a guard: when an economic-calendar event is about to strike, EX16058 closes the open positions on the affected pair, deletes pending orders, optionally stops the EA's auto-trading, and re-enables trading after the news shock has dissipated.
The mechanism is straightforward but layered. On initialization the EA fires a GET request to https://nfs.faireconomy.media/`ff_calendar_thisweek`.xml using MQL5's WebRequest(). The response is an XML feed of the week's economic events. EX16058 walks the block, pulls the , , , , and from every node, converts the date string to a datetime value, and stores the result in a 500-element news_event_struct array. Up to 500 events are kept in memory; the EA's EventSetTimer(news_update_hour*3600) schedules a re-fetch every 2 hours so the calendar stays current without spamming the network.
Before storing, each event runs through three filter functions. CurrencySelected() keeps only events whose currency appears in either the chart symbol (default) or a custom symbol list — default USD,EUR,GBP,JPY,CAD,CHF, set via the symbol_type and news_symbols inputs. TitleSelected() optionally narrows further to a comma-separated keyword list, which defaults to Non-Farm,Unemployment,ISM,PMI,CPI,FOMC,Retail Sales,Final GDP q/q,Core PCE Price Index m/m,Empire State Manufacturing Index,Advance GDP q/q,JOLTS — the dozen or so USD releases that reliably move XAUUSD. ImpactSelected() limits by severity, defaulting to high-impact only with include_medium and include_low both off. Any of these three filters can be widened: a trader running only USD pairs can leave the title list as-is and let the dozen named releases through; a multi-pair portfolio operator can disable the title filter entirely with use_title=false and let high-impact events for any of the six watched currencies trigger the lockdown.
Once the calendar is in memory, the per-tick logic in OnTick() runs two timing checks. BeforeNewsForZeroProfit() returns the affected currency if the current GMT time is between min_before_zero=60 minutes before the event and the event time itself. AtNews() returns the affected currency if the current GMT time is between min_before=5 minutes before the event and min_after=45 minutes after. These two windows are deliberately different in shape: the pre-window is wider (60 minutes) and is used for harvesting profits ahead of volatility, while the at-window is asymmetric (5 before, 45 after) and is used for full defensive lockdown while the market digests the release.
When the pre-window fires (and close_zero=true, default), EX16058 checks if ACCOUNT_PROFIT >= close_profit (default $1). If yes, it runs CloseAll(_pair) which iterates the position pool backwards, calls trade.PositionClose() on each ticket through the TryClose_EX16058() retry helper, and accepts either TRADE_RETCODE_DONE or TRADE_RETCODE_DONE_PARTIAL as success. The retry helper loops up to three times on TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF, or TRADE_RETCODE_PRICE_CHANGED, sleeping 200ms between attempts. If close_pending=true, DeleteAllPendings() follows — same loop, but with trade.OrderDelete(). The function OpenTrades(_pair) returns the count of remaining positions; if it is still >0, the EA sleeps 5 seconds (the delay input) and re-runs on the next tick. If close_only_news_pair=false (default), the pair string is "all" and the close sweep runs across the entire account.
When the at-window fires, the same close logic runs unconditionally (if close_open=true). If stop_algo=true (default), AlgoTradingStatus(false) is called. This is the only place EX16058 touches Windows: it pulls the chart's HWND via ChartGetInteger(ChartID(), CHART_WINDOW_HANDLE), walks up the parent chain with GetAncestor(hwnd, GA_ROOT), and posts WM_COMMAND with MT_WMCMD_EXPERTS to flip the Algo Trading button off. The next time AtNews() returns "No News" and the internal allow_trade flag is false, the function is called again with true, restoring the button. The Print(), SendNotification(), and Alert() calls fire one combined message ("[NEWS!] All trades are Closed. All pendings are Deleted. Auto trading is Disabled.") when the lockdown engages. Close_zero logic and the at-window logic are guarded by separate allow_trade flips, so the pre-news profit-take can fire independently of the at-news lockdown.
Visualization is on by default. DrawNews() runs on init and on every timer tick, walking the first 100 stored events and dropping a vertical line at each event time on the chart, color clrRed, style STYLE_DOT, width 1 (all configurable via Line_Color, Line_Style, Line_Width). Each line is hidden from selection (OBJPROP_SELECTABLE=false, OBJPROP_SELECTED=false, OBJPROP_HIDDEN=true) and lives in front of candles (OBJPROP_BACK=false). When the EA is removed, OnDeinit clears the chart comment and ObjectsDeleteAll(0) removes the lines.
A few details round out the build. slippage=5 is hardcoded as a global (no input), and the per-symbol filling mode is set via trade.SetTypeFillingBySymbol() before every close or delete to handle both IOC and FOK exchanges without manual configuration. MarketOpen() checks the symbol's session table via SymbolInfoSessionTrade() and returns false on weekends or outside the trading session, preventing close attempts when the book is frozen. TryClosePartial_EX16058() is wired but never called — dead code kept for symmetry with the other two retry helpers. Every order touched is tagged with the trade comment Psgrowth.com Expert_16058, which makes it trivial to filter post-trade analytics by which closes were news-driven versus manual.
Practical deployment requires two terminal settings. First, Tools → Options → Expert Advisors → Allow DLL imports must be checked, otherwise OnInit() aborts with a MessageBox. Second, the URL https://nfs.faireconomy.media/ must be added to the same tab's Allow WebRequest list — if it is not, the first WebRequest() returns error 4060 and OnInit() prompts the user with a popup naming the URL. Both are one-time setup steps that take under a minute.
The use case is narrow but well-defined: a discretionary or systematic trader who runs any EA on XAUUSD, EURUSD, GBPUSD, USDJPY, USDCAD, or USDCHF and wants a deterministic defense against the dozen-or-so USD data releases per month that routinely produce 20–50 point whipsaws against open positions. Backtest behavior is structural rather than statistical — there is no equity curve, no PnL attribution, no optimization surface to tune. The EA is either correctly fetching the calendar and clamping the windows, or it is not, and the chart's vertical red lines plus the Print() log are the only diagnostics.
Strategy Deep Dive
On every chart tick OnTick() runs two timing checks against the in-memory calendar. BeforeNewsForZeroProfit() activates the 60-minute pre-event window: if account profit is positive, CloseAll() exits open positions, DeleteAllPendings() clears orders, and SendNotification() plus Alert() notify the trader. AtNews() activates the tighter 5-minutes-before to 45-minutes-after window: it forces the same close and delete sequence, then AlgoTradingStatus(false) posts a Windows WM_COMMAND to disable the platform's auto-trading button. The EA re-enables algo trading the first tick after the window closes. DrawNews() runs on init and on a 2-hour timer to drop vertical red dotted lines on the chart at every relevant event time, and OnDeinit() removes them on shutdown.
EX16058 opens no trades of its own. The activation trigger is the entry into a news event's pre-window (min_before_zero=60 minutes before) or at-window (min_before=5 to min_after=45 minutes around the event). The trigger source is a fetched XML feed from https://nfs.faireconomy.media/, filtered in memory by currency (chart symbol or custom six-pair list), title keyword (a default list of twelve USD releases), and impact severity (high by default).
During the pre-news profit window, CloseAll() exits every open position on the affected pair (or the entire account if close_only_news_pair=false) when account profit reaches close_profit=1 USD, then DeleteAllPendings() removes pending orders. During the at-news window the close runs unconditionally, and AlgoTradingStatus(false) flips the platform's Algo Trading button off via Windows PostMessageW. The button is restored the first tick after AtNews() returns No News.
No per-trade stop loss is set. EX16058 does not open positions, so the relevant risk control is the global news lockdown: the EA's own window-driven close of every open position is the protective stop for whatever strategy is running on the same account.
No per-trade take profit is set. The profit-realization mechanism is the pre-news window itself: when ACCOUNT_PROFIT >= close_profit=1 USD inside the 60-minute pre-event window, every open trade is closed at market regardless of its individual TP level, locking in any equity above the one-dollar threshold before the news volatility.
Traders running any EA on XAUUSD, EURUSD, GBPUSD, USDJPY, USDCAD, or USDCHF who want a deterministic defense against the dozen-or-so high-impact USD releases per month. Minimum recommended balance is $100 (no trade sizing occurs in EX16058). The utility runs on M5 or H1, requires Allow DLL imports plus the URL https://nfs.faireconomy.media/ in the WebRequest allowlist, and pairs best with brokers offering tight spreads on metals and FX majors since EX16058 itself does not request quotes — it only consumes the existing position pool.
Strategy Logic
Pipsgrowth EX16058 Trend — Strategy Logic Analysis (from .mq5 source)
Family: Trend
Magic: 22216058
Version: 2.00
BRIEF:
News Stopper utility that fetches economic calendar data via HTTP, closes open trades and pending orders, and halts auto-trading around high-impact news events with configurable time windows and notification options. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
OnTimer()NewsUpdate()MakeDateTime()DrawNews()CurrencySelected()TitleSelected()ImpactSelected()AtNews()BeforeNewsForZeroProfit()CloseAll()DeleteAllPendings()OpenTrades()- ...and 6 more
INTERNAL CONSTANTS (1 total):
GA_ROOT= 2 // Enums
INPUT PARAMETERS (31 total across 1 groups):
- [=== Identity ===]
InpMagic=22216058//EAMagic Number - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_16058" // Trade comment - [=== Identity ===] info1 = " ------======<<[ News Management ]>>======------ " // ---=== News Settings ===---
- [=== Identity ===]
news_link= "https://nfs.faireconomy.media/" // --- NewsURL(to be placed in settings) - [=== Identity ===]
min_before= 5 // Minutes Before News to close - [=== Identity ===]
min_before_zero= 60 // Minutes Before News to close with zero profit - [=== Identity ===]
min_after= 45 // Minutes After News to halt - [=== Identity ===]
include_high=true// Include high - [=== Identity ===]
include_medium=false// Include medium - [=== Identity ===]
include_low=false// Include low - [=== Identity ===]
use_title=true// Filter News based on title - [=== Identity ===]
title_phrase= "Non-Farm,Unemployment,ISM,PMI,CPI,FOMC,Retail Sales,FinalGDPq/q,CorePCEPrice Index m/m,Empire State Manufacturing Index,AdvanceGDPq/q,JOLTS" // title keyword (comma seperated) - [=== Identity ===]
news_update_hour= 2 // Update time interval (in hours) - [=== Identity ===]
symbol_type= type1 // Currencies check method - [=== Identity ===]
news_symbols= "USD,EUR,GBP,JPY,CAD,CHF" // Custom Currencies to Check For News - [=== Identity ===]
close_only_news_pair=false// Only Close Orders of The Events Currency - [=== Identity ===]
draw_news_lines=true// Draw News Lines on chart - [=== Identity ===] Line_Color =
clrRed// Lines Color - [=== Identity ===] Line_Style =
STYLE_DOT// Lines Style - [=== Identity ===] Line_Width = 1 // Line Width
- [=== Identity ===] info2 = " ------======<<[ Order Management ]>>======------ " // ---=== Order Management ===---
- [=== Identity ===]
stop_algo=true// Stop Auto trading - [=== Identity ===]
close_open=true// Close all open trades - [=== Identity ===]
close_pending=true// Delete all Pending orders - [=== Identity ===]
close_zero=true// Close all trades with profit - [=== Identity ===]
close_profit= 1 // Profit for Closing all trades (in $) - [=== Identity ===]
close_charts=false// Close all Charts - [=== Identity ===] info3 = " ------======<<[ Settings ]>>======------ " // ---=== Settings ===---
- [=== Identity ===]
send_notif=true// Send notification - [=== Identity ===]
send_alert=true// SendAlert - [=== Identity ===] delay = 5 // Delay if somthing goes wrong (in seconds)
// Pipsgrowth EX16058 Trend — Execution Flow (from source analysis)
// Family: Trend
// News Stopper utility that fetches economic calendar data via HTTP, closes open trades and pending orders, and halts auto-trading around high-impact news events with configurable time windows and notification options. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
ON_INIT:
Create indicator handles: standard set
Initialize state variables
Detect broker GMT offset
ON_TICK:
1. Refresh indicator buffers (closed-bar shift=1)
2. Manage existing positions:
- Break-even check
- ATR trailing stop
- Profit lock ratchet
- Time-based exit
- Opposite-signal exit
3. If new bar:
a. ClassifyRegime() — ADX/ATR/BB regime detection
b. NoTradeGate() checks:
- Market open + session filter
- Spread limit
- Cooldown after loss
- Consecutive loss limit
- Kill switch
- Max drawdown
- Max concurrent positions
- Daily/weekly loss limits
c. GenerateSignal() — strategy-specific entry logic
d. CheckConfirm() — HTF alignment + R:R + ADX minimum
e. Calculate position size from risk %
f. Execute with retry logic
g. Mark bar to prevent duplicates
ON_TESTER:
Custom fitness = weighted(RecoveryFactor, ROI, ProfitFactor, TradeCount, Sharpe, Drawdown)Optimization Profile
How to Install This EA on MT5
- 1Download the .mq5 file using the button above
- 2Open MetaTrader 5 on your computer
- 3Click File → Open Data Folder in the top menu
- 4Navigate to MQL5 → Experts and paste the .mq5 file there
- 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
- 6Drag the EA onto an H4 or Daily chart for best results
- 7Configure EMA periods, ADX threshold, and lot size in the dialog
- 8Enable Allow Algo Trading and click OK
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpMagic | 22216058 | EA Magic Number |
| InpTradeComment | "Psgrowth.com Expert_16058" | Trade comment |
| info1 | " ------======<<[ News Management ]>>======------ " | ---=== News Settings ===--- |
| news_link | "https://nfs.faireconomy.media/" | --- News URL (to be placed in settings) |
| min_before | 5 | Minutes Before News to close |
| min_before_zero | 60 | Minutes Before News to close with zero profit |
| min_after | 45 | Minutes After News to halt |
| include_high | true | Include high |
| include_medium | false | Include medium |
| include_low | false | Include low |
| use_title | true | Filter News based on title |
| title_phrase | "Non-Farm,Unemployment,ISM,PMI,CPI,FOMC,Retail Sales,Final GDP q/q,Core PCE Price Index m/m,Empire State Manufacturing Index,Advance GDP q/q,JOLTS" | title keyword (comma seperated) |
| news_update_hour | 2 | Update time interval (in hours) |
| symbol_type | type1 | Currencies check method |
| news_symbols | "USD,EUR,GBP,JPY,CAD,CHF" | Custom Currencies to Check For News |
| close_only_news_pair | false | Only Close Orders of The Events Currency |
| draw_news_lines | true | Draw News Lines on chart |
| Line_Color | clrRed | Lines Color |
| Line_Style | STYLE_DOT | Lines Style |
| Line_Width | 1 | Line Width |
| info2 | " ------======<<[ Order Management ]>>======------ " | ---=== Order Management ===--- |
| stop_algo | true | Stop Auto trading |
| close_open | true | Close all open trades |
| close_pending | true | Delete all Pending orders |
| close_zero | true | Close all trades with profit |
| close_profit | 1 | Profit for Closing all trades (in $) |
| close_charts | false | Close all Charts |
| info3 | " ------======<<[ Settings ]>>======------ " | ---=== Settings ===--- |
| send_notif | true | Send notification |
| send_alert | true | Send Alert |
| delay | 5 | Delay if somthing goes wrong (in seconds) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX16058 News_Stopper_MT5 -- News event management tool that closes trades and halts auto-trading around high-impact news, full 12-layer stack."
#include <Trade\Trade.mqh>
CTrade trade;
#ifdef __MQL5__
#include <WinAPI\winapi.mqh>
#define MT_WMCMD_EXPERTS 32851
#else
#define HANDLE int
#define PVOID int
#import "user32.dll"
HANDLE GetAncestor( HANDLE hwnd, uint flags);
int PostMessageW( HANDLE hwnd, uint Msg, PVOID param, PVOID param );
#import
#define MT_WMCMD_EXPERTS 33020
#endif
#define WM_COMMAND 0x0111
#define GA_ROOT 2
//Enums
enum currencies
{
type1,//Chart Symbol (Auto)
type2,//Custom Symbols
};
//Inputs
input group "=== Identity ==="
input ulong InpMagic = 22216058; // EA Magic Number
input string InpTradeComment = "Psgrowth.com Expert_16058"; // Trade comment
input string info1 = " ------======<<[ News Management ]>>======------ "; //---=== News Settings ===---
input string news_link = "https://nfs.faireconomy.media/";// --- News URL (to be placed in settings)
input int min_before = 5; //Minutes Before News to close
input int min_before_zero = 60; //Minutes Before News to close with zero profit
input int min_after = 45; //Minutes After News to halt
input bool include_high = true; // Include high
input bool include_medium = false; // Include medium
input bool include_low = false; // Include low
input bool use_title = true; // Filter News based on title
input string title_phrase="Non-Farm,Unemployment,ISM,PMI,CPI,FOMC,Retail Sales,Final GDP q/q,Core PCE Price Index m/m,Empire State Manufacturing Index,Advance GDP q/q,JOLTS";//title keyword (comma seperated)
input int news_update_hour = 2;//Update time interval (in hours)
input currencies symbol_type = type1; //Currencies check method
input string news_symbols = "USD,EUR,GBP,JPY,CAD,CHF"; // Custom Currencies to Check For News
input bool close_only_news_pair = false; // Only Close Orders of The Events Currency
Full source code available on download
Educational purposes only. Do NOT use with real money. Test on demo accounts only.
Clear Warning: Educational Purposes Only
Clear Warning: This Expert Advisor is for educational and testing purposes only. Do NOT use it with real money. Test only on demo accounts. Trading with real money involves substantial risk of capital loss. This does not constitute investment advice.
Recommended Brokers for This EA
These EAs run on MT5 — use a regulated broker with fast execution and tight spreads
Markets.com
Exness
IC Markets
Similar Expert Advisors
View All Expert AdvisorsMore Trend Following strategy EAs from our library
Pipsgrowth EX16080 Trend
Pipsgrowth.com EX16080 EURUSDTrendFollower — triple-EMA H4 trend follower, full 12-layer stack.
Pipsgrowth EX16081 Trend
Pipsgrowth.com EX16081 GoldTrendEA — XAUUSD H4 EMA cross with Fib targets, full 12-layer stack.
Pipsgrowth EX16033 Trend
Pipsgrowth.com EX16033 EA_Price_Action — price-action grid scalper, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.