Code Snippets
SOFLMARKET Correlation Matrix
Correlation matrix for TradingView: up to 8 symbols, Pearson correlation on returns, colour-coded cells, averages and alerts.
What you get: 3 files · 31.33 KB · TXT
See purchase optionsProduct description
What it is
SOFLMARKET Correlation Matrix is a Pine Script v6 indicator for TradingView that builds a correlation matrix for up to 8 symbols and draws it as a compact table in a separate pane.
The correlation is Pearson correlation of bar returns over a rolling window. Each cell is coloured by value, so strong positive and strong negative relationships stand out at a glance. The diagonal is 1.00 by definition, and an optional average row and column show how each symbol moves with the rest of the group.
It is built for portfolio users: comparing a watchlist, checking whether two holdings still move together, or seeing which symbol is the odd one out.
What is inside
Symbols
- Up to 8 symbols, any TradingView symbol: stocks, ETFs, forex, crypto, indices.
- The defaults are Binance USDT pairs: BTC, ETH, SOL, BNB, XRP, DOGE, ADA, AVAX.
- Mixing markets (stocks with crypto) is the most common cause of 0.00 values: stocks do not trade around the clock, and "Fill gaps" fills those hours with zero returns.
- "Symbols to show" (2-8) selects how many of the inputs are used.
- Optional "Use chart symbol as Symbol 1": compare the chart instrument with a watchlist.
- Tickers in the table are shortened (NASDAQ:AAPL becomes AAPL).
Calculation
- Close is requested on the chart timeframe for every symbol.
- Returns: close / previous close - 1.
- Pearson correlation over a rolling window (5-500 bars, default 60).
- "Fill gaps" (default on) forward-fills missing bars; turn it off to keep gaps as n/a.
- A pair is n/a when there is not enough data, the symbol is invalid, or the return series has zero variance.
Matrix
- Diagonal 1.00, symmetric table.
- The corner cell shows "r" and the window (for example "r 60") and the average |r| below it.
- Green for positive, red for negative.
- Opacity grows with |r|, so strong relationships are darker.
- White text when |r| is at or above the alert threshold (default 0.7).
- Optional average row and column, plus an overall average in the corner.
Display
- Separate pane.
- Nine positions for the table.
- Adjustable positive / negative / background colours.
Alerts
- High correlation: |r| crosses above the threshold.
- Correlation break: |r| crosses below the threshold.
- Named alerts (default) list every pair that crossed on the bar.
- Optional generic condition alerts.
What you get
- SOFLMARKET Correlation Matrix.txt - Pine Script v6 source code (v1.0.0)
- README.txt - installation, every input with defaults, calculations, alerts and FAQ
- LICENSE.txt - SOFLMARKET Commercial Licence v1.0
Requirements
- A TradingView account with Pine Script v6 support.
- No external libraries: the script is fully self-contained.
Installation
- Download the product files.
- In TradingView open the Pine Editor.
- Paste the supplied source into a new script.
- Save it and click "Add to chart".
- The indicator opens in a separate pane.
- Pick the symbols, the window and the alert threshold.
Alerts
- High correlation
- Correlation break
Named alerts are on by default: the message lists every pair that crossed the threshold on that bar, with its value.
Notes
- Correlation is measured on the chart timeframe. Use a timeframe that matches the horizon you care about: 1H for intraday, 1D for swing, 1W for long term.
- The indicator opens in a separate pane. If the table looks clipped, resize the pane.
- "Fill gaps" forward-fills missing bars. On symbols with different sessions this creates flat returns and can distort the correlation. Turn it off for a strict pairwise comparison, or use symbols that share the same session.
- Correlation is not causation. It changes over time and can break without a clear reason.
- Correlation is sensitive to the window. A short window reacts faster and is noisier; a long window is smoother and slower.
- The indicator uses closes only. It does not use volume or order flow.
- Nothing in this product is financial advice. Trading leveraged instruments carries a high risk of loss. Past performance is not indicative of future results.
Changelog
v1.0.0 - 21.11.2026 - First release.
What you get
3 files · 31.33 KB
- LICENSE.txtTXT · 4.16 KB
- README.txtTXT · 10.58 KB
- SOFLMARKET Correlation Matrix.txtTXT · 16.6 KB
Code Snippets
SOFLMARKET Correlation Matrix
Correlation matrix for TradingView: up to 8 symbols, Pearson correlation on returns, colour-coded cells, averages and alerts.
Tags
Frequently asked questions
Do I get access instantly?
Yes. This is a digital product - you can download it right after checkout, straight from your library.
Can I use it for commercial projects?
Personal use only. Use it for yourself - not in work you sell or hand to a client - and do not resell or redistribute the file.
What's your refund policy?
You can request a refund within 30 days. If something isn't right, request it from your order and the Getly team reviews it.
What file formats and sizes will I get?
You'll download 3 files - TXT - 31.33 KB in total.
Do I get free updates?
Yes - when the seller ships a new version, you can re-download the latest files from your library at no extra cost. Check the changelog for recent updates.
Price
$49.00



