Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Indicator | Broker Rollover Spread Logger and EA Guard | Trading Tool Update

Fresh MQL5 code release – perfect for enhancing your MT4/MT5 strategies.

If you're holding positions or running automated EAs across the daily server rollover (usually 23:55 to 00:10 server time), you've probably seen liquidity dry up and bid-ask spreads jump 5x to 15x in a few seconds. Mid-price barely moves. Yet a single Ask spike can trigger a pending Buy Stop, clip a tight stop-loss on a short trade, or drag floating equity below a prop firm's daily loss limit right at midnight.

I built Broker Rollover Spread Logger to track those midnight spikes tick-by-tick and give EAs a clean pause signal. When you attach it to a chart, it scans up to 240 historical bars outside the rollover window to seed an immediate daytime baseline spread (capped at 50 points during seeding so old news spikes don't skew the average). During normal hours, it updates that baseline using an outlier-filtered exponential average. Once the clock hits your rollover window, any tick exceeding InpSpikeMultiplier (default 3.0x baseline) and InpMinSpikePts flips iCustom Buffer 0 to 1.0 .

Image for Broker Rollover Spread Logger and EA Guard

Never miss news-driven moves – use the News OCO Expert Advisor to place pending orders safely around economic releases. Find out more.

iCustom Buffers and Telemetry

Your EA only needs to read bar index 0 via CopyBuffer . The indicator exposes three buffers and writes a summary line when the rollover window closes:

  • Buffer 0 ( ExtGuardFlagBuf ): Returns 1.0 (BLOCK) on the current bar during rollover when live spread breaches your limit, and 0.0 (SAFE) otherwise.
  • Buffer 1 ( ExtCurSpreadBuf ): Current Bid-Ask spread in points on every tick.
  • Buffer 2 ( ExtPeakSpreadBuf ): Highest spread recorded during the active or most recent rollover session.

If InpWriteCsvLog is enabled, it also appends the date, peak points, peak timestamp, baseline spread, and spike ratio to MQL5/Files/Rollover_Spread_Log_<Symbol>.csv so you can audit your broker's midnight execution over weeks of live trading. Global variables keep the baseline intact across timeframe changes (expiring automatically if stale for more than 48 hours).

EA Integration Snippet (MQL5)

int g_rolloverGuardHandle = INVALID_HANDLE;

int OnInit()
  {
   g_rolloverGuardHandle = iCustom(_Symbol, _Period, "Broker_Rollover_Spread_Logger");
   if(g_rolloverGuardHandle == INVALID_HANDLE)
      return(INIT_FAILED);
   return(INIT_SUCCEEDED);
  }

bool IsRolloverSpreadSafe()
  {
   double flag[1];
   if(CopyBuffer(g_rolloverGuardHandle, 0, 0, 1, flag) <= 0)
      return(true);
   return(flag[0] < 0.5); // false when Buffer 0 == 1.0 (BLOCK)
  }

Input Parameters

Parameter Default Description
InpRolloverStartHour 23 Rollover window start hour (Broker Server Time, 0-23).
InpRolloverStartMin 55 Rollover window start minute (0-59).
InpRolloverEndHour 0 Rollover window end hour (Broker Server Time, 0-23).
InpRolloverEndMin 10 Rollover window end minute (0-59).
InpSpikeMultiplier 3.0 Spike alert threshold as a multiplier of daytime baseline spread.
InpMinSpikePts 25 Minimum spread in points required before triggering a spike flag.
InpMaxSafeSpreadPts 0 Optional hard spread cap in points ( 0 = disabled, uses multiplier).
InpLogToExperts true Prints spike alerts and end-of-window summaries to the Experts log.
InpWriteCsvLog false Appends daily rollover summaries to MQL5/Files/Rollover_Spread_Log_<Symbol>.csv .
InpSaveGlobalVar true Saves baseline and peak values in terminal GlobalVariables across chart reloads.
InpPanelX 20 Top-right HUD horizontal pixel offset.
InpPanelY 20 Top-right HUD vertical pixel offset.

Technical Scope

This tool covers live, single-symbol rollover spread tracking and iCustom EA gating. It doesn't reconstruct historical M1 equity curves across multiple symbols, calculate Central European Time (Prague 00:00 CE(S)T) High-Water Marks from HTML Strategy Tester reports, or run static source code checks. If you want to audit backtest reports against prop firm daily drawdown rules before going live, or need an automated equity and news circuit breaker that flattens open trades prior to a breach, see the risk tools on my MQL5 profile.

Complement community code with advanced automation from RobotFX.

79242

Best MetaTrader Indicators + Profitable Expert Advisors