OPEN-SOURCE SCRIPT
已更新 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.
發行說明
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).
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。