PROTECTED SOURCE SCRIPT

Commodities vs Securities Rotation

51
Are commodities leading securities (real-asset / inflation tilt), or are securities leading commodities (growth / disinflation tilt)?

It is designed for macro trend context and regime confirmation, not for precise entries.


What it measures
The indicator compares Commodities vs Securities using two selectable modes:

1) Price mode (default)
Securities leg:
- SP:SPX (S&P 500 index) for long history.

Commodities leg:
- A synthetic commodity basket built from long-history futures prices:
- COMEX:GC1! (Gold)
- NYMEX:CL1! (Crude oil)
- NYMEX:NG1! (Natural gas)
- CBOT:ZC1! (Corn)
- CBOT:ZS1! (Soybeans)

How the basket is built:
- Compute log returns for each component.
- Take the average of the enabled component log returns (equal-weight by default).
- Build a cumulative performance index by cumulatively summing the averaged log returns.

Plotted signal:
- Relative performance level: commPerf - spxPerf
- Relative performance change: 1-bar change of that series

You can disable the basket and use a single commodity symbol fallback (default AMEX:DBC) if you prefer.

2) ETF flows mode
The script attempts to compute fund flows as a percent of AUM for a commodity ETF and a securities ETF:
flowPercent = (FUND_FLOWS / AUM) * 100

If that fundamentals data is unavailable for a ticker, the indicator automatically falls back to a realtime proxy:
- OBV, or
- Dollar-volume pressure

The dashboard clearly labels when proxy fallback is active.


How to interpret the signal
- Signal > 0: commodities leading securities.
- Signal < 0: securities leading commodities.

Z-score normalization helps compare regimes across long histories. Often the most useful information is the transition from negative to positive (or vice versa) and sustained regimes rather than small fluctuations around zero.


Recommended starting settings
- Timeframe: D (or W for smoother macro regimes)
- Normalization: Z-score
- Smoothing: 10 to 20
- Commodity basket: ON
- Visual mode: Minimal for a clean signal; Dashboard when validating data status


Visual modes
- Minimal: clean signal + zero line
- Atmosphere: soft shading around the signal for regime feel
- Dashboard: compact table with mode, data status, inversion state, value, and regime label
- Components: plots the two legs (commodity performance vs SPX performance, or flows legs)


Alerts
- Cross above/below 0
- Cross above/below a user threshold
- ETF flows: alert when switching from fundamentals to proxy fallback and when fundamentals are restored


Limitations and caveats
- The synthetic basket is a proxy for broad commodity beta, not a standardized index (equal weights by default).
- Continuous futures (GC1!, CL1!, etc.) can have roll effects; use for regime context rather than precise valuation.
- Fundamentals availability varies by ticker and TradingView data plan; proxy fallback is not the same as true fund flows.

Educational use only. Not financial advice.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.