PROTECTED SOURCE SCRIPT
Telah dikemas kini

Multi-Asset Trend Background [SwissAlgo]

14
Multi-Asset Trend Background

---------------------------------------------------------
Purpose
This indicator colors the chart background green (uptrend) or red (downtrend) to show the broad phases of a selected asset or ratio (for example SP500, or Gold), regardless of the current ticker on the chart (for example BTC).
The aim is not to generate signals, but to show when the selected asset (such as SP500 or Gold) was in a sustained uptrend or downtrend, so you can compare another chart (for example BTC) against that backdrop.
It helps frame price action in context, highlighting how macro drivers often align with or diverge from other markets.

  • From mid-2016 to late-2017, the SP500 was in a clear uptrend — Bitcoin rallied strongly in the same period, showing alignment between equities and crypto risk-taking.
  • When Gold trended higher, the SP500 often weakened, reflecting their tendency to move inversely in longer cycles.
  • As HYG/TLT turned down in early 2020, QQQ also struggled — illustrating how credit risk appetite is linked to equity performance.
  • During periods of DXY strength, Gold frequently showed the opposite trend, consistent with the historical dollar–gold relationship.
  • When RSP/SPY trended down, rallies in the S&P 500 were driven by a narrow group of large-cap stocks, while a rising ratio indicated broad market participation.


---------------------------------------------------------
Why it May Help You

  • Provides context for asset correlations.
  • Helps identify whether a chart is moving with or against its macro environment.
  • Useful for cycle mapping and historical study of market phases.
  • Filters noise and emphasizes established trends rather than short swings.

---------------------------------------------------------
How it Works

  1. You select an asset or ratio from a dropdown.
  2. The script calculates a mid-term moving average, then measures its slope, slope change, and slope acceleration to quantify the trend’s direction and consistency.
  3. A longer-term moving average filter defines whether the long-term backdrop is bullish or bearish.

Background Coloring rules:
  • Green = slope strongly positive in line with long-term uptrend, or downtrend showing constructive reversal signs.
  • Red = slope strongly negative in line with long-term downtrend, or uptrend showing weakening slope.
  • No shading = neutral or mixed conditions.


This slope-based approach avoids the limitations of simple MA crosses, aiming to capture broad, consistent trend phases across different assets, with a mid/long-term view.

---------------------------------------------------------
Assets You Can Select

EQUITIES – good reference to gauge risk appetite in financial markets

  • SP500 = broad benchmark. Uptrend = strength in US equities signalling risk-on conditions; downtrend = weakness, risk-off market phase.
  • NASDAQ = tech and growth stocks. Uptrend = technology/growth leadership, risk appetite; downtrend = tech underperformance and fading risk appetite.
  • DOW = industrial and value stocks. Uptrend = industrial/value strength/economic strength; downtrend = weakness in traditional sectors and potential economic downturn.
  • RUSSELL2000 = small caps. Uptrend = typical in risk-on environments and FOMO; downtrend = small-cap underperformance, "flight to safety".


COMMODITIES – proxies for inflation, industry, and safe-haven demand.

  • GOLD = safe-haven. Uptrend = defensive demand rising/risk-off/inflation fears; downtrend = weaker demand for safety.
  • SILVER = partly industrial, partly safe-haven. Uptrend = stronger industrial cycle, or precious metals demand and risk appetite.
  • COPPER = industrial barometer. Uptrend = stronger industrial activity; downtrend = economic slowdown concerns.
  • CRUDE OIL = energy prices. Uptrend = rising energy/inflation pressures; downtrend = weaker demand or supply relief.
  • NATURAL GAS = volatile energy prices. Uptrend = higher energy costs and inflation pressure; downtrend = easing energy conditions.


BONDS / FX – monetary policy, credit, and risk appetite signals.

  • TLT = long-term US bonds. Uptrend = falling yields (bond demand)/flight to safety; downtrend = rising yields (risk on)
  • HYG = high-yield credit. Uptrend = strong credit appetite; downtrend = risk aversion in credit markets.
  • DXY = US dollar index. Uptrend = dollar strength (weaker EUR, GBP, SEK, etc); downtrend = dollar weakness.
  • USDJPY = carry trade proxy. Uptrend = stronger USD vs JPY (risk appetite); downtrend = JPY strength (risk-off).
  • CHFUSD = Swiss franc. Uptrend = franc strength (defensive flow); downtrend = franc weakness.
  • YIELD INVERSION = US10Y–US02Y. Uptrend = curve steepening; downtrend = inversion deepening (higher recession risk).
  • HOME BUILDERS = US housing sector. Uptrend = housing sector strength (risk on); downtrend = weakness (risk off).
  • EURUSD = euro vs dollar. Uptrend = euro strength (risk appetite); downtrend = euro weakness (risk aversion).


CRYPTO – digital asset benchmarks.

  • BITCOIN = digital gold. Uptrend = BTC strength; downtrend = BTC weakness.
  • CRYPTO_TOTAL = entire crypto market cap. Uptrend = broad crypto growth; downtrend = contraction.
  • CRYPTO_ALTS = altcoin market cap. Uptrend = altcoin expansion (often “alt season”); downtrend = contraction.


RATIOS – relative measures to extract macro signals.

  • COPPER/BTC = compares industrial cycle vs Bitcoin cycle. Uptrend = copper outperforming BTC; downtrend = BTC outperforming copper. Seems aligned with BTC macro tops and bottoms in the mid/long run.
  • RSP/SPY = market breadth (equal-weight vs cap-weighted). Uptrend = strong broad participation in market growth; downtrend = narrow leadership (fewer stocks leading the growth).
  • PCE/CPI = Fed’s inflation measure (PCE) vs consumer perceived inflation (CPI). Uptrend = PCE rising faster than CPI; downtrend = CPI running hotter than PCE. Fluctuates around 1; values above 1 may indicate hawkish Fed stands, values < 1 may indicate more dovish Fed stands.
  • HYG/TLT = credit vs bonds. Uptrend = risk appetite (high-yield outperforming long-term
    treasury bonds); downtrend = risk aversion.
  • GOLD/SILVER = defensive vs cyclical metals. Uptrend = gold outperforming (risk-off tilt); downtrend = silver outperforming (risk-on tilt).
  • EURUSD/BTC = fiat vs crypto. Uptrend = EUR strengthening vs BTC; downtrend = BTC strengthening vs EUR. In general, the BTC trend is aligned EUR/USD trend.


---------------------------------------------------------
Limitations

  • Trend detection may lag by design to reduce noise.
  • Ratios rely on the availability and session rules of their components.
  • Background colors update on bar close; intra-bar values may differ.
  • Parameters are fixed and may not suit all assets equally.


---------------------------------------------------------
Disclaimer

This script is for educational and research purposes only. It does not provide financial advice or trade recommendations. Historical trend alignment does not guarantee future outcomes. Use with additional independent analysis.
Nota Keluaran
Made the trend identification logic more dynamic (based on the selected chart timeframe)
Nota Keluaran
Updated background colors for better visibility

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.