OPEN-SOURCE SCRIPT

Session Range Architecture [JOAT]

3 022
Session Range Architecture [JOAT]

Introduction

Session Range Architecture (SRA) is an open-source, institutional-grade session killzone engine that captures the opening range of the Tokyo, London, and New York trading sessions as live price-tracking boxes, draws high, low, and mid extension lines that persist after each session closes, and fires rejection signals when price wicks beyond a session extreme and closes back inside. Signals are filtered by an EMA alignment stack (EMA 4, EMA 5, and EMA 750) and confirmed exclusively on closed bars. ATR-based stop loss and take profit boxes visualize each signal's risk/reward from entry. Per-session and aggregate win rate statistics are tracked and displayed in a configurable dashboard.

The core problem SRA solves is the repetitive, daily manual work of marking opening range boxes for each session. ICT methodology identifies the first portion of each killzone as the period during which institutional order flow establishes the session's directional bias — the high and low of that range become the primary intraday reference levels. When price returns to those levels later in the session or in the following session and creates a wick rejection, it signals a potential liquidity grab and reversal opportunity. SRA automates the full process from box construction through signal detection to trade outcome tracking.

istantanea

Core Concepts

1. Session Opening Range Construction

Each session's opening range is built dynamically during the configurable range window (default: first 15 minutes of each session). The high and low of every bar within that window expand the range in real time. At the end of the window, the range is finalized and stored as a SessionRange user-defined type containing the box, three extension lines (high, low, mid), and the session label:

Pine Script®


2. Extension Lines

When a session's range window closes, three horizontal lines are drawn extending rightward from the range: a dashed line at the session high (buy-side liquidity), a dashed line at the session low (sell-side liquidity), and a dotted line at the session midpoint (50% equilibrium reference). These lines persist on the chart as long-term structural reference levels beyond the session itself.

3. Rejection Signal Detection

A rejection is detected when a bar's wick pierces a session high or low and the close returns inside the range. A minimum wick percentage filter ensures the penetration is meaningful relative to total candle range — trivial pokes are excluded. For a bullish rejection at a session low (price swept below, closed above), the setup is treated as a potential long opportunity. For a bearish rejection at a session high, it is treated as a short opportunity.

4. EMA Alignment Filter

Signals are optionally filtered by a simplified EMA alignment check: bullish signals require EMA 4 above EMA 5 and price above EMA 750; bearish signals require EMA 4 below EMA 5 and price below EMA 750. This ensures rejection signals at session levels are taken in the direction of the prevailing trend structure rather than against it.

5. ATR-Based Trade Visualization and Tracking

On each confirmed signal, ATR-based stop loss and take profit boxes are drawn from the entry close. Outcome is checked on subsequent bars — if price hits the SL or TP, the trade is recorded, counters for the originating session are updated, and the box color changes to reflect the result.

Features

  • Three Independent Session Ranges: Tokyo, London, and New York opening ranges built automatically each day — individually configurable with independent colors and visibility toggles
  • Configurable Range Window: Opening range capture window length adjustable from 5 to 60 minutes to match different analysis styles
  • Extension Lines: Session high, low, and mid extension lines drawn from completed ranges and extended rightward as persistent liquidity reference levels
  • Rejection Signal Detection: Wick-beyond, close-inside detection at session extremes with minimum wick percentage filter
  • EMA Alignment Filter: EMA 4/5 cross direction and EMA 750 price side required for signal confirmation — configurable on/off
  • ATR TP/SL Visualization: Risk and reward boxes from each entry bar — default 1.5× ATR stop, 3:1 reward ratio, fully adjustable
  • Session Win Rate Tracking: Independent win/loss/total counters for Tokyo, London, and New York sessions
  • Session History Management: Oldest range boxes automatically trimmed to prevent chart clutter (configurable maximum)
  • Non-Repainting: All signals gated on barstate.isconfirmed — session ranges never move backward
  • Timezone Configuration: Session windows evaluated relative to a configurable timezone to handle exchange-specific session times
  • Dashboard (Top Right): Per-session win/loss/rate table for Tokyo, London, NY, and aggregate total with color-coded performance rows
  • Session Background Tints: Subtle color fills applied to the chart background during Tokyo, London, and NY range-building windows — visually delineates the opening range capture period for each session in real time
  • Session Name Labels on Range Boxes: Session name label placed at the midpoint of each finalized range box — immediately identifies which session produced each visible range without requiring manual reference
  • EMA Alignment State in Dashboard: Current EMA alignment state (BULL ALIGN / BEAR ALIGN / NEUTRAL) displayed in the dashboard — provides a one-glance structural context for the active session
  • Live ATR Value in Dashboard: Current ATR value shown in the dashboard — communicates the prevailing volatility level used for TP/SL sizing at any given moment
  • Expanded Dashboard (8 Rows): Dashboard expanded to 8 rows — now includes EMA alignment state and live ATR value alongside the existing per-session win rate breakdown


