OPEN-SOURCE SCRIPT
SadashiTrading Gap Analyzer

📊 Overview:
Gaps are among the most misunderstood price action phenomena. Most retail traders treat every gap as a "gap fill" opportunity regardless of market structure.
The SadashiTrading Gap Analyzer evaluates historical gaps by contextualizing them through Trend Alignment (SMA) and Volume Expansion (RVOL). Instead of guessing, it calculates historical sample sizes, win rates, average returns, and Profit Factor Asymmetry on the fly.
⚙️ Key Features & Filters:
- Gap Size Threshold (minGapPct): Filters out minor noise and focuses solely on significant overnight imbalances.
- Trend Context (useSmaFilter): Categorizes gaps into With-Trend (continuation) or Against-Trend (mean-reversion) setups using a configurable SMA baseline.
- Volume Context (useRvolFilter): Confirms activity by requiring Relative Volume expansion on the gap day.
- Flexible Horizon Evaluation (evalDays): Analyzes statistical outcomes from same-day close (0) up to 10 trading days post-gap (10).
📈 On-Chart Dynamic Dashboard:
The indicator plots an interactive summary table breaking down 4 distinct market scenarios:
Bull Gap — With Trend (Trend Continuation)
Bull Gap — Against Trend (Counter-trend / Mean Reversion)
Bear Gap — With Trend (Trend Continuation)
Bear Gap — Against Trend (Counter-trend / Mean Reversion)
Tracked Metrics per Scenario:
Samples: Total historical occurrences matching the exact criteria.
Win Rate: Percentage of observations yielding positive return over the evaluation window.
Avg Return: Mean performance per trade.
Profit Factor: Gross profit relative to gross loss
⚠️ Important Methodology & Model Limitations
- Context Model vs. Execution Backtest: This indicator measures directional context bias, not live execution PnL. Performance is evaluated simplistically from Open to Close.
- No Intra-Session Risk Management: It does not account for intraday drawdowns, stop-losses, or take-profit targets. Intraday price path metrics (MAE/MFE) are excluded.
- Friction & Slippage: Does not include broker fees or market-open slippage around the 09:30 EST bell.
Gaps are among the most misunderstood price action phenomena. Most retail traders treat every gap as a "gap fill" opportunity regardless of market structure.
The SadashiTrading Gap Analyzer evaluates historical gaps by contextualizing them through Trend Alignment (SMA) and Volume Expansion (RVOL). Instead of guessing, it calculates historical sample sizes, win rates, average returns, and Profit Factor Asymmetry on the fly.
⚙️ Key Features & Filters:
- Gap Size Threshold (minGapPct): Filters out minor noise and focuses solely on significant overnight imbalances.
- Trend Context (useSmaFilter): Categorizes gaps into With-Trend (continuation) or Against-Trend (mean-reversion) setups using a configurable SMA baseline.
- Volume Context (useRvolFilter): Confirms activity by requiring Relative Volume expansion on the gap day.
- Flexible Horizon Evaluation (evalDays): Analyzes statistical outcomes from same-day close (0) up to 10 trading days post-gap (10).
📈 On-Chart Dynamic Dashboard:
The indicator plots an interactive summary table breaking down 4 distinct market scenarios:
Bull Gap — With Trend (Trend Continuation)
Bull Gap — Against Trend (Counter-trend / Mean Reversion)
Bear Gap — With Trend (Trend Continuation)
Bear Gap — Against Trend (Counter-trend / Mean Reversion)
Tracked Metrics per Scenario:
Samples: Total historical occurrences matching the exact criteria.
Win Rate: Percentage of observations yielding positive return over the evaluation window.
Avg Return: Mean performance per trade.
Profit Factor: Gross profit relative to gross loss
⚠️ Important Methodology & Model Limitations
- Context Model vs. Execution Backtest: This indicator measures directional context bias, not live execution PnL. Performance is evaluated simplistically from Open to Close.
- No Intra-Session Risk Management: It does not account for intraday drawdowns, stop-losses, or take-profit targets. Intraday price path metrics (MAE/MFE) are excluded.
- Friction & Slippage: Does not include broker fees or market-open slippage around the 09:30 EST bell.
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.
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.
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.