OPEN-SOURCE SCRIPT
Cập nhật

Beta Tracker [theUltimator5]

941
This script calculates the Pearson correlation coefficient between the charted symbol and a dynamic composite of up to four other user-defined tickers. The goal is to track how closely the current asset’s normalized price behavior aligns with, or diverges from, the selected group (or basket)

How can this indicator be valuable?
  1. You can compare the correlation of your current symbol against a basket of other tickers to see if it is moving independently, or being pulled with the basket.... or is it moving against the basket.
  2. It can be used to help identify 'swap' baskets of stocks or other tickers that tend to generally move together and visually show when your current ticker diverges from the basket.
  3. It can be used to track beta (or negative beta) with the market or with a specific ticker.
  4. This is best used as a supplement to other trading signals to give a more complete picture of the external forces potentially pulling or pushing the price action of the ticker.


🛠️ How It Works
  • The current symbol and each selected comparison ticker are normalized over a custom lookback window, allowing fair pattern-based comparison regardless of price scale.
  • The normalized values from 1 to 4 selected tickers are averaged into a composite, which represents the group’s collective movement.
  • A Pearson correlation coefficient is computed over a separate correlation lookback period, measuring the relationship between the current asset and the composite.
  • The result is plotted as a dynamic line, with color gradients:

Blue = strongly correlated (near +1)
Orange = strongly inverse correlation (near –1)
Intermediate values fade proportionally

A highlighted background appears when the correlation drops below a user-defined threshold (e.g. –0.7), helping identify strong negative beta periods visually.

A toggleable info table displays which tickers are currently being compared, along with customizable screen positioning.

⚙️ User Inputs
  • Ticker 1–4: Symbols to compare the current asset against (blank = ignored)
  • Normalization Lookback: Period to normalize each series
  • Correlation Lookback: Period over which correlation is calculated
  • Negative Correlation Highlight: Toggle for background alert and threshold level
  • Comparison Table: Toggle and position controls for an on-screen summary of selected tickers


https://imgur.com/a/bBQ1LUN


⚠️ Notes
  • The script uses request.security() to pull data from external symbols; these must be available for the selected chart timeframe.
  • A minimum of one valid ticker must be provided for the script to calculate a composite and render correlation.
Phát hành các Ghi chú
Updated chart to show indicator name in order to abide by house publishing rules

Added labels to chart to highlight use case

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

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.