OPEN-SOURCE SCRIPT
Adaptive Entry: RSI & SMA With Debounce

Short description
Adaptive long-entry timing using RSI on a higher timeframe and an SMA ±band price filter, with optional no-repaint confirmation and debounce.
Long description
What it does
This study helps time long entries by combining:
RSI on a selected higher-timeframe (HTF), and
A price filter relative to an SMA ± band on the same HTF,
plus a debounce so you don’t get rapid-fire signals. It includes an optional “confirm on HTF close” mode to avoid repainting.
Core logic (long bias only)
Compute HTF RSI and HTF SMA for the chart symbol (no external market filter).
Build an upper/lower band around the SMA using a user-defined fraction (e.g., 0.05 = ±5%).
Entry state = true when:
RSI(HTF) is below the threshold (oversold/weak),
Price (HTF) is inside the band (or within your chosen price-vs-band rule),
(Optional) the signal is confirmed on HTF bar close (no-repaint).
Cross event is the first bar where the state turns true and at least N bars have passed since the previous signal (debounce).
Why it doesn’t repaint (when enabled)
All HTF values are requested with lookahead_off.
With Confirm on HTF bar close checked, a signal is only accepted after the HTF candle closes.
Inputs
Signal timeframe (HTF) – default 1D.
RSI length / RSI threshold – e.g., 14 / 45.
SMA length – default 50.
SMA ± band (fraction) – e.g., 0.05 → ±5% around SMA.
Confirm on HTF bar close – toggles no-repaint behavior.
Debounce: min bars between signals – e.g., 3.
Price filter vs band – choose one:
Inside band only (strict)
Inside or below LB (lenient / value)
Re-entering band from below (pullback into strength)
Show SMA ± band fill / Show debug label – visuals.
Visuals
HTF SMA with shaded ±band.
A small ▲ below bars on Cross events (debounced first-true signals).
Optional compact debug label (HTF, RSI, distance to SMA, debounce setting).
Alerts
BUY (State) – stays true while conditions are met (can remain on across multiple bars).
Use when you want continuous awareness that the setup is live.
BUY (Cross event) – fires once on the first bar the state turns true and debounce is satisfied.
Use when you want a single, actionable “go” ping.
Best practices
HTF = 1D on intraday charts works well for swing entries.
Tune RSI threshold: lower values = deeper pullbacks, fewer signals.
Tune band fraction: 0.03–0.08 often balances sensitivity vs. whipsaw.
If you trade ETFs that only alert in regular hours, consider running alerts on a 24/5 proxy (e.g., ES1!/SPCFD) and executing on your ETF.
Limitations
Long-only logic by design.
Signals depend on HTF selection and data availability for your symbol/feed.
Extended-hours alerting depends on the instrument (ETFs are often RTH-only on TV).
Suggested default settings
HTF: 1 day
RSI: 14, Threshold 45
SMA: 50
Band fraction: 0.05
Confirm on HTF close: ON
Debounce: 3 bars
Price filter: Inside or below LB
Show band fill & debug label: ON
How to use (quick start)
Add to chart and pick your HTF.
Set RSI threshold (start with 45).
Choose your band fraction (start with 0.05).
Keep Confirm on HTF close ON if you want no-repaint signals.
Create an alert:
BUY (Cross event) for one-shot actionable alerts, or
BUY (State) for persistent “setup is active” monitoring.
Tags / categories
Category: Indicators → Trend / Momentum
Tags: RSI, SMA, Pullback, Mean Reversion, Swing, Higher Timeframe, Debounce, No-Repaint
Adaptive long-entry timing using RSI on a higher timeframe and an SMA ±band price filter, with optional no-repaint confirmation and debounce.
Long description
What it does
This study helps time long entries by combining:
RSI on a selected higher-timeframe (HTF), and
A price filter relative to an SMA ± band on the same HTF,
plus a debounce so you don’t get rapid-fire signals. It includes an optional “confirm on HTF close” mode to avoid repainting.
Core logic (long bias only)
Compute HTF RSI and HTF SMA for the chart symbol (no external market filter).
Build an upper/lower band around the SMA using a user-defined fraction (e.g., 0.05 = ±5%).
Entry state = true when:
RSI(HTF) is below the threshold (oversold/weak),
Price (HTF) is inside the band (or within your chosen price-vs-band rule),
(Optional) the signal is confirmed on HTF bar close (no-repaint).
Cross event is the first bar where the state turns true and at least N bars have passed since the previous signal (debounce).
Why it doesn’t repaint (when enabled)
All HTF values are requested with lookahead_off.
With Confirm on HTF bar close checked, a signal is only accepted after the HTF candle closes.
Inputs
Signal timeframe (HTF) – default 1D.
RSI length / RSI threshold – e.g., 14 / 45.
SMA length – default 50.
SMA ± band (fraction) – e.g., 0.05 → ±5% around SMA.
Confirm on HTF bar close – toggles no-repaint behavior.
Debounce: min bars between signals – e.g., 3.
Price filter vs band – choose one:
Inside band only (strict)
Inside or below LB (lenient / value)
Re-entering band from below (pullback into strength)
Show SMA ± band fill / Show debug label – visuals.
Visuals
HTF SMA with shaded ±band.
A small ▲ below bars on Cross events (debounced first-true signals).
Optional compact debug label (HTF, RSI, distance to SMA, debounce setting).
Alerts
BUY (State) – stays true while conditions are met (can remain on across multiple bars).
Use when you want continuous awareness that the setup is live.
BUY (Cross event) – fires once on the first bar the state turns true and debounce is satisfied.
Use when you want a single, actionable “go” ping.
Best practices
HTF = 1D on intraday charts works well for swing entries.
Tune RSI threshold: lower values = deeper pullbacks, fewer signals.
Tune band fraction: 0.03–0.08 often balances sensitivity vs. whipsaw.
If you trade ETFs that only alert in regular hours, consider running alerts on a 24/5 proxy (e.g., ES1!/SPCFD) and executing on your ETF.
Limitations
Long-only logic by design.
Signals depend on HTF selection and data availability for your symbol/feed.
Extended-hours alerting depends on the instrument (ETFs are often RTH-only on TV).
Suggested default settings
HTF: 1 day
RSI: 14, Threshold 45
SMA: 50
Band fraction: 0.05
Confirm on HTF close: ON
Debounce: 3 bars
Price filter: Inside or below LB
Show band fill & debug label: ON
How to use (quick start)
Add to chart and pick your HTF.
Set RSI threshold (start with 45).
Choose your band fraction (start with 0.05).
Keep Confirm on HTF close ON if you want no-repaint signals.
Create an alert:
BUY (Cross event) for one-shot actionable alerts, or
BUY (State) for persistent “setup is active” monitoring.
Tags / categories
Category: Indicators → Trend / Momentum
Tags: RSI, SMA, Pullback, Mean Reversion, Swing, Higher Timeframe, Debounce, No-Repaint
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.