OPEN-SOURCE SCRIPT
Dynamic Gap Probability Tool with N-Bar Decay

📌 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.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Trade forex, indices, stocks and metals with up to US$100.000 in company's funding.
Complete a challenge to access funding or go for instant deposit.
Trading involves substantial risk. Not financial advice
Complete a challenge to access funding or go for instant deposit.
Trading involves substantial risk. Not financial advice
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Trade forex, indices, stocks and metals with up to US$100.000 in company's funding.
Complete a challenge to access funding or go for instant deposit.
Trading involves substantial risk. Not financial advice
Complete a challenge to access funding or go for instant deposit.
Trading involves substantial risk. Not financial advice
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.