INDICATOR MANUAL
Correlation and beta indicatorCorrelation Matrix [AFD] · full manual · published to TradingView
Compare the chart symbol with up to eight instruments using matched returns, correlation, beta, spread, history, and coverage.
Start here
What the indicator does, the questions it can help answer, and its fresh-install defaults.
The indicator compares the chart symbol with up to eight configured symbols. It is not a full pairwise matrix between every comparison symbol; each row is measured against the chart symbol.
Returns are built only from consecutive accepted endpoint pairs whose chart and comparison timestamps both advance. Missing bars and session gaps accumulate both instruments over the same shared interval.
Dashboard calculations and comparison-line drawings have separate controls. Measurement preset selects the sampling clock and windows; Dashboard view changes columns; Comparison line starting point changes only rebased visual paths.
Fresh-install defaults9 documented defaults
Swipe or scroll horizontally to see every column.
| Area | Default | Result |
|---|---|---|
| Measurement preset | Intraday | Requests 5-minute measurements with Long 78 and Short 20 windows. |
| Dashboard view | Context | Shows Symbol, Long, Short, Spread, Coverage, plus Difference because its switch starts on. |
| Symbol set | Custom | Uses the per-slot symbol and display-name fields. |
| Slots 1–3 | QQQ · DIA · IWM | All three are enabled and show comparison lines. |
| Slots 4–8 | Enabled · blank | Blank slots remain inactive and hidden while retaining their fixed request sites. |
| Dashboard and lines | On | Both visual layers start visible when usable data exists. |
| Line starting point | Auto | Intraday resolves to Session Open; Swing resolves to Year Open. |
| Main correlation window | Short | Main Correlation, History, and line-end correlation text use the Short result. |
| Historical comparison | Off | History is not calculated for display until enabled. |
How it works
How the indicator turns chart data into the states and drawings you see.
Measurement clock
Scalper uses 1-minute 60/15 windows, Intraday 5-minute 78/20, Swing 1-day 120/20, and Custom uses user values. A requested timeframe below the chart falls back to the chart timeframe and shows an amber warning.
Confirmed comparison snapshots
Equal-timeframe data commits on chart confirmation. Fixed higher-timeframe tuples use the last completed measurement bar and commit when the first chart bar that sees the tuple confirms, which can add one chart-bar delay.
Shared-endpoint returns
The latest causally available comparison endpoint maps to the nearer current or prior chart-base endpoint. Both timestamps must advance before log returns are admitted; unmatched positions remain unavailable in the rolling window.
Correlation, Difference, and Beta
Long and Short use centered Pearson moments over pairwise-valid matched returns. Difference is Short minus Long. Beta is covariance(chart returns, comparison returns) divided by variance(comparison returns) over the Long sample.
Matched Spread
Non-negative Long correlation selects log(chart) − log(comparison); negative Long correlation selects their sum. The current value is reported as a population z-score against its matched Long-window history.
History and Coverage
History ranks the current Main Correlation against prior valid readings using tie-aware midrank. Coverage is fresh comparison endpoints divided by eligible Long-window positions; it is availability, not quality or confidence.
Dashboard views
Context, Compact, Full, Minimal, and Custom choose columns only. Show correlation difference can add Difference to every view. An advanced override can use custom columns without changing the selected view.
Rebased comparison lines
Each path starts from a shared chart boundary and applies the comparison symbol’s percentage change to the chart scale. Session Open, Year Open, Fixed Date, and Rolling N Bars affect drawings only.
Output and state reference12 documented states
Swipe or scroll horizontally to see every column.
| Output or state | When it appears | Meaning |
|---|---|---|
| LONG CORRELATION | Complete Long window | Centered Pearson correlation over usable matched returns. |
| SHORT CORRELATION | Complete Short window | Faster centered Pearson correlation over the shorter matched sample. |
| DIFFERENCE | Long and Short available | Short minus Long, displayed in rounded percentage points. |
| MAIN CORRELATION | Long or Short selected | Reuses the selected result for Minimal view, History, and line-end text. |
| BETA | Long sample with variation | Chart-return sensitivity relative to comparison returns. |
| SPREAD | Matched price history with variation | Signed ratio- or product-form population z-score. |
| DATA COVERAGE | Complete Long window | Fresh comparison endpoints divided by eligible measurement positions. |
| HISTORY | Historical comparison enabled | Tie-aware percentile of Main Correlation against prior valid pair readings. |
| LAG STAR | Fresh comparison mapped to prior base | Marks that the latest accepted endpoint aligned to the preceding chart-base close. |
| NO DATA | Invalid or unavailable symbol | Keeps the row unavailable without stopping other rows. |
| NO ACTIVE SYMBOLS | No enabled nonblank slots | Dashboard empty state; fixed request architecture remains. |
| AMBER WARNING | Lower-timeframe fallback or Short adjustment | Names the requested and effective measurement contract. |
Settings
The 102-input reference begins with the eight five-control slot rows, then documents measurement, dashboard, custom-column, appearance, rebased-line, baseline, shading, label, and global-opacity controls.
Eight comparison slots
40 mapped inputs
Swipe or scroll horizontally to see every column.
| Row | Enabled | Symbol | Display name | Color | Line |
|---|---|---|---|---|---|
| Slot 1 | OnToggle | NASDAQ:QQQSymbol · conditional | Choice / text · conditional | #64B5F6Color | OnToggle |
| Slot 2 | OnToggle | AMEX:DIASymbol · conditional | Choice / text · conditional | #FFB74DColor | OnToggle |
| Slot 3 | OnToggle | AMEX:IWMSymbol · conditional | Choice / text · conditional | #4DD0E1Color | OnToggle |
| Slot 4 | OnToggle | Symbol · conditional | Choice / text · conditional | #BA68C8Color | OnToggle |
| Slot 5 | OnToggle | Symbol · conditional | Choice / text · conditional | #81C784Color | OnToggle |
| Slot 6 | OnToggle | Symbol · conditional | Choice / text · conditional | #FFD54FColor | OnToggle |
| Slot 7 | OnToggle | Symbol · conditional | Choice / text · conditional | #F06292Color | OnToggle |
| Slot 8 | OnToggle | Symbol · conditional | Choice / text · conditional | #BCAAA4Color | OnToggle |
Quick Setup7 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Measurement presettrading_horizon | Choice / text | Intraday · 5-minute measurements · Long 78 / Short 20 | Scalper · 1-minute measurements · Long 60 / Short 15 · Intraday · 5-minute measurements · Long 78 / Short 20 · Swing · 1-day measurements · Long 120 / Short 20 · Custom |
| Dashboard viewvisual_preset | Choice / text | Context | Context · Compact · Full · Minimal · Custom |
| Show correlation differenceshow_difference | Toggle | On | — |
| Symbol setpreset_group | Choice / text | Custom | Custom · United States Indices · Risk On / Off · Major Foreign Exchange Pairs · Energy & Metals · Crypto |
| Show dashboarddash_en | Toggle | On | — |
| Show comparison linesoverlay_en | Toggle | On | — |
| Comparison line starting point (visual only)line_start | Choice / text | Auto from measurement preset | Auto from measurement preset · Session Open · Rolling N Bars · Year Open · Fixed Date | Conditional |
Custom Measurements — Advanced6 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Custom measurement timeframecustom_calc_tf | Timeframe | Blank | Conditional |
| Long correlation windowcustom_long_len | Whole number | 120 | Min 10 · Max 1000 | Conditional |
| Short correlation windowcustom_short_len | Whole number | 20 | Min 5 · Max 200 | Conditional |
| Main correlation windowpct_src | Choice / text | Short | Long · Short |
| Historical comparisonhist_en | Toggle | Off | — |
| Historical windowhist_len | Whole number | 750 | Min 100 · Max 5000 | Conditional |
Dashboard3 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Positiondash_pos | Choice / text | Top Right | Top Left · Top Center · Top Right · Middle Left · Middle Center · Middle Right · Bottom Left · Bottom Center · Bottom Right |
| Sort rows bydash_sort | Choice / text | Slot order | Slot order · Strongest correlation · Widest spread |
| Cell coloringcolor_mode | Choice / text | Heat | Heat · Mono |
Dashboard Columns — Advanced8 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Use custom dashboard columnscustom_columns_override | Toggle | Off | — |
| Show main correlationcol_pct | Toggle | On | Conditional |
| Show long correlationcol_rl | Toggle | Off | Conditional |
| Show short correlationcol_rc | Toggle | Off | Conditional |
| Show betacol_beta | Toggle | Off | Conditional |
| Show spreadcol_z | Toggle | Off | Conditional |
| Show historycol_hist | Toggle | Off | Conditional |
| Show data coveragecol_match | Toggle | Off | Conditional |
Dashboard Appearance — Advanced15 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Header text sizehdr_size | Choice / text | Small | Tiny · Small · Normal · Large · Huge |
| Body text sizebody_size | Choice / text | Small | Tiny · Small · Normal · Large · Huge |
| Header text colorhdr_txt_c | Color | White | — |
| Body text colorbody_txt_c | Color | White | — |
| Header backgroundhdr_bg_c | Color | #1E222D | — |
| Body backgroundbody_bg_c | Color | #131722 | — |
| Background transparencytbl_bg_transp | Whole number | 10 | Min 0 · Max 100 |
| Alternating row shadingstripe_en | Toggle | On | — |
| Row shading colorstripe_c | Color | #1E222D | Conditional |
| Row shading transparencystripe_transp | Whole number | 40 | Min 0 · Max 100 | Conditional |
| Border widthborder_w | Whole number | 1 | Min 0 · Max 4 |
| Border colorborder_c | Color | #2A2E39 | — |
| Frame widthframe_w | Whole number | 1 | Min 0 · Max 4 |
| Frame colorframe_c | Color | #2A2E39 | — |
| Mono coloringmono_c | Color | #787B86 | Conditional |
Comparison Line Style3 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Line appearancereb_style | Choice / text | Solid line | Solid line · Dashed line · Dotted line · Step line · Step line with diamonds · Points · Crosses | Conditional |
| Line widthreb_width | Whole number | 2 | Min 1 · Max 4 | Conditional |
| Line transparencyline_transp | Whole number | 50 | Min 0 · Max 100 | Conditional |
Comparison Line Starting Point — Advanced7 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Rolling barsanchor_bars | Whole number | 120 | Min 10 · Max 1000 | Conditional |
| Fixed dateanchor_date | Date / time | timestamp("01 Jan 2026 00:00 +0000") | Conditional |
| Show starting-point markermarker_en | Toggle | On | Conditional |
| Marker styleanc_style | Choice / text | Dotted | Solid · Dashed · Dotted | Conditional |
| Marker coloranc_col | Color | #787B86 | Conditional |
| Marker transparencyanc_transp | Whole number | 50 | Min 0 · Max 100 | Conditional |
| Marker widthanc_width | Whole number | 1 | Min 1 · Max 4 | Conditional |
Comparison Line Gap Shading — Advanced5 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Shaded slotshade_slot | Whole number | 0 | Min 0 · Max 8 | Conditional |
| Shade the gapfill_en | Toggle | On | Conditional |
| Chart above colorfill_up_c | Color | #4CAF50 | Conditional |
| Chart below colorfill_dn_c | Color | #FF5252 | Conditional |
| Fill transparencyfill_transp | Whole number | 85 | Min 0 · Max 100 | Conditional |
Comparison Line Labels — Advanced7 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Show line-end labelsend_lbl_en | Toggle | On | Conditional |
| Include symbol nameend_lbl_sym | Toggle | On | Conditional |
| Include main correlationend_lbl_pct | Toggle | On | Conditional |
| Include spreadend_lbl_z | Toggle | On | Conditional |
| Text sizeend_lbl_size | Choice / text | Normal | Auto · Tiny · Small · Normal · Large · Huge | Conditional |
| Text colorend_lbl_cmode | Choice / text | Slot color | Slot color · Custom | Conditional |
| Custom text colorend_lbl_c | Color | White | Conditional |
Global Appearance — Advanced1 input
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Master opacity shiftmaster_opacity | Whole number | 0 | Min 0 · Max 100 |
Alerts and limitations
What can notify you, what can change the output, and what the indicator cannot establish.
Alerts
Limits to keep visible
- Every comparison is against the chart symbol; the dashboard is not an all-against-all pairwise matrix.
- Standard time-based candles are required. Non-standard chart types and tick charts stop with a runtime message.
- A requested measurement timeframe below the chart falls back to the chart timeframe, so the sample changes.
- Fixed higher-timeframe readings can appear up to one confirming chart bar after a newly completed measurement tuple becomes visible.
- Coverage measures fresh endpoint availability, not statistical quality, confidence, significance, or the exact count used by every metric.
- A full configured window, at least three usable pairs, and measurable variation are required before correlation appears.
- All eight comparison request sites remain active by architecture; disabling a slot hides it but does not reduce request cost.
- Rebased lines can stretch the price scale when a comparison path moves far from the chart. Change the visual starting point or hide lines when needed.
- The indicator is not a hedge-sizing model, portfolio-risk engine, significance test, cointegration model, or trade signal.
Troubleshooting
Start with what you see on the chart. Each answer explains the likely cause and the first setting, timeframe, or data condition to check.
Why does the Swing preset work on a 30-minute chart?
Swing measures completed daily returns even when you view a 30-minute chart. The chart timeframe controls what you see; the preset controls the comparison clock. They do not need to match.
Why is the timeframe warning amber?
Your requested measurement timeframe is smaller than the chart timeframe, so TradingView cannot supply the finer comparison from that chart. The indicator falls back to the chart timeframe. Choose the same or a higher measurement timeframe to remove the fallback.
Why is one comparison row marked No data?
TradingView could not return usable history for that ticker in the current chart context. Check the exact exchange-qualified symbol and whether your data plan includes it. The other rows continue working independently.
Why is correlation blank even though Coverage is high?
Coverage only says that many recent endpoints arrived. Correlation still needs a full window, at least three matched returns, and actual movement in both symbols. Load more history or shorten the window, then check that neither series is flat.
Why is Spread blank when I compare the chart symbol with itself?
A symbol divided by itself does not move, so its spread has no variation and no meaningful z-score. Choose a different comparison symbol if you want a Spread reading.
Why didn’t changing the line starting point change the dashboard?
The starting point only changes how the rebased comparison lines are drawn. Correlation, Beta, Spread, History, and Coverage use the same matched returns either way, so the dashboard should not change.
Why is the effective Short window different from what I entered?
In Custom mode, Short must be smaller than Long. If you enter an equal or larger value, the script uses Long minus one. Set Short below Long and compare the selected and effective values in the dashboard.