Lead-lag Detection
By LuxAlgoJun 6, 2026
Lead-lag Detection is an indicator on Vela, our next-generation charting platform, written in Pine Script®.
Lead-lag Detection measures whether the chart symbol systematically moves before or after a related instrument, and by how many bars. The cross-correlation sweep behind lead-lag detection reruns on both series' returns every bar, from -20 to +20 lags, and the peak value plots with approximate significance bounds at 2/sqrt(n). A relationship is only called while the peak sits at a nonzero lag beyond the bounds; the dashboard names the leader and its lag in plain language.
How to Trade the Lead-lag Detection?
- Peak at a positive lag: the chart symbol leads the comparison by that many bars; at a negative lag, the comparison leads the chart.
- Significance first: inside the bounds the honest read is no significant lead - alerts mark the transitions in and out.
- Compare against lag 0: the Lag-0 Correlation plot shows the plain contemporaneous correlation - the value added by shifting one series in time, at a glance.
Peak Lag Shift and Leader Flip alerts round out the set - a relationship is only worth trusting while its lag and sign persist.
Lead-lag Detection Settings
- Comparison Symbol (default SP:SPX): the second instrument of the pair.
- Source (default close) and Returns (default Log): the correlated series, sampled only on fresh comparison bars so session mismatches cannot fabricate lags.
- Correlation Window (default 100): overlapping observations n at every lag, and the bounds.
- Max Lag (default 20): the sweep spans -K to +K bars; wider sweeps multiply the odds of spurious peaks.
- Show Profile (on) with Profile Offset (default 5): the per-lag correlogram beside the last bar.
- Show Dashboard (on, Top Right, Small); style: Lag-0 Correlation (on), Normalized Peak Lag (off), Significance Bounds (on).
Frequently Asked Questions
Free to use
Run it on Vela. Go further with a paid plan.
- Up to 500 Custom Alerts, with webhook automation
- Up to 10× the chart history of Free
- Orderflow lookback up to full history
- More Quant usage to customize it, plus extra usage when you need it
- Futures data alongside crypto, stocks, forex and commodities
Related indicators
Run it on Vela. Make it yours with Quant.
Open this indicator free on Vela, our next-generation charting platform. Then ask Quant, our coding agent built into Vela, to retune it or turn it into a backtested strategy of your own.





