OPEN-SOURCE SCRIPT
Updated Long/Short (Corr+Trend+RSI+ADX)

Purpose
This indicator outputs a single trading regime — LONG ONLY, SHORT ONLY, or NEUTRAL — using a weighted model that blends: correlation to Bitcoin, local trend (EMA cross), RSI state, and trend strength via ADX (+DI/−DI). The goal is to cut market noise and provide a clear directional bias.
How it Works
Corr × BTC — Computes return correlation to BTC and multiplies it by BTC’s trend direction (EMA50 vs EMA200). Positively correlated assets follow BTC’s bias; negatively correlated assets invert it.
Trend — Local trend of the asset via EMA(50) vs EMA(200).
RSI — Soft mapping into bearish/neutral/bullish contribution (above the upper band → bullish, below the lower band → bearish).
ADX Block — Trend strength and bias from +DI/−DI (implemented manually via DM/TR/RMA).
All components are weighted and summed into a score; thresholds map the score to the trading regime.
Signals & Visuals
LONG ONLY — subtle green background; up-arrow on regime change.
SHORT ONLY — subtle red background; down-arrow on regime change.
NEUTRAL — muted background, no arrows.
Compact dashboard (top-right) shows regime, total score, and each component’s contribution.
Key Inputs
Benchmark (BTC) — symbol used for correlation (default: BTCUSDT).
Correlation length — window for return correlation.
EMA fast / EMA slow — trend parameters (defaults: 50/200).
RSI period / upper / lower — RSI settings and zone thresholds.
ADX period / threshold — strength measurement parameters.
Weights — per-block influence (Corr, Trend, RSI, ADX).
Decision thresholds — score cutoffs for LONG/SHORT.
Alerts
Go LONG (new signal) — regime flips into LONG.
Go SHORT (new signal) — regime flips into SHORT.
Back to NEUTRAL — regime returns to neutral.
(Define your alert message in the Alerts dialog.)
Usage Guidance
Trade in the direction of the active regime:
LONG ONLY — favor long entries/re-entries; avoid shorts.
SHORT ONLY — favor shorts; avoid longs.
NEUTRAL — reduce risk and wait for confirmation.
Combine with S/R or consolidation zones: trigger entries only when price interacts with your zones in alignment with the regime.
For altcoins, tune weights and thresholds; high-beta markets may need lower decision thresholds.
Tuning Tips
Want more signals? Lower Go LONG/SHORT thresholds or increase weights.
Want stricter signals? Raise thresholds or reduce weights.
If the asset weakly correlates with BTC, reduce Corr weight and emphasize Trend/ADX.
Limitations & Disclaimer
This is a directional filter, not a full trade system. Always apply risk management and confirm on multiple timeframes. Past performance does not guarantee future results.
This indicator outputs a single trading regime — LONG ONLY, SHORT ONLY, or NEUTRAL — using a weighted model that blends: correlation to Bitcoin, local trend (EMA cross), RSI state, and trend strength via ADX (+DI/−DI). The goal is to cut market noise and provide a clear directional bias.
How it Works
Corr × BTC — Computes return correlation to BTC and multiplies it by BTC’s trend direction (EMA50 vs EMA200). Positively correlated assets follow BTC’s bias; negatively correlated assets invert it.
Trend — Local trend of the asset via EMA(50) vs EMA(200).
RSI — Soft mapping into bearish/neutral/bullish contribution (above the upper band → bullish, below the lower band → bearish).
ADX Block — Trend strength and bias from +DI/−DI (implemented manually via DM/TR/RMA).
All components are weighted and summed into a score; thresholds map the score to the trading regime.
Signals & Visuals
LONG ONLY — subtle green background; up-arrow on regime change.
SHORT ONLY — subtle red background; down-arrow on regime change.
NEUTRAL — muted background, no arrows.
Compact dashboard (top-right) shows regime, total score, and each component’s contribution.
Key Inputs
Benchmark (BTC) — symbol used for correlation (default: BTCUSDT).
Correlation length — window for return correlation.
EMA fast / EMA slow — trend parameters (defaults: 50/200).
RSI period / upper / lower — RSI settings and zone thresholds.
ADX period / threshold — strength measurement parameters.
Weights — per-block influence (Corr, Trend, RSI, ADX).
Decision thresholds — score cutoffs for LONG/SHORT.
Alerts
Go LONG (new signal) — regime flips into LONG.
Go SHORT (new signal) — regime flips into SHORT.
Back to NEUTRAL — regime returns to neutral.
(Define your alert message in the Alerts dialog.)
Usage Guidance
Trade in the direction of the active regime:
LONG ONLY — favor long entries/re-entries; avoid shorts.
SHORT ONLY — favor shorts; avoid longs.
NEUTRAL — reduce risk and wait for confirmation.
Combine with S/R or consolidation zones: trigger entries only when price interacts with your zones in alignment with the regime.
For altcoins, tune weights and thresholds; high-beta markets may need lower decision thresholds.
Tuning Tips
Want more signals? Lower Go LONG/SHORT thresholds or increase weights.
Want stricter signals? Raise thresholds or reduce weights.
If the asset weakly correlates with BTC, reduce Corr weight and emphasize Trend/ADX.
Limitations & Disclaimer
This is a directional filter, not a full trade system. Always apply risk management and confirm on multiple timeframes. Past performance does not guarantee future results.
Release Notes
Change Log (v6 • timed+dash)Added
✅ Signal recency window (recentBars): plots and shading only if the regime flip happened within the last N bars (default 3).
✅ Alert delay (alertDelay): alerts can fire 0–10 bars after the flip (default 0).
✅ Enhanced dashboard: shows actual RSI, component contribution, and EMA-gap % (EMAfast–EMAslow as % of price).
✅ Manual ADX/+DI/−DI: implemented via DM/TR/RMA (no ta.adx/diPlus/diMinus dependency).
✅ Smooth RSI mode: RSI: smooth around 50 (dead-zone +/-5) — continuous RSI contribution around 50 with a dead zone.
Fixed / Improved
🔧 Removed problematic functions/smart quotes (e.g., math.clamp), preventing compiler issues.
🔧 LONG/SHORT arrows appear only for the last N bars, avoiding distant markers.
🔧 Precise alert timing: alerts fire on the bar where barssince(flip) == delay.
How to get “alerts within the last 3 hourly bars”
Set Signal recency window (bars) = 3
Set Alert delay (bars after flip) = 0 (or 1–3 for delayed confirmation)
Create alerts for Go LONG (timed) and Go SHORT (timed).
Tuning tips
Want more signals? Lower Go LONG/SHORT thresholds or increase weights.
Want stricter signals? Raise thresholds or reduce weights.
For alts with weaker BTC linkage, reduce Corr weight and emphasize Trend/ADX.
Если нужно — сделаю короткую подсказку для окна “Описание” в самом индикаторе (скопируешь в поле Description на TradingView).
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.
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.
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.