Input Parameters

Session Settings:
  • Chart Timezone: Timezone for session window evaluation (default: America/New_York)
  • Show Tokyo / London / New York Range: Independent visibility toggles per session
  • Range Window (minutes): Opening range capture duration (default: 15)


EMA Filter:
  • Fast EMA: Period for fast EMA (default: 4)
  • Slow EMA: Period for slow EMA (default: 5)
  • Trend EMA: Period for long-term trend filter EMA (default: 750)
  • Require EMA Alignment: Toggle filter on/off (default: enabled)


Risk Settings:
  • ATR Length: ATR period (default: 14)
  • ATR SL Multiplier: Stop loss ATR distance (default: 1.5)
  • Reward:Risk Ratio: TP as multiple of SL distance (default: 3.0)
  • Show TP/SL Boxes: Toggle TP/SL visualization (default: enabled)


Signal Settings:
  • Require Rejection Wick: Toggle minimum wick filter (default: enabled)
  • Min Wick % of Range: Minimum wick size relative to candle range (default: 55%)


How to Use This Indicator

Step 1: Identify Session Range Levels
Each session's opening range box shows the high, low, and midpoint established during the opening window. These are the primary liquidity reference levels for that killzone. Extension lines persist after the session box closes, continuing to mark those price levels as the day progresses.

Step 2: Monitor for Rejection Signals
When price wicks beyond a session extreme and closes back inside, a rejection signal is generated. This event represents a liquidity grab — the market took the stops placed beyond the session extreme and reversed. The signal fires at the close of the rejecting bar, confirmed on that candle only.

Step 3: Confirm EMA Alignment
With the EMA filter enabled, only signals aligned with the current EMA 4/5 direction and EMA 750 trend side are triggered. This avoids trading session rejections against the prevailing structural trend.

Step 4: Manage Risk with TP/SL Boxes
The ATR-based TP/SL boxes extend from the entry close and show the exact risk/reward zone for each trade. The stop is placed 1.5× ATR from entry; the target is 3× that distance by default. Both are adjustable.

Step 5: Review Session Performance
The per-session win rate table shows which session ranges have historically produced the best rejection setups on the current instrument and timeframe. Use this to focus attention on the sessions with the strongest empirical edge.

Indicator Limitations

  • Session detection is based on time windows relative to the selected timezone. Instruments that observe daylight saving time shifts differently from the selected timezone may require manual session string adjustment during DST transitions
  • The opening range window is fixed in minutes. On timeframes coarser than the window (e.g., a 30-minute chart with a 15-minute range window), the range will capture only one or two bars, which may not accurately represent the opening range
  • The EMA 750 requires 750 bars of history to produce an accurate value. On instruments with limited history or on very long timeframes, the first 750 bars will show an inaccurate trend filter — use the indicator on instruments and timeframes with sufficient historical data
  • Session win rate counters are maintained within the current chart load session and reset when the indicator is refreshed. They reflect historical outcomes up to the current chart's loaded data, not a permanent multi-year backtest
  • Rejection detection uses bar closes. On timeframes with large candles (daily, weekly), a wick rejection at a session range level may span multiple intraday sessions, making the signal less precise for intraday execution


Originality Statement

SRA automates the full three-stage session range workflow — range construction, level monitoring, and rejection detection — within a single indicator, with per-session outcome tracking and EMA trend filtering. This is original for the following reasons:

  • The dynamic range construction (high/low expanding bar-by-bar during the opening window, then finalizing on window close) replicates the manual process of drawing opening range boxes in real time, including live box expansion during active sessions — behavior not available from static horizontal lines
  • Extension lines at the session high, low, and midpoint persist beyond the session box as separate structural reference levels, providing a layered view of session-specific liquidity without requiring additional drawings
  • The rejection detection system operates across all three active session ranges simultaneously in a single scan loop, identifying which specific session range produced the signal and tagging it for session-specific outcome tracking
  • The EMA alignment stack (fast EMA cross direction + long-term trend EMA) applied as a prerequisite filter to session rejection signals combines institutional level-based methodology with trend confirmation in a single indicator rather than requiring a separate trend indicator


Disclaimer

This indicator is provided for educational and informational purposes only. It is not financial advice or a recommendation to buy or sell any financial instrument. Trading involves substantial risk of loss. Session range levels and rejection signals are historical reference points. Price does not respect these levels in all market conditions, and rejection signals do not guarantee a reversal. Session win rates are derived from historical bar data and do not predict future performance. Always apply proper risk management. The author is not responsible for any trading losses resulting from the use of this indicator.

-Made with passion by jackofalltrades

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.