OPEN-SOURCE SCRIPT
Gap Analyzer[KG]

Overview:
Gap Analyzer is a statistical research tool that scans every bar on your chart, identifies significant gap-down and gap-up events beyond a user-defined threshold, and summarizes what historically happens inside those gap bars — from open to high, open to low, and open to close.
What is a Gap?
A gap occurs when a bar's open is meaningfully higher or lower than the prior bar's close, leaving an empty zone on the chart with no traded price. This indicator flags:
Gap Down — when (Open − Prior Close) / Prior Close × 100 is at or below your threshold (default: −1%)
Gap Up — when the same calculation is at or above your threshold (default: +1%)
Visual Markers on the Chart:
Every qualifying gap is marked directly on the price pane with three layers:
Gap Zone Box — a semi-transparent dashed box fills the exact price area between the prior close and the current open, making the gap size immediately visible
Bar Highlight — a subtle background tint on the gap bar itself (red for gap down, teal for gap up)
Arrow + Label — a triangle arrow above/below the bar paired with the exact gap percentage printed inside the gap zone box (e.g. −6.43% or +5.91%)
Statistical Tables:
Two summary tables are rendered in the price pane — one for gap downs (bottom right by default) and one for gap ups (opposite corner). Each table contains 10 columns across 3 rows:
Gap Down Table:
Column Meaning Coun Total number of gap-down bars detectedΦGapAverage gap size across all qualifying bars O>C %% of gap-down bars that closed bearish (continuation) ΦO→HAverage % move from Open to High on continuation barsΦO→LAverage % move from Open to Low on continuation bars ΦO→CAverage % move from Open to Close on continuation bars O<C %% of gap-down bars that closed bullish (bounce )ΦO→HAverage % move from Open to High on bounce bars ΦO→LAverage % move from Open to Low on bounce bars ΦO→CAverage % move from Open to Close on bounce bars
Gap Up Table mirrors the same logic with:
Gap Continuation ↑ — bars where the gap-up day also closed bullish (O < C)
Gap Fade ↓ — bars where the gap-up day reversed and closed bearish (O > C)
All percentage values are colour-coded — teal for positive, red for negative — for instant readability.
The Φ Notation-
The symbol Φ (Phi) denotes an average (mean) across all qualifying bars in that category. So ΦO→H means "the average percentage move from the Open to the High across all gap bars in this group" — a measure of how much intraday upside was available on average after the gap open.
Inputs:
Input Default Description Gap-Down Threshold−5%Minimum gap size to qualify as a gap down Gap-Up Threshold+5%Minimum gap size to qualify as a gap up Table Position Bottom Right Where to anchor the gap-down table (gap-up table auto-mirrors) Show Gap % Label On Toggles the arrow and % label on each gap bar
Use Cases:
Intraday traders — know statistically how far price tends to travel from open toward the high or low after a gap, helping size entries and targets
Swing traders — quickly assess whether gaps on your instrument tend to fill (bounce) or continue, and by how much on average
Back testing context — apply to any timeframe and ticker to build a historical gap behavior profile before trading a live gap event
Notes:
Works on any ticker and any timeframe
All statistics are computed from the full visible history loaded on the chart; extending your chart history will give more robust sample sizes
Past statistical behavior does not guarantee future results — use as context, not as a signal in isolation
Gap Analyzer is a statistical research tool that scans every bar on your chart, identifies significant gap-down and gap-up events beyond a user-defined threshold, and summarizes what historically happens inside those gap bars — from open to high, open to low, and open to close.
What is a Gap?
A gap occurs when a bar's open is meaningfully higher or lower than the prior bar's close, leaving an empty zone on the chart with no traded price. This indicator flags:
Gap Down — when (Open − Prior Close) / Prior Close × 100 is at or below your threshold (default: −1%)
Gap Up — when the same calculation is at or above your threshold (default: +1%)
Visual Markers on the Chart:
Every qualifying gap is marked directly on the price pane with three layers:
Gap Zone Box — a semi-transparent dashed box fills the exact price area between the prior close and the current open, making the gap size immediately visible
Bar Highlight — a subtle background tint on the gap bar itself (red for gap down, teal for gap up)
Arrow + Label — a triangle arrow above/below the bar paired with the exact gap percentage printed inside the gap zone box (e.g. −6.43% or +5.91%)
Statistical Tables:
Two summary tables are rendered in the price pane — one for gap downs (bottom right by default) and one for gap ups (opposite corner). Each table contains 10 columns across 3 rows:
Gap Down Table:
Column Meaning Coun Total number of gap-down bars detectedΦGapAverage gap size across all qualifying bars O>C %% of gap-down bars that closed bearish (continuation) ΦO→HAverage % move from Open to High on continuation barsΦO→LAverage % move from Open to Low on continuation bars ΦO→CAverage % move from Open to Close on continuation bars O<C %% of gap-down bars that closed bullish (bounce )ΦO→HAverage % move from Open to High on bounce bars ΦO→LAverage % move from Open to Low on bounce bars ΦO→CAverage % move from Open to Close on bounce bars
Gap Up Table mirrors the same logic with:
Gap Continuation ↑ — bars where the gap-up day also closed bullish (O < C)
Gap Fade ↓ — bars where the gap-up day reversed and closed bearish (O > C)
All percentage values are colour-coded — teal for positive, red for negative — for instant readability.
The Φ Notation-
The symbol Φ (Phi) denotes an average (mean) across all qualifying bars in that category. So ΦO→H means "the average percentage move from the Open to the High across all gap bars in this group" — a measure of how much intraday upside was available on average after the gap open.
Inputs:
Input Default Description Gap-Down Threshold−5%Minimum gap size to qualify as a gap down Gap-Up Threshold+5%Minimum gap size to qualify as a gap up Table Position Bottom Right Where to anchor the gap-down table (gap-up table auto-mirrors) Show Gap % Label On Toggles the arrow and % label on each gap bar
Use Cases:
Intraday traders — know statistically how far price tends to travel from open toward the high or low after a gap, helping size entries and targets
Swing traders — quickly assess whether gaps on your instrument tend to fill (bounce) or continue, and by how much on average
Back testing context — apply to any timeframe and ticker to build a historical gap behavior profile before trading a live gap event
Notes:
Works on any ticker and any timeframe
All statistics are computed from the full visible history loaded on the chart; extending your chart history will give more robust sample sizes
Past statistical behavior does not guarantee future results — use as context, not as a signal in isolation
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。