OPEN-SOURCE SCRIPT
Fade Setup Overlays

WHAT IT IS
Fade Setup Overlays is a chart readout for crypto perpetual futures. It tracks one specific pattern: a "fade" setup that can form after a strong momentum leg. It shows the current state of that pattern in a small table, plus three context flags, and can raise an alert when the state changes. It runs on either side of the market: fade highs (short-side setup) or fade lows (long-side setup).
It is an execution aid for reading the chart. It is not a signal service, not a strategy, and not an edge. Nothing here predicts price. "Short-side" and "long-side" name the direction of the setup being tracked; they are descriptions of chart state, not recommendations to trade.
HOW IT WORKS
The indicator runs a small state machine. The first condition that matches sets the mode:
- CHOP: ADX(14) on the last completed regime-timeframe bar is below the unlock threshold (default 25). The setup is not tracked.
- IMPULSE LEG: the regime ADX is unlocked and the swing extreme was set very recently, with no reversal bar.
- FADE ARMED: the swing extreme is fresh (default: within 4 reference hours), price is still within a set % of it (default 2.5%), and no reversal bar has printed.
- FADE WINDOW: a reversal bar printed while the extreme is fresh and price is within 3% of it.
- EXTENDED: price has already moved more than 2.5% away from the extreme.
- COOLING: none of the above.
The Side input picks the direction. Short (fade highs) tracks the highest high of the window and a reversal-down bar (a lower high that closes below the previous bar's low). Long (fade lows) mirrors everything: the lowest low of the window and a reversal-up bar (a higher low that closes above the previous bar's high). The three flags mirror too.
Each mode label comes with a short neutral description. On the chart, the script plots the swing-extreme watermark and a small triangle on reversal bars that print inside the fresh-extreme window.
TIMEFRAMES
The setup is defined in "reference hours" on a 15m chart: a 12h extreme, a 2h CVD window, a 24h premium z-score window, and a 1h ADX regime gate. With Auto-scale on (the default) every window is multiplied by chart-minutes / 15 and the regime timeframe moves one rung above the chart, so the readout keeps the same proportions on any chart from 1m to 1D:
- 15m chart: 12h extreme, 2h CVD, 24h z-score, 1h regime ADX, 1m intrabars
- 1h chart: 48h extreme, 8h CVD, 4d z-score, 4h regime ADX, 5m intrabars
- 4h chart: 8d extreme, 32h CVD, 16d z-score, 1D regime ADX, 15m intrabars
- 1D chart: 48d extreme, 8d CVD, 96d z-score, 1W regime ADX, 1h intrabars
Turn Auto-scale off to use the literal hour values on every chart. The table labels show the actual windows in use (for example "1D ADX" and "8d hi" on a 4h chart).
THE THREE OVERLAY FLAGS (ALL PROXIES)
Each flag is shown as ✓ (condition present), · (absent) or ? (data unavailable).
1. CVD-div (proxy): net signed volume over the CVD window leading into the extreme bar. The script pulls lower-timeframe bars with request.security_lower_tf and signs each bar's volume by its candle direction. Short side: ✓ when the net is flat or negative into the high. Long side: ✓ when the net is flat or positive into the low.
2. prem-z (proxy): the perp-vs-spot close spread, (perp - spot) / spot, z-scored against its trailing window. Short side: ✓ when the z-score went above +1.5 inside the CVD window. Long side: ✓ when it went below -1.5.
3. OI-stall (proxy): TradingView's open-interest symbol for the perp. ✓ when current open interest is below open interest at the extreme bar, on either side.
Honesty note: exchange-native CVD, perp premium and open-interest feeds are built from data TradingView cannot load. These proxies are directionally similar to those feeds but numerically different. Treat them as context, not ground truth.
The flags use a tri-state int (-1 unknown / 0 no / 1 yes) because a Pine v6 bool cannot hold na. That keeps missing data visible as "?" instead of turning it into a silent "no".
ALERTS
Alerts fire only when the state changes, not on every bar the state is true. They describe a chart state and nothing more.
Option A, one alert for everything: create a single alert on this indicator with the event "Any alert() function call" and the trigger "Once per bar close". The script formats the message itself. In "Readable text" mode the message carries the side, the state, the close, the extreme with its age and distance, the regime ADX, and the three flags. In "JSON (webhook)" mode each event is one JSON object ("action" = open on FADE WINDOW, close_all on INVALIDATED, and optionally info on FADE ARMED) with the same fields, for people who already run their own webhook receiver. The position_size_pct, leverage and secret fields in JSON mode are plain inputs passed through verbatim; the script never sizes, places, or sends anything itself. TradingView delivers whatever the alert is pointed at.
Option B, one alert per event: six alertcondition() events (Short/Long × FADE ARMED, FADE WINDOW opened, INVALIDATED) for anyone who prefers separate alerts.
INPUTS
Setup
- Side: Short (fade highs) or Long (fade lows).
- Regime ADX unlock threshold (25): below this, the mode is CHOP.
- Extreme freshness, hours at 15m (4): how recent the extreme must be for FADE ARMED / FADE WINDOW. Auto-scales.
- Max % from extreme to stay armed (2.5): the distance limit for FADE ARMED. Not auto-scaled; widen it by hand on 4h/1D if needed.
Scale
- Auto-scale windows to chart timeframe (on).
- Extreme lookback, CVD window, premium z window, all in hours at 15m (12 / 2 / 24).
- Regime ADX timeframe: leave on "Chart" for automatic (one rung above the chart), or set it by hand. It must be higher than the chart timeframe.
Overlays
- Spot symbol: leave blank to derive it from the chart (BINANCE:SOLUSDT.P becomes BINANCE:SOLUSDT), or type the spot pair by hand.
- Open-interest symbol: leave blank to derive it from the chart (BINANCE:SOLUSDT.P_OI), or type it by hand.
- CVD lower timeframe: leave on "Chart" for automatic (1m / 5m / 15m / 1h by chart timeframe), or set it by hand.
Alerts
- Combined alert() on/off, include INVALIDATED events, an optional personal note appended to text alerts, message format (Readable text / JSON), and the JSON pass-through fields.
Visuals
- Table position, text sizes, cell padding, compact labels, and a credit row toggle.
SETUP
1. Open a crypto perpetual chart on any timeframe from 1m to 1D. Example: BINANCE:SOLUSDT.P on 15m or 4h.
2. Add the indicator and pick the Side.
3. If a flag stays at "?", open the inputs and set the spot symbol and open-interest symbol by hand. Use Symbol Search: the spot pair from the same exchange as your perp, and "<asset> open interest" for OI.
4. Optional: create one alert on "Any alert() function call", trigger "Once per bar close".
LIMITATIONS
- Timeframes: 1m to 1D only. Multi-day, weekly and monthly charts stop with an error message, because the windows are computed from minutes per bar.
- Intrabar depth: TradingView keeps limited lower-timeframe history and caps intrabar requests at 100,000 bars, so CVD-div reads "?" on older bars. The automatic CVD timeframe is chosen to keep that history usable on each chart timeframe.
- OI availability: not every perp has a TradingView open-interest symbol. Where none loads, OI-stall reads "?".
- Proxies: all three flags approximate exchange-native data and will differ from it.
- Regime ADX: requested from the higher timeframe as an offset expression (value[1]) with lookahead on, which is the non-repainting form recommended by PineCoders. It returns only completed higher-timeframe bars and carries no lookahead bias.
- Repainting: the reversal bar, flags and mode are computed on the chart's bars, so on the live bar they can change until that bar closes. That is why alerts use "Once per bar close". Nothing beyond this is guaranteed.
- The percentage thresholds (2.5% and 3%) are not auto-scaled with the timeframe.
- The table shows the last bar only. It is not a backtest and makes no statement about outcomes.
DISCLAIMER
Educational use only. Not financial advice. Do your own research. This script is a chart readout and makes no performance claims. Crypto perpetual futures are high risk, and leverage can lose more than the initial margin. The author may hold positions in the assets discussed.
LICENSE
Open-source under the Mozilla Public License 2.0. Free to use, study and fork; attribution is appreciated.
Fade Setup Overlays is a chart readout for crypto perpetual futures. It tracks one specific pattern: a "fade" setup that can form after a strong momentum leg. It shows the current state of that pattern in a small table, plus three context flags, and can raise an alert when the state changes. It runs on either side of the market: fade highs (short-side setup) or fade lows (long-side setup).
It is an execution aid for reading the chart. It is not a signal service, not a strategy, and not an edge. Nothing here predicts price. "Short-side" and "long-side" name the direction of the setup being tracked; they are descriptions of chart state, not recommendations to trade.
HOW IT WORKS
The indicator runs a small state machine. The first condition that matches sets the mode:
- CHOP: ADX(14) on the last completed regime-timeframe bar is below the unlock threshold (default 25). The setup is not tracked.
- IMPULSE LEG: the regime ADX is unlocked and the swing extreme was set very recently, with no reversal bar.
- FADE ARMED: the swing extreme is fresh (default: within 4 reference hours), price is still within a set % of it (default 2.5%), and no reversal bar has printed.
- FADE WINDOW: a reversal bar printed while the extreme is fresh and price is within 3% of it.
- EXTENDED: price has already moved more than 2.5% away from the extreme.
- COOLING: none of the above.
The Side input picks the direction. Short (fade highs) tracks the highest high of the window and a reversal-down bar (a lower high that closes below the previous bar's low). Long (fade lows) mirrors everything: the lowest low of the window and a reversal-up bar (a higher low that closes above the previous bar's high). The three flags mirror too.
Each mode label comes with a short neutral description. On the chart, the script plots the swing-extreme watermark and a small triangle on reversal bars that print inside the fresh-extreme window.
TIMEFRAMES
The setup is defined in "reference hours" on a 15m chart: a 12h extreme, a 2h CVD window, a 24h premium z-score window, and a 1h ADX regime gate. With Auto-scale on (the default) every window is multiplied by chart-minutes / 15 and the regime timeframe moves one rung above the chart, so the readout keeps the same proportions on any chart from 1m to 1D:
- 15m chart: 12h extreme, 2h CVD, 24h z-score, 1h regime ADX, 1m intrabars
- 1h chart: 48h extreme, 8h CVD, 4d z-score, 4h regime ADX, 5m intrabars
- 4h chart: 8d extreme, 32h CVD, 16d z-score, 1D regime ADX, 15m intrabars
- 1D chart: 48d extreme, 8d CVD, 96d z-score, 1W regime ADX, 1h intrabars
Turn Auto-scale off to use the literal hour values on every chart. The table labels show the actual windows in use (for example "1D ADX" and "8d hi" on a 4h chart).
THE THREE OVERLAY FLAGS (ALL PROXIES)
Each flag is shown as ✓ (condition present), · (absent) or ? (data unavailable).
1. CVD-div (proxy): net signed volume over the CVD window leading into the extreme bar. The script pulls lower-timeframe bars with request.security_lower_tf and signs each bar's volume by its candle direction. Short side: ✓ when the net is flat or negative into the high. Long side: ✓ when the net is flat or positive into the low.
2. prem-z (proxy): the perp-vs-spot close spread, (perp - spot) / spot, z-scored against its trailing window. Short side: ✓ when the z-score went above +1.5 inside the CVD window. Long side: ✓ when it went below -1.5.
3. OI-stall (proxy): TradingView's open-interest symbol for the perp. ✓ when current open interest is below open interest at the extreme bar, on either side.
Honesty note: exchange-native CVD, perp premium and open-interest feeds are built from data TradingView cannot load. These proxies are directionally similar to those feeds but numerically different. Treat them as context, not ground truth.
The flags use a tri-state int (-1 unknown / 0 no / 1 yes) because a Pine v6 bool cannot hold na. That keeps missing data visible as "?" instead of turning it into a silent "no".
ALERTS
Alerts fire only when the state changes, not on every bar the state is true. They describe a chart state and nothing more.
Option A, one alert for everything: create a single alert on this indicator with the event "Any alert() function call" and the trigger "Once per bar close". The script formats the message itself. In "Readable text" mode the message carries the side, the state, the close, the extreme with its age and distance, the regime ADX, and the three flags. In "JSON (webhook)" mode each event is one JSON object ("action" = open on FADE WINDOW, close_all on INVALIDATED, and optionally info on FADE ARMED) with the same fields, for people who already run their own webhook receiver. The position_size_pct, leverage and secret fields in JSON mode are plain inputs passed through verbatim; the script never sizes, places, or sends anything itself. TradingView delivers whatever the alert is pointed at.
Option B, one alert per event: six alertcondition() events (Short/Long × FADE ARMED, FADE WINDOW opened, INVALIDATED) for anyone who prefers separate alerts.
INPUTS
Setup
- Side: Short (fade highs) or Long (fade lows).
- Regime ADX unlock threshold (25): below this, the mode is CHOP.
- Extreme freshness, hours at 15m (4): how recent the extreme must be for FADE ARMED / FADE WINDOW. Auto-scales.
- Max % from extreme to stay armed (2.5): the distance limit for FADE ARMED. Not auto-scaled; widen it by hand on 4h/1D if needed.
Scale
- Auto-scale windows to chart timeframe (on).
- Extreme lookback, CVD window, premium z window, all in hours at 15m (12 / 2 / 24).
- Regime ADX timeframe: leave on "Chart" for automatic (one rung above the chart), or set it by hand. It must be higher than the chart timeframe.
Overlays
- Spot symbol: leave blank to derive it from the chart (BINANCE:SOLUSDT.P becomes BINANCE:SOLUSDT), or type the spot pair by hand.
- Open-interest symbol: leave blank to derive it from the chart (BINANCE:SOLUSDT.P_OI), or type it by hand.
- CVD lower timeframe: leave on "Chart" for automatic (1m / 5m / 15m / 1h by chart timeframe), or set it by hand.
Alerts
- Combined alert() on/off, include INVALIDATED events, an optional personal note appended to text alerts, message format (Readable text / JSON), and the JSON pass-through fields.
Visuals
- Table position, text sizes, cell padding, compact labels, and a credit row toggle.
SETUP
1. Open a crypto perpetual chart on any timeframe from 1m to 1D. Example: BINANCE:SOLUSDT.P on 15m or 4h.
2. Add the indicator and pick the Side.
3. If a flag stays at "?", open the inputs and set the spot symbol and open-interest symbol by hand. Use Symbol Search: the spot pair from the same exchange as your perp, and "<asset> open interest" for OI.
4. Optional: create one alert on "Any alert() function call", trigger "Once per bar close".
LIMITATIONS
- Timeframes: 1m to 1D only. Multi-day, weekly and monthly charts stop with an error message, because the windows are computed from minutes per bar.
- Intrabar depth: TradingView keeps limited lower-timeframe history and caps intrabar requests at 100,000 bars, so CVD-div reads "?" on older bars. The automatic CVD timeframe is chosen to keep that history usable on each chart timeframe.
- OI availability: not every perp has a TradingView open-interest symbol. Where none loads, OI-stall reads "?".
- Proxies: all three flags approximate exchange-native data and will differ from it.
- Regime ADX: requested from the higher timeframe as an offset expression (value[1]) with lookahead on, which is the non-repainting form recommended by PineCoders. It returns only completed higher-timeframe bars and carries no lookahead bias.
- Repainting: the reversal bar, flags and mode are computed on the chart's bars, so on the live bar they can change until that bar closes. That is why alerts use "Once per bar close". Nothing beyond this is guaranteed.
- The percentage thresholds (2.5% and 3%) are not auto-scaled with the timeframe.
- The table shows the last bar only. It is not a backtest and makes no statement about outcomes.
DISCLAIMER
Educational use only. Not financial advice. Do your own research. This script is a chart readout and makes no performance claims. Crypto perpetual futures are high risk, and leverage can lose more than the initial margin. The author may hold positions in the assets discussed.
LICENSE
Open-source under the Mozilla Public License 2.0. Free to use, study and fork; attribution is appreciated.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Open-source Pine tools and systematic-trading research. Discussion: discord.gg/AAGQTPxkwa
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Open-source Pine tools and systematic-trading research. Discussion: discord.gg/AAGQTPxkwa
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.