MiniBull Session SR MTF
- Indicatori
-
Yusuf Levent Aksun
Platform Engineer & professionista certificato AWS con oltre 20 anni di esperienza
nello sviluppo software, architettura cloud e trasformazione DevOps.
Attualmente guido iniziative di platform engineering presso World Wide Technology - Versione: 4.20
- Aggiornato: 31 agosto 2026
- Attivazioni: 5
# MiniBull Session S/R MTF
**Version:** 4.0
**Platform:** MetaTrader 5 (custom indicator, `.mq5`)
**Type:** Visual reference overlay — no trading logic, no signals, no orders
**File:** `MiniBull_Session_SR_MTF.mq5`
## Overview
MiniBull Session S/R MTF is a multi-timeframe support/resistance and session-level
overlay for MT5. It draws the previous trading session's high/low, the current
session's open, the US cash market open, rolling support/resistance from three
higher timeframes (4H / 1H / 15M-intraday), two Kaufman Adaptive Moving Averages
(KAMA), and a compact info panel with % distance to key levels and the Daily
Wilder ATR — all computed automatically, with no manual timezone configuration
required.
It is a from-scratch MQL5 implementation inspired by a "Session & Prev-Day
Levels" style TradingView (Pine Script) tool, adapted and extended for MT5's
object/event model.
## What it draws
| Element | Style | Notes |
|---|---|---|
| Previous session High | Solid green line + label | Anchored at the actual bar that set the high |
| Previous session Low | Solid red line + label | Anchored at the actual bar that set the low |
| Current session Open | Solid white line + label | Drawn at the first bar of the current session |
| US cash open (09:30 NY) | Dashed white line + label | Standard instrument mode only |
| R / S (4H, x120 bars) | Solid, width 3 | ~4 weeks lookback by default |
| R / S (1H, x120 bars) | Dashed, width 2 | ~1 week lookback by default |
| R / S (15M, current day) | Dotted, width 1 | Rebuilt every session, current day only |
| R / S (30M, x120 bars) | Dash-dot, width 1 | **Off by default** — enable from inputs; ~2.5 days lookback |
| R / S (5M, x120 bars) | Dash-dot-dot, width 1 | **Off by default** — enable from inputs; ~10 hours lookback |
| R / S (1M, x120 bars) | Dotted, width 1 (distinct colors) | **Off by default** — enable from inputs; ~2 hours lookback |
| AMA #1 / AMA #2 | Solid lines (white / yellow by default) | Kaufman KAMA, periods configurable (default 200 / 9) |
| Info panel | Top-right corner | % vs Prev High, % vs Prev Low, Daily ATR (Wilder) |
Every S/R line is anchored **at the exact candle that produced the high or low**,
not at the edge of the lookback window — so a level that formed 3 days into a
20-day scan starts exactly 3 days back, not 20. Resistance and support within
the same timeframe are tracked independently, since the bar that set the high is
rarely the same bar that set the low.
Line thickness decreases with timeframe: 4H (3) → 1H (2) → 15M (1), on top of
the existing solid / dashed / dotted style distinction, so the timeframe
hierarchy is visible at a glance even in monochrome.
## Session logic
- **Standard mode**: a new "trading day" begins at **18:00 New York time**
(the standard forex/CFD rollover), matching how most retail platforms define
a trading session for FX and metals.
- **Brent mode**: a new "trading day" begins at **00:00 UTC** (fixed), which
suits energy/futures-style instruments that don't follow the FX rollover.
- Weekend gaps are handled naturally: since no new session boundary occurs
while the market is closed, the session that was open at Friday's close
simply continues through the gap into Monday, exactly as a trader would
expect.
## Timezone handling (fully automatic)
- The broker server → UTC offset is **auto-detected at runtime** by comparing
`TimeGMT()` (the PC's real UTC clock) against `TimeTradeServer()` (the
broker's server clock). This works regardless of the trader's own location
or which broker/server is in use — it only requires the PC's own clock to be
correctly set, which is standard on any modern OS.
- US Daylight Saving Time is computed from the **actual US DST calendar rule**
(2nd Sunday of March → 1st Sunday of November), so New York's UTC offset is
always correct for the current year without ever needing a manual update.
- A manual fallback offset input exists only for edge cases where `TimeGMT()`
is unavailable, such as the Strategy Tester.
## Inputs
**Session & Prev-Day Levels**
- `InpShowSessionLevels` — show/hide prev high/low + session open
- `InpInstrumentMode` — `Standard` (NY rollover) or `Brent` (00:00 UTC rollover)
- `InpShowCashOpen` — show the 09:30 NY cash-open marker (Standard mode only)
- `InpShowSessionPanel` — show/hide the info panel
**Timezone**
- `InpAutoDetectBrokerOffset` — auto-detect broker↔UTC offset (recommended, default on)
- `InpManualBrokerOffsetHours` — fallback offset, used only if auto-detect is off or fails
**Support/Resistance**
- `InpShowSR4H` / `InpLookback4H` — 4H S/R on/off + lookback in bars (default 120 ≈ 4 weeks)
- `InpShowSR1H` / `InpLookback1H` — 1H S/R on/off + lookback in bars (default 120 ≈ 1 week)
- `InpShowSR15M` — 15-minute intraday S/R on/off (always scoped to the current session)
- `InpShowSR30M` / `InpLookback30M` — **optional, off by default.** Rolling 30-minute S/R, same model as 4H/1H (default lookback 120 ≈ 2.5 days)
- `InpShowSR5M` / `InpLookback5M` — **optional, off by default.** Rolling 5-minute S/R (default lookback 120 ≈ 10 hours)
- `InpShowSR1M` / `InpLookback1M` — **optional, off by default.** Rolling 1-minute S/R (default lookback 120 ≈ 2 hours)
**Adaptive Moving Average**
- `InpShowAMA` — show/hide both AMA lines
- `InpAmaPeriod1` / `InpAmaPeriod2` — KAMA periods (default 200 / 9)
- `InpAmaFastEMA` / `InpAmaSlowEMA` — KAMA smoothing-constant bounds (default 2 / 30)
- `InpAmaColor1` / `InpAmaColor2` — line colors
**Wilder ATR**
- `InpShowATRPanel` — show/hide the ATR row in the panel
- `InpAtrLength` — ATR period (default 14). **ATR is always computed on the
Daily timeframe**, regardless of the timeframe the chart is currently
showing.
## Design notes / things fixed along the way
This is a living document of the more subtle correctness issues addressed
during development, kept here for anyone maintaining the code later:
- **Label collision avoidance.** Nearby levels (e.g. a 4H resistance and a
15-minute "today" resistance a few points apart) are queued and resolved by
pixel distance before being drawn, so overlapping text is nudged apart. Only
the printed label moves — the underlying line is always drawn at the exact
price.
- **Lines drawn in front of candles, not behind.** On a volatile instrument,
dense candle bodies can fully obscure a "behind the price action" line even
though the object exists — all reference lines render in front instead.
- **Panel anchoring.** A corner-anchored label with a small offset from the
edge needs to be *right*-anchored so its text grows inward, or it renders
mostly off-screen — an easy mistake that makes a working panel look like it
never rendered at all.
- **"Today" session detection is anchored to the chart's own current time**,
not to whichever bar a separately-fetched intraday series happens to return
as "latest" — avoiding a stale/mismatched read locking the day's range to
the wrong session.
- **KAMA computation is O(n)**, not O(n·period): the volatility sum inside the
efficiency-ratio calculation is maintained as a sliding window instead of
being re-summed from scratch for every historical bar, which matters a lot
with a 200-period AMA over a long history.
## Known limitations
- First load on a fresh chart/timeframe/symbol can take a few seconds while
MT5 syncs the H4/H1/M15 history series it depends on — this is normal MT5
history-sync behavior, not indicator overhead, and is faster once those
timeframes have been opened once for that symbol.
- Designed as a visual aid only. It does not place trades, generate alerts, or
make any trading recommendation.
- For best readability, enabling **Chart Shift** (right-click chart →
Properties → Common) gives labels room to breathe on the right edge instead
of crowding against the last candle.
## Disclaimer
This indicator is a visual reference tool only. It does not constitute
financial advice, and past levels holding as support/resistance is not a
guarantee they will do so in the future. Use at your own risk alongside your
own analysis and risk management.
