OPEN-SOURCE SCRIPT
Session Pulse [JOAT]

Session Pulse [JOAT]
Introduction
Session Pulse is an open-source multi-session gap statistics engine that tracks, categorizes, and accumulates gap data across Asia, London, and New York trading sessions, marks every session boundary transition with labeled vertical lines on the chart, and presents a unified session statistics dashboard. It answers a specific and persistent question that many traders examine manually: how often, in which direction, and by how much does this instrument gap between sessions?
Gap behavior is one of the most systematically consistent patterns across many instruments. Session close-to-open gaps represent a measurable directional displacement — one that either fills (mean reverts) or extends (confirms momentum) in predictable proportions over sufficiently large samples. Session Pulse automates the data collection and visualization for that entire analysis, providing live cumulative statistics on gap frequency, average gap size, maximum gap, and directional bias, refreshed on every bar.

Core Concepts
1. Session Detection
Each of the three sessions (Asia, London, New York) is detected using Pine Script's time() function with a user-configurable session string and timezone. Session transitions are identified by comparing the current bar's session membership to the previous bar's membership. A session start occurs on the first bar where the current bar is inside the session and the previous bar was outside:
Pine Script®
2. Gap Calculation and Categorization
A gap is calculated at each session open as the difference between the current bar's open and the previous bar's close, expressed as a percentage of the previous close. Gaps are categorized as Gap Up (positive gap, open above prior close) or Gap Down (negative gap, open below prior close). A minimum gap percentage threshold filters out negligible noise-level gaps that do not qualify as meaningful session displacements:
Pine Script®
3. Session Boundary Visualization
At each session start, a vertical dotted line is drawn extending across the chart, and a labeled arrow points down from the top of the price range with the session name (ASIA, LONDON, NEW YORK). This creates a clear visual demarcation of every session boundary on the chart without requiring manual annotation. The lines and labels are drawn live on the current bar and persist across the chart history:
Pine Script®
4. Cumulative Statistics Accumulation
Statistics are accumulated across the full chart history using running counters and accumulators for each direction. For each session type (Asia, London, NY), the indicator tracks: total gap count by direction, cumulative gap size sum for average computation, and the maximum gap in each direction. These statistics build bar by bar and display the full historical picture at any point in time:
Pine Script®
5. Unified Statistics Dashboard
A single unified table presents all gap statistics in a structured layout: Gap Up rows at the top, a separator, Gap Down rows below, a final separator, and a summary row showing total gap count and the percentage of gaps that were up (directional bias). The entire table is positioned at a single user-configurable location on the chart, eliminating split-panel layouts:
Pine Script®

