SessionClock

  • Libraries
  • Shipra Gupta
    Shipra Gupta
    I’m Shipra Gupta, a trader and quantitative strategy developer with a strong background in mathematics, economics, and algorithmic trading systems. Over the years, I’ve worked extensively across forex, gold, indices, commodities, and crypto markets, focusing on building data-driven trading
  • Version: 1.0

SessionClock – DST-Aware Broker Clock & Trading Sessions

TimeGMT() returns server time in the Strategy Tester, so most session EAs backtest on the wrong hours around every DST switch. SessionClock fixes that.

Features

  • Auto-detect broker – Fits your broker's GMT offset and DST rule (none, US, EU, AU) to weekend opens in price history. Works in the Strategy Tester.
  • Live fallback – SC_DetectLive() reads TimeTradeServer() − TimeGMT(). SC_SetBroker() for manual override.
  • 7 time zones – UTC, New York, London, Frankfurt, Tokyo, Sydney, Hong Kong, each with its own DST calendar.
  • 7 sessions – Sydney, Tokyo, London, Frankfurt, New York, NY cash 09:30–16:00, London/NY overlap.
  • Countdowns – Next session open in server time and minutes until it opens.
  • Trading day – 17:00 New York rollover key used by FX and index CFDs.

Quick start

1. Buy and download the library. MetaTrader installs it to MQL5\Libraries\SessionClock.ex5.
2. Paste the import block below at the top of your EA, indicator or script.
3. Call the functions.

int OnInit()
  {
   if(!SC_DetectFromHistory("EURUSD",17,104)) SC_SetBroker(120,SC_DST_US);
   Print(SC_Describe());              // Broker GMT+2.0, DST US, fit 100%
   return(INIT_SUCCEEDED);
  }
void OnTick()
  {
   if(SC_IsSessionOpen(SC_SES_NY_CASH,TimeCurrent())) Trade();
  }

Import block (copy into your code)

#define SC_DST_NONE    0
#define SC_DST_US      1
#define SC_DST_EU      2
#define SC_DST_AU      3
#define SC_ZONE_UTC        0
#define SC_ZONE_NEWYORK    1
#define SC_ZONE_LONDON     2
#define SC_ZONE_FRANKFURT  3
#define SC_ZONE_TOKYO      4
#define SC_ZONE_SYDNEY     5
#define SC_ZONE_HONGKONG   6
#define SC_ZONE_SERVER     7
#define SC_SES_SYDNEY      0
#define SC_SES_TOKYO       1
#define SC_SES_LONDON      2
#define SC_SES_NEWYORK     3
#define SC_SES_NY_CASH     4
#define SC_SES_LDN_NY      5
#define SC_SES_FRANKFURT   6
#define SC_ERR_NONE    0
#define SC_ERR_PARAM   1
#define SC_ERR_DATA    2
#define SC_ERR_SYMBOL  3
#define SC_ERR_FIT     4

#import "SessionClock.ex5"
int SC_LastError();
bool SC_SetBroker(const int base_offset_minutes,const int dst_model);
bool SC_DetectFromHistory(const string symbol,const int ny_open_hour,const int weeks);
bool SC_DetectLive();
double SC_FitScore();
int SC_BrokerBaseMin();
int SC_BrokerDSTModel();
bool SC_IsReady();
int SC_ServerOffsetMin(const datetime server_time);
datetime SC_ServerToUTC(const datetime server_time);
datetime SC_UTCToServer(const datetime utc);
datetime SC_UTCToZone(const datetime utc,const int zone);
datetime SC_ZoneToUTC(const datetime local,const int zone);
datetime SC_ServerToZone(const datetime server_time,const int zone);
datetime SC_ZoneToServer(const datetime local,const int zone);
bool SC_IsDST(const int dst_model,const datetime utc);
bool SC_IsSessionOpen(const int session,const datetime server_time);
datetime SC_NextSessionOpen(const int session,const datetime server_time);
int SC_MinutesToSessionOpen(const int session,const datetime server_time);
datetime SC_TradingDay(const datetime server_time,const int ny_roll_hour);
string SC_ZoneName(const int zone);
string SC_Describe();
#import

Notes

  • Use any 24/5 reference symbol. FX majors open 17:00 New York; most index CFDs open 18:00.
  • Tested on a GMT+2/+3 New-York-close broker feed: 105 of 105 weekend opens matched.
  • The reference symbol is an input, never hard-coded.

Technical

  • Pure MQL5. No DLL, no WebRequest, no file I/O.
  • Every exported function validates its inputs. SC_LastError() returns the reason for any failed call.
  • Works in the Strategy Tester and live, on any broker, symbol and account currency.

Past performance shown in screenshots is from historical data and does not guarantee future results.



