Back to Blog

News Trading Automation: Building News-Aware Expert Advisors

High-impact news creates both opportunity and danger. Here's how to build EAs that handle news intelligently.

Sangam Raj
January 17, 2026
14 min read

News Trading Automation Expert Advisors | Viprasol Tech

News Trading Automation

High-impact news creates both opportunity and danger. Here's how to build EAs that handle news intelligently.

The News Trading Challenge

News events like NFP, FOMC, and CPI cause:

  • Extreme volatility: 100+ pip moves in seconds
  • Wide spreads: Can expand 10-50x normal
  • Slippage: Orders filled at unexpected prices
  • Gaps: Price jumps without trades in between
  • Requotes: Broker delays in execution

News Filter Architecture

Basic News Filter:

// Include economic calendar data
#include <Calendar.mqh>

class CNewsFilter {
private:
    int m_minutes_before;    // Minutes to pause before news
    int m_minutes_after;     // Minutes to pause after news
    string m_currencies[];   // Currencies to filter
    int m_impact_level;      // Minimum impact (1=Low, 2=Medium, 3=High)
    
public:
    CNewsFilter(int before=30, int after=30, int impact=3) {
        m_minutes_before = before;
        m_minutes_after = after;
        m_impact_level = impact;
    }
    
    bool IsTradingAllowed(string symbol) {
        MqlCalendarValue values[];
        datetime start = TimeCurrent() - m_minutes_before * 60;
        datetime end = TimeCurrent() + m_minutes_after * 60;
        
        if(CalendarValueHistory(values, start, end)) {
            for(int i = 0; i < ArraySize(values); i++) {
                MqlCalendarEvent event;
                CalendarEventById(values[i].event_id, event);
                
                // Check impact level
                if(event.importance >= m_impact_level) {
                    // Check if currency is in our symbol
                    if(StringFind(symbol, event.currency) >= 0) {
                        return false;  // Trading not allowed
                    }
                }
            }
        }
        return true;  // Trading allowed
    }
};

Usage in EA:

CNewsFilter* newsFilter;

int OnInit() {
    newsFilter = new CNewsFilter(30, 30, 3);  // 30 min before/after, high impact only
    return INIT_SUCCEEDED;
}

void OnTick() {
    if(!newsFilter.IsTradingAllowed(_Symbol)) {
        Comment("Trading paused - High impact news nearby");
        return;
    }
    
    // Normal trading logic here
}

๐Ÿค– Can This Strategy Be Automated?

In 2026, top traders run custom EAs โ€” not manual charts. We build MT4/MT5 Expert Advisors that execute your exact strategy 24/7, pass prop firm challenges, and eliminate emotional decisions.

  • Runs 24/7 โ€” no screen time, no missed entries
  • Prop-firm compliant (FTMO, MFF, TFT drawdown rules)
  • MyFXBook-verified backtest results included
  • From strategy brief to live EA in 2โ€“4 weeks

Advanced News Handling Strategies

Strategy 1: Close Before News

void ManagePositionsBeforeNews() {
    if(IsHighImpactNewsComingSoon(15)) {  // 15 minutes
        // Option A: Close all positions
        CloseAllPositions();
        
        // Option B: Move to breakeven
        MoveAllToBreakeven();
        
        // Option C: Tighten stops
        TightenStopLosses(50);  // 50% tighter
    }
}

Strategy 2: News Straddle

Trade the volatility without predicting direction:

class CNewsStraddle {
private:
    double m_distance;      // Distance for pending orders
    double m_stop_loss;
    double m_take_profit;
    
public:
    void SetupStraddle(int minutes_before=1) {
        if(!IsHighImpactNewsComingSoon(minutes_before)) return;
        
        double price = SymbolInfoDouble(_Symbol, SYMBOL_BID);
        
        // Place buy stop above
        double buy_price = price + m_distance * _Point;
        OrderSend(_Symbol, ORDER_TYPE_BUY_STOP, 0.1, 
                  buy_price, 0, 
                  buy_price - m_stop_loss * _Point,
                  buy_price + m_take_profit * _Point);
        
        // Place sell stop below
        double sell_price = price - m_distance * _Point;
        OrderSend(_Symbol, ORDER_TYPE_SELL_STOP, 0.1,
                  sell_price, 0,
                  sell_price + m_stop_loss * _Point,
                  sell_price - m_take_profit * _Point);
    }
    
    void CancelUnfilledAfterNews() {
        // Cancel pending orders that weren't triggered
        if(MinutesSinceLastNews() > 5) {
            CancelAllPendingOrders();
        }
    }
};

Strategy 3: Fade the Spike

Trade reversals after initial news reaction:

