Overnight vs Intraday Correlation Split

A stock or future can move with its benchmark for different reasons. Sometimes the link comes from the gap between one close and the next open. Sometimes it comes from the cash session. This script puts both correlations in one pane so you can see which one carries the link.

Statistics, published November 25, 2026. Free and open source.

Chart on TradingView with Overnight vs Intraday Correlation Split added

What it shows

  • A purple line: the rolling correlation of the chart symbol to the benchmark using only overnight returns.
  • An amber line: the same correlation using only intraday returns.
  • A fill between the two lines. It is purple where overnight is higher and amber where intraday is higher.
  • Dotted reference lines at 1, 0 and minus 1.
  • A small table at the top right with the benchmark, both latest correlations, their gap and how many completed days are loaded out of the Lookback.

How it works

For each completed day on both symbols, the script takes the daily open, the daily close and the prior daily close. The overnight return is ln(open / prior close). The intraday return is ln(close / open). It keeps the last N days of each series, where N is the Lookback input, and computes a Pearson correlation between the chart symbol and the benchmark for the overnight series and for the intraday series separately. A day is used only when both symbols have a daily bar for the same calendar date (New York time, taken from the bar close) and for the prior day too. Other days are skipped. A line starts once N such days have been collected. A new value is added once per completed day. The latest day is never included until it has closed, so past values do not change.

How to use it

  1. Add the script to a daily chart of a stock, index or future.
  2. Set the Benchmark symbol input (default SPY) and the Lookback input (default 60 days).
  3. Compare the two lines in the pane.
  4. When the purple line sits above the amber line, the link to the benchmark is stronger in the overnight gap. When amber sits above purple, it is stronger during the session.
  5. The Fill the gap between lines and Show readout table inputs switch the fill and the table off if you want a plainer pane.

Why it is different

Most correlation scripts use close to close returns, which mix both parts of the day into one number. This one separates the two parts and draws them side by side with the difference filled in.

Limits

  • It needs daily data for both symbols. On intraday charts it still reads daily values and shows the last completed day. Above the daily timeframe the lines are hidden and the table shows n/a.
  • Lines appear only after Lookback matching days are loaded, so a chart with little history may show nothing. On intraday charts the loaded chart history sets how many days are available, and the Days loaded row in the table shows the count. On a 5 minute chart that is often too few for the default of 60 days.
  • A 24 hour symbol compared with a benchmark that skips weekends loses the days next to a weekend, because the prior day does not match.
  • Futures and 24 hour markets have no cash session open, so the overnight and intraday split depends on how the data vendor defines the daily bar.
  • Correlation measures how two series move together. It says nothing about size or direction of future moves.
  • Two alerts fire when the lines cross. They report the line positions only.
  • It draws on the chart only. It places no orders and is not advice about any trade.