More from author
AMD Po3
Shipra Gupta
AMD Po3 for MetaTrader 5 Accumulation, manipulation, distribution: mapped for you. AMD Po3 is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator maps the reaction zones that matter right now: the nearest areas above and
KN Smart TP SL Signals for MetaTrader 5 Overview KN Smart TP SL Signals is an EMA crossover indicator for MetaTrader 5 that converts confirmed moving-average crossovers into structured visual trade setups. Each signal includes an entry level, ATR-based Stop Loss, and three configurable Take Profit targets. The indicator automatically plots these levels on the chart, helping traders evaluate potential trades without manually calculating each price level. Signals are generated using closed candle
IFVG Sniper Entry Engine — MQL5 Marketplace Description IFVG Sniper Entry Engine is a precision MT5 indicator built around one of the most specific and high-probability Smart Money Concepts entry patterns — the Inverse Fair Value Gap (IFVG) . It silently tracks every raw Fair Value Gap formed on the chart, monitors each one for inversion (mitigation), and the moment a qualifying IFVG is confirmed, it fires a BUY or SELL signal with a full SL/TP trade layout and a push notification — on every si
Coppock Curve MultiFilter for MetaTrader 5 The classic Coppock curve with modern filters. Coppock Curve MultiFilter is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with
FREE
Tension Flow Trend — Dynamic HMA Ribbon with Historical RR Backtest Tension Flow Trend is an advanced trend-following indicator for MetaTrader 5 that combines a Hull Moving Average (HMA) trend ribbon , Z-Score momentum analysis , and a built-in visual Risk:Reward backtesting engine into a single chart overlay. Designed to identify high-probability trend continuation opportunities, the indicator filters out market noise by requiring both a slope-confirmed HMA crossover and a configurable signal c
FREE
Adaptive RSI Supertrend for MetaTrader 5 Trend and RSI momentum in one view. Adaptive RSI Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
FREE
Trend Target Ribbon for MetaTrader 5 A colour ribbon for trend, targets for risk. Trend Target Ribbon is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull c
FREE
Overview Structure-Anchored VWAP [WAT] is a market-structure-aware VWAP indicator for MetaTrader 5. It anchors Volume Weighted Average Price (VWAP) to relevant swing points and market-structure events rather than relying exclusively on fixed session resets. The indicator combines market structure analysis, anchored VWAP, deviation bands, retest signals, and ATR-based trade-level calculations in one chart-based framework. It is designed to help traders assess price relative to structural movemen
FREE
Liquidity Intelligence System — MQL5 Marketplace Description Liquidity Intelligence System   is an institutional-grade MT5 indicator that maps Smart Money liquidity pools, detects sweep-and-reverse setups, and generates high-confluence trade signals through 16 independently-testable signal models — all within a single, clean indicator. How It Works The engine continuously builds a live liquidity map by detecting pivot-based   Buy-Side Liquidity (BSL)   and   Sell-Side Liquidity (SSL)   zones, in
Precision Sniper Trader for MetaTrader 5 EMA trend plus momentum confirmation. Precision Sniper Trader is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to c
FREE
TrendIQ Pro for MetaTrader 5 Adaptive volatility trend with a trend cloud. TrendIQ Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull colour for long
Squeeze Momentum Breakout for MetaTrader 5 Low volatility in, momentum breakout out. Squeeze Momentum Breakout is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is trading in and hi
FREE
Volume Breakout Pro for MetaTrader 5 Breakouts backed by abnormal volume. Volume Breakout Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is trading in and highlights periods
FREE
Meridian Flow — Smart Money Structure Indicator for MT5 Meridian Flow is a MetaTrader 5 indicator built for traders who follow Smart Money Concepts (SMC) and ICT price action methodology. It automatically detects BOS (Break of Structure) and CHoCH (Change of Character) events on any symbol and timeframe, then plots a complete risk map — Entry, Stop Loss, TP1, TP2, and TP3 — for every signal, including historical ones. Signals fire only on confirmed, closed bars. No repainting. No guesswork. MT5
Adaptive Trend System for MetaTrader 5 A trend line that adapts to volatility. Adaptive Trend System is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
Market Path Forecast for MetaTrader 5 Projected price paths from swing statistics. Market Path Forecast is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how price b
FREE
RSI Signal Entries for MetaTrader 5 RSI extremes plus candle confirmation. RSI Signal Entries is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with clear extreme zones.
FREE
Trident Swing Projector for MetaTrader 5 Quarter-swing projections from ABC structures. Trident Swing Projector is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how
Z-Score Range Boxes Breakout for MetaTrader 5 Statistical extremes boxed, breakouts flagged. Z-Score Range Boxes Breakout is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is tradin
Precision Sniper Pro for MetaTrader 5 Four pillars: EMA, RSI, MACD and ADX. Precision Sniper Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to close b
FREE
Stealth Trail Supertrend for MetaTrader 5 A supertrend that adapts its own multiplier. Stealth Trail Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the tre
Fibonacci Path Profile for MetaTrader 5 How price moved after similar retracements. Fibonacci Path Profile is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how pric
Strong Fade Signals for MetaTrader 5 Fade the overextended move, with a score. Strong Fade Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to close
FREE
Fan Principle Signals for MetaTrader 5 The classic fan principle, as clear signals. Fan Principle Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how price
McGinley Dynamic Fusion for MetaTrader 5 McGinley Dynamic crossovers with ATR levels. McGinley Dynamic Fusion is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend
Liquidity Entry Signals for MetaTrader 5 Entries where liquidity gets taken. Liquidity Entry Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator maps the reaction zones that matter right now: the nearest areas
Cardwell Range Pro for MetaTrader 5 RSI ranges that change with the market regime. Cardwell Range Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with clear extreme
Adaptive RSI Supertrend for MetaTrader 5 Trend and RSI momentum in one view. Adaptive RSI Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
Market Structure Target Tracker for MetaTrader 5 Swings, BOS, CHoCH and ATR targets. Market Structure Target Tracker is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and track
Smart TrendFlow Pro for MetaTrader 5 Channel breaks with a volatility heatmap. Smart TrendFlow Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is trading in and highlights per
Filter:
No reviews
Reply to review