Features
Input Parameters
Session Settings:
Gap Detection:
Display:
How to Use This Indicator
Step 1: Read the Directional Bias
The summary row of the statistics table shows Up Bias % — the percentage of all gaps that have been upward. An Up Bias above 60% on a large sample indicates this instrument has a persistent tendency to gap up at session opens. This is the first, most actionable piece of information from the table.
Step 2: Compare Average Gap Sizes
The average gap rows for Gap Up and Gap Down show the typical magnitude of each type. If the average Gap Down is significantly larger than the average Gap Up, the downside gaps — when they occur — tend to be more violent even if they are less frequent. This asymmetry has implications for stop sizing around session opens.
Step 3: Use Maximum Gap for Range Planning
The maximum gap rows show the largest gap in each direction recorded on the chart. This establishes the worst-case session displacement for this instrument at the current timeframe — useful for setting session-open risk boundaries.
Step 4: Use Session Boundary Lines for Chart Context
The vertical lines with session name labels divide the chart into session periods. On lower timeframes this makes it immediately clear which session each group of bars belongs to, providing context for patterns that occur predominantly in specific sessions.
Step 5: Monitor for Session Open Alerts
Set the session open alerts to receive notifications at each session transition. This is particularly useful on instruments where specific sessions (London or New York) have consistent volatility expansion patterns at open.
Indicator Limitations
Originality Statement
Session Pulse is original in its simultaneous three-session gap tracking system with unified cumulative statistics, directional bias calculation, and session boundary visualization integrated into a single tool. This indicator is published because:
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 gap statistics reflect historical data and do not guarantee future gaps will occur with the same frequency, size, or direction. The directional bias percentage is a historical observation, not a predictive probability. Session open behavior is subject to news, earnings, and macroeconomic events that historical statistics do not account for. Always use proper risk management. The author is not responsible for any trading losses resulting from the use of this indicator.
-Made with passion by jackofalltrades
Introduction
Session Pulse is an open-source multi-session gap statistics engine that tracks, categorizes, and accumulates gap data across Asia, London, and New York trading sessions, marks every session boundary transition with labeled vertical lines on the chart, and presents a unified session statistics dashboard. It answers a specific and persistent question that many traders examine manually: how often, in which direction, and by how much does this instrument gap between sessions?
Gap behavior is one of the most systematically consistent patterns across many instruments. Session close-to-open gaps represent a measurable directional displacement — one that either fills (mean reverts) or extends (confirms momentum) in predictable proportions over sufficiently large samples. Session Pulse automates the data collection and visualization for that entire analysis, providing live cumulative statistics on gap frequency, average gap size, maximum gap, and directional bias, refreshed on every bar.
Core Concepts
1. Session Detection
Each of the three sessions (Asia, London, New York) is detected using Pine Script's time() function with a user-configurable session string and timezone. Session transitions are identified by comparing the current bar's session membership to the previous bar's membership. A session start occurs on the first bar where the current bar is inside the session and the previous bar was outside:
inAsia = not na(time(timeframe.period, asiaSess, tzString))
inLondon = not na(time(timeframe.period, londonSess, tzString))
inNY = not na(time(timeframe.period, nySess, tzString))
asiaStart = inAsia and not inAsia[1]
londonStart = inLondon and not inLondon[1]
nyStart = inNY and not inNY[1]
2. Gap Calculation and Categorization
A gap is calculated at each session open as the difference between the current bar's open and the previous bar's close, expressed as a percentage of the previous close. Gaps are categorized as Gap Up (positive gap, open above prior close) or Gap Down (negative gap, open below prior close). A minimum gap percentage threshold filters out negligible noise-level gaps that do not qualify as meaningful session displacements:
gapPct = (open - close[1]) / close[1] * 100
isGapUp = asiaStart and gapPct > minGap
isGapDown = asiaStart and gapPct < -minGap
3. Session Boundary Visualization
At each session start, a vertical dotted line is drawn extending across the chart, and a labeled arrow points down from the top of the price range with the session name (ASIA, LONDON, NEW YORK). This creates a clear visual demarcation of every session boundary on the chart without requiring manual annotation. The lines and labels are drawn live on the current bar and persist across the chart history:
if showSessLns and londonStart
line.new(bar_index, low * 0.9999, bar_index, high * 1.0001,
color=color.new(#01579B, 55), style=line.style_dotted,
width=2, extend=extend.both)
label.new(bar_index, high, "LONDON",
style=label.style_label_down,
color=color.new(#01579B, 50), textcolor=color.white, size=size.tiny)
4. Cumulative Statistics Accumulation
Statistics are accumulated across the full chart history using running counters and accumulators for each direction. For each session type (Asia, London, NY), the indicator tracks: total gap count by direction, cumulative gap size sum for average computation, and the maximum gap in each direction. These statistics build bar by bar and display the full historical picture at any point in time:
if isGapUp
upCount += 1
upTotal += gapPct
upMax := math.max(upMax, gapPct)
5. Unified Statistics Dashboard
A single unified table presents all gap statistics in a structured layout: Gap Up rows at the top, a separator, Gap Down rows below, a final separator, and a summary row showing total gap count and the percentage of gaps that were up (directional bias). The entire table is positioned at a single user-configurable location on the chart, eliminating split-panel layouts:
// Row 0-1: Gap Up (Count, Avg, Max)
// Row 2: Separator
// Row 3-4: Gap Down (Count, Avg, Max)
// Row 5: Separator
// Row 6: Summary (Total, Up Bias %)
Features
- Three-session gap tracking: Asia, London, and New York sessions each independently tracked with configurable session strings
- Session boundary vertical lines: Dotted vertical lines with session name labels (ASIA, LONDON, NEW YORK) at every session transition
- Gap categorization: Gap Up and Gap Down separated by direction with independent counters, average, and maximum for each
- Minimum gap filter: Configurable threshold eliminates negligible gaps below a specified percentage
- Directional bias calculation: Summary row shows Up Bias % — what proportion of all detected gaps have been upward
- Unified statistics table: Single table with Gap Up, separator, Gap Down, separator, and summary rows at a single configurable position
- Table position selector: Top-right, bottom-right, bottom-left, or bottom-center placement
- Session boundary line toggle: Session vertical lines and labels can be independently enabled or disabled
- Configurable session strings: All three session time windows are fully user-adjustable for different broker timezones
- Timezone input: Single timezone string applied consistently to all three session detectors
- Alerts: Six alertconditions — Gap Up and Gap Down for each of the three sessions, plus Asia, London, and New York session open alerts
Input Parameters
Session Settings:
- Timezone: Timezone string for session detection (default: America/New_York)
- Asia Session: Session time string (default: 1800-0000)
- London Session: Session time string (default: 0200-0500)
- New York Session: Session time string (default: 0930-1600)
Gap Detection:
- Min Gap %: Minimum gap size to qualify as a gap event (default: 0.05%)
- Enable Gap Tracking toggles per session
Display:
- Show Session Lines toggle
- Show Stats Table toggle
- Table Position: Top Right, Bottom Right, Bottom Left, Bottom Center
- Session line colors for Asia, London, and New York
How to Use This Indicator
Step 1: Read the Directional Bias
The summary row of the statistics table shows Up Bias % — the percentage of all gaps that have been upward. An Up Bias above 60% on a large sample indicates this instrument has a persistent tendency to gap up at session opens. This is the first, most actionable piece of information from the table.
Step 2: Compare Average Gap Sizes
The average gap rows for Gap Up and Gap Down show the typical magnitude of each type. If the average Gap Down is significantly larger than the average Gap Up, the downside gaps — when they occur — tend to be more violent even if they are less frequent. This asymmetry has implications for stop sizing around session opens.
Step 3: Use Maximum Gap for Range Planning
The maximum gap rows show the largest gap in each direction recorded on the chart. This establishes the worst-case session displacement for this instrument at the current timeframe — useful for setting session-open risk boundaries.
Step 4: Use Session Boundary Lines for Chart Context
The vertical lines with session name labels divide the chart into session periods. On lower timeframes this makes it immediately clear which session each group of bars belongs to, providing context for patterns that occur predominantly in specific sessions.
Step 5: Monitor for Session Open Alerts
Set the session open alerts to receive notifications at each session transition. This is particularly useful on instruments where specific sessions (London or New York) have consistent volatility expansion patterns at open.
Indicator Limitations
- Gap detection measures the open of the first bar inside a session versus the close of the last bar outside the session. On timeframes where session transitions do not align cleanly with bar boundaries, gaps may be slightly misattributed
- On instruments that trade continuously (24/7 crypto) with no actual session close, the concept of a gap between sessions is less meaningful — the session boundaries exist but price does not actually stop between them
- The minimum gap filter is a flat percentage threshold. Instruments with different typical volatility levels require different minimum gap values to produce meaningful categorization
- Statistics accumulate from the beginning of the chart's data history. On very long charts or charts with intraday data going back years, early data may represent a different market regime than the current one, diluting the relevance of cumulative statistics
- This indicator tracks and categorizes gaps. It does not predict gap fill probability, gap extension probability, or provide entry/exit signals
Originality Statement
Session Pulse is original in its simultaneous three-session gap tracking system with unified cumulative statistics, directional bias calculation, and session boundary visualization integrated into a single tool. This indicator is published because:
- Tracking gap statistics across three named, independently configurable sessions simultaneously — with separate counters, averages, and maximums for each direction per session — in a single unified table is uncommon in published open-source Pine Script
- The directional bias percentage (Up Bias %) derived from cumulative historical gap data provides a single, immediately actionable summary statistic that characterizes the instrument's session gap behavior over the entire charted history
- The session boundary vertical lines with labeled session name arrows provide a visual calendar overlay that applies the same session detection logic used for gap calculation to the chart itself, creating consistency between the chart elements and the statistical table
- The unified single-table layout with section separators — merging Gap Up, Gap Down, and summary into one table at one position — avoids the visual fragmentation of split multi-table layouts
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 gap statistics reflect historical data and do not guarantee future gaps will occur with the same frequency, size, or direction. The directional bias percentage is a historical observation, not a predictive probability. Session open behavior is subject to news, earnings, and macroeconomic events that historical statistics do not account for. Always use proper risk management. The author is not responsible for any trading losses resulting from the use of this indicator.
-Made with passion by jackofalltrades
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.