OPEN-SOURCE SCRIPT

Dynamic Gap Probability Tool with N-Bar Decay

52
📌 How It Works
1. Moving Average (MA) Reference
o The indicator plots a moving average (SMA, EMA, WMA, etc.) on the chart.
o Price can be above or below this moving average.
2. Probability Tracking
o Every time a bar closes, the script records:
 Whether the next candle closed up (green) or down (red).
 Whether within the next N bars (e.g., 3 bars ahead) the price moved higher or lower than the current close.
3. N Bar Lookahead
o Instead of only caring about the very next candle, it looks forward several bars to see if the market eventually moves in your favor.
o Example: If N = 3, it answers:
"Within the next 3 bars, what’s the chance price will go higher/lower from here?"
4. Results Table
o At the edge of your chart, the table shows:
 ✅ Next Green % – Probability next candle is bullish.
 ❌ Next Red % – Probability next candle is bearish.
 📈 N Bar Bull % – Probability that within N bars, price goes higher.
 📉 N Bar Bear % – Probability that within N bars, price goes lower.
💡 Why It’s Useful for Traders
• Removes Guesswork – Instead of relying on “gut feeling,” you see historical probabilities for how price reacts when above/below the MA.
• Better Trade Timing – If N Bar Bullish Probability is high, it suggests waiting for confirmation and holding longer than just 1 candle.
• Adapts to Style –
o Scalpers: Use N = 1 to see immediate probabilities.
o Swing Traders: Use N = 3, 5, or 10 to see longer-term reaction probabilities.
• Trend Awareness – Works differently above and below the moving average, giving you a bias toward long or short trades.
• Confidence in Decisions – Probabilities are based on real past data from the chart’s history.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.