class CNewsFade {
public:
    void CheckForFadeOpportunity() {
        int minutes_since_news = GetMinutesSinceLastHighImpactNews();
        
        if(minutes_since_news < 2 || minutes_since_news > 30) {
            return;  // Too early or too late
        }
        
        double spike_size = GetNewsSpikeSize();
        
        // Large spike = fade opportunity
        if(spike_size > 50 * _Point) {  // 50+ pips
            double entry = GetSpikeRetracement(0.5);  // 50% retracement
            PlaceFadeOrder(entry);
        }
    }
};

Integrating External News APIs

Forex Factory API Integration:

import requests
from datetime import datetime, timedelta

class ForexFactoryCalendar:
    def __init__(self):
        self.base_url = "https://nfs.faireconomy.media/ff_calendar_thisweek.json"
    
    def get_upcoming_news(self, hours_ahead=24):
        response = requests.get(self.base_url)
        events = response.json()
        
        upcoming = []
        cutoff = datetime.now() + timedelta(hours=hours_ahead)
        
        for event in events:
            event_time = datetime.strptime(event['date'], '%Y-%m-%dT%H:%M:%S')
            if datetime.now() < event_time < cutoff:
                if event['impact'] == 'High':
                    upcoming.append(event)
        
        return upcoming
    
    def is_news_blackout(self, currency, minutes=30):
        events = self.get_upcoming_news(hours_ahead=1)
        
        for event in events:
            if event['country'] == currency:
                return True
        
        return False

Real-Time News Feed:

import websocket
import json

class NewsWebSocket:
    def __init__(self, callback):
        self.callback = callback
        
    def on_message(self, ws, message):
        news = json.loads(message)
        
        if news['impact'] == 'high':
            self.callback(news)
    
    def connect(self):
        ws = websocket.WebSocketApp(
            "wss://news-feed.example.com/forex",
            on_message=self.on_message
        )
        ws.run_forever()

๐Ÿ“ˆ Stop Trading Manually โ€” Let AI Do It

While you sleep, your EA keeps working. Viprasol builds prop-firm-compliant Expert Advisors with strict risk management, real backtests, and live deployment support.

  • No rule violations โ€” daily drawdown, max drawdown, consistency rules built in
  • Covers MT4, MT5, cTrader, and Python-based algos
  • 5.0โ˜… Upwork record โ€” 100% job success rate
  • Free strategy consultation before we write a single line

Risk Adjustments for News

Dynamic Spread Handling:

double GetDynamicSpread() {
    double spread = SymbolInfoInteger(_Symbol, SYMBOL_SPREAD) * _Point;
    double normal_spread = GetAverageSpread();  // Your calculated average
    
    return spread / normal_spread;  // Ratio of current to normal
}

bool IsSpreadAcceptable() {
    if(GetDynamicSpread() > 3.0) {  // Spread 3x normal
        return false;
    }
    return true;
}

Position Sizing During News:

double GetNewsAdjustedLotSize(double base_lots) {
    if(IsHighImpactNewsComingSoon(60)) {
        return base_lots * 0.5;  // Half size near news
    }
    
    if(GetMinutesSinceLastHighImpactNews() < 30) {
        return base_lots * 0.7;  // Reduced size after news
    }
    
    return base_lots;
}

Testing News Strategies

Historical News Backtesting:

Download historical news data and simulate:

class NewsBacktester:
    def __init__(self, news_data, price_data):
        self.news = news_data
        self.prices = price_data
    
    def simulate_straddle(self, distance=30, sl=50, tp=100):
        results = []
        
        for news_event in self.news:
            if news_event['impact'] != 'High':
                continue
            
            price_at_news = self.get_price_at_time(news_event['time'])
            high_after = self.get_high_after(news_event['time'], minutes=60)
            low_after = self.get_low_after(news_event['time'], minutes=60)
            
            # Check if straddle would trigger
            # ... simulation logic
            
        return results

Our News Trading Solutions

Viprasol builds news-aware EAs featuring:

  • Economic calendar integration
  • Smart spread filtering
  • Straddle and fade strategies
  • Real-time news API connections
  • Historical news backtesting

Want a news-trading EA? Contact us or WhatsApp us to discuss your strategy.

Share this article:

About the Author

S

Sangam Raj

Business & Technology Consultant โ€” Viprasol Tech

Sangam bridges business strategy and technology at Viprasol. He writes about digital transformation, IT consulting, startup tech decisions, and how companies can use software to grow faster without burning budget.

Business StrategyIT ConsultingDigital TransformationStartup Tech

Ready to Automate Your Trading?

Get a custom Expert Advisor built by professionals with verified MyFXBook results.

Free consultation โ€ข No commitment โ€ข Response within 24 hours

Viprasol ยท Trading Software

Need a custom EA or trading bot built?

We specialise in MT4/MT5 Expert Advisor development โ€” prop-firm compliant, forward-tested before live, MyFXBook verifiable. 5.0โ˜… Upwork, 100% Job Success, 100+ projects shipped.