OPEN-SOURCE SCRIPT
Omega Correlation [OmegaTools]

Omega Correlation (Ω CRR) is a cross-asset analytics tool designed to quantify both the strength of the relationship between two instruments and the tendency of one to move ahead of the other. It is intended for traders who work with indices, futures, FX, commodities, equities and ETFs, and who require something more robust than a simple linear correlation line.
The indicator operates in two distinct modes, selected via the “Show” parameter: Correlation and Anticipation. In Correlation mode, the script focuses on how tightly the current chart and the chosen second asset move together. In Anticipation mode, it shifts to a lead–lag perspective and estimates whether the second asset tends to behave as a leader or a follower relative to the symbol on the chart.
In both modes, the core inputs are the chart symbol and a user-selected second symbol. Internally, both assets are transformed into normalized log-returns: the script computes logarithmic returns, removes short-term mean and scales by realized volatility, then clips extreme values. This normalisation allows the tool to compare behaviour across assets with different price levels and volatility profiles.
In Correlation mode, the indicator computes a composite correlation score that typically ranges between –1 and +1. Values near +1 indicate strong and persistent positive co-movement, values near zero indicate an unstable or weak link, and values near –1 indicate a stable anti-correlation regime. The composite score is constructed from three components.
The first component is a normalized return co-movement measure. After transforming both instruments into normalized returns, the script evaluates how similar those returns are bar by bar. When the two assets consistently deliver returns of similar sign and magnitude, this component is high and positive. When they frequently diverge or move in opposite directions, it becomes negative. This captures short-term co-movement in a volatility-adjusted way.
The second component focuses on high–low swing alignment. Rather than looking only at closes, it examines the direction of changes in highs and lows for each bar. If both instruments are printing higher highs and higher lows together, or lower highs and lower lows together, the swing structure is considered aligned. Persistent alignment contributes positively to the correlation score, while repeated mismatches between the swing directions reduce it. This helps differentiate between superficial price noise and structural similarity in trend behaviour.
The third component is a classical Pearson correlation on closing prices, computed over a longer lookback. This serves as a stabilising backbone that summarises general co-movement over a broader window. By combining normalized return co-movement, swing alignment and standard price correlation with calibrated weights, the Correlation mode provides a richer view than a single linear measure, capturing both short-term dynamic interaction and longer-term structural linkage.
In Anticipation mode, Omega Correlation estimates whether the second asset tends to lead or lag the current chart. The output is again a continuous score around the [–1, +1] range. Positive values suggest that the second asset is acting more as a leader, with its past moves bearing informative value for subsequent moves of the chart symbol. Negative values indicate that the second asset behaves more like a laggard or follower. Values near zero suggest that no stable lead–lag structure can be identified.
The anticipation score is built from four elements inspired by quantitative lead–lag and price discovery analysis. The first element is a residual lead correlation, conceptually similar to Granger-style logic. The script first measures how much of the chart symbol’s normalized returns can be explained by its own lagged values. It then removes that component and studies the correlation between the residuals and lagged returns of the second asset. If the second asset’s past returns consistently explain what the chart symbol does beyond its own autoregressive behaviour, this residual correlation becomes significantly positive.
The second element is an asymmetric lead–lag structure measure. It compares the strength of relationships in both directions across multiple lags: the correlation of the current symbol with lagged versions of the second asset (candidate leader) versus the correlation of lagged values of the current symbol with the present values of the second asset. If the forward direction (second asset leading the first) is systematically stronger than the backward direction, the structure is skewed toward genuine leadership of the second asset.
The third element is a relative price discovery score, constructed by building a dynamic hedge ratio between the two prices and defining a spread. The indicator looks at how changes in each asset contribute to correcting deviations in this spread over time. When the chart symbol tends to do most of the adjustment while the second asset remains relatively stable, it suggests that the second asset is taking a greater role in determining the equilibrium price and the chart symbol is adjusting to it. The difference in adjustment intensity between the two instruments is summarised into a single score.
The fourth element is a breakout follow-through causality component. The script scans for breakout events on the second asset, where its price breaks out of a recent high or low range while the chart symbol has not yet done so. It then evaluates whether the chart symbol subsequently confirms the breakout direction, remains neutral, or moves against it. Events where the second asset breaks and the first asset later follows in the same direction add positive contribution, while failed or contrarian follow-through reduce this component. The contribution is also lightly modulated by the strength of the breakout, via the underlying normalized return.
The four elements of the Anticipation mode are combined into a single leading correlation score, providing a compact and interpretable measure of whether the second asset currently behaves as an effective early signal for the symbol you trade.
To aid interpretation, Omega Correlation builds dynamic bands around the active series (correlation or anticipation). It estimates a long-term central tendency and a typical deviation around it, plotting upper and lower bands that highlight unusually high or low values relative to recent history. These bands can be used to distinguish routine fluctuations from genuinely extreme regimes.
The script also computes percentile-based levels for the correlation series and uses them to track two special price levels on the main chart: lost correlation levels and gained correlation levels. When the correlation drops below an upper percentile threshold, the current price is stored as a lost correlation level and plotted as a horizontal line. When the correlation rises above a lower percentile threshold, the current price is stored as a gained correlation level. These levels mark zones where a historically strong relationship between the two markets broke down or re-emerged, and can be used to frame divergence, convergence and spread opportunities.
An information panel summarises, in real time, whether the second asset is behaving more as a leading, lagging or independent instrument according to the anticipation score, and suggests whether the current environment is more conducive to de-alignment, re-alignment or classic spread behaviour based on the correlation regime. This makes the tool directly interpretable even for users who are not familiar with all the underlying statistical details.
Typical applications for Omega Correlation include intermarket analysis (for example, index vs index, commodity vs related equity sector, FX vs bonds), dynamic hedge sizing, regime detection for algorithmic strategies, and the identification of lead–lag structures where a macro driver or benchmark can be monitored as an early signal for the instrument actually traded. The indicator can be applied across intraday and higher timeframes, with the understanding that the strength and nature of relationships will differ across horizons.
Omega Correlation is designed as an advanced analytical framework, not as a standalone trading system. Correlation and lead–lag relationships are statistical in nature and can change abruptly, especially around macro events, regime shifts or liquidity shocks. A positive anticipation reading does not guarantee that the second asset will always move first, and a high correlation regime can break without warning. All outputs of this tool should be combined with independent analysis, sound risk management and, when appropriate, backtesting or forward testing on the user’s specific instruments and timeframes.
The intention behind Omega Correlation is to bring techniques inspired by quantitative research, such as normalized return analysis, residual correlation, asymmetric lead–lag structure, price discovery logic and breakout event studies, into an accessible TradingView indicator. It is intended for traders who want a structured, professional way to understand how markets interact and to incorporate that information into their discretionary or systematic decision-making processes.
The indicator operates in two distinct modes, selected via the “Show” parameter: Correlation and Anticipation. In Correlation mode, the script focuses on how tightly the current chart and the chosen second asset move together. In Anticipation mode, it shifts to a lead–lag perspective and estimates whether the second asset tends to behave as a leader or a follower relative to the symbol on the chart.
In both modes, the core inputs are the chart symbol and a user-selected second symbol. Internally, both assets are transformed into normalized log-returns: the script computes logarithmic returns, removes short-term mean and scales by realized volatility, then clips extreme values. This normalisation allows the tool to compare behaviour across assets with different price levels and volatility profiles.
In Correlation mode, the indicator computes a composite correlation score that typically ranges between –1 and +1. Values near +1 indicate strong and persistent positive co-movement, values near zero indicate an unstable or weak link, and values near –1 indicate a stable anti-correlation regime. The composite score is constructed from three components.
The first component is a normalized return co-movement measure. After transforming both instruments into normalized returns, the script evaluates how similar those returns are bar by bar. When the two assets consistently deliver returns of similar sign and magnitude, this component is high and positive. When they frequently diverge or move in opposite directions, it becomes negative. This captures short-term co-movement in a volatility-adjusted way.
The second component focuses on high–low swing alignment. Rather than looking only at closes, it examines the direction of changes in highs and lows for each bar. If both instruments are printing higher highs and higher lows together, or lower highs and lower lows together, the swing structure is considered aligned. Persistent alignment contributes positively to the correlation score, while repeated mismatches between the swing directions reduce it. This helps differentiate between superficial price noise and structural similarity in trend behaviour.
The third component is a classical Pearson correlation on closing prices, computed over a longer lookback. This serves as a stabilising backbone that summarises general co-movement over a broader window. By combining normalized return co-movement, swing alignment and standard price correlation with calibrated weights, the Correlation mode provides a richer view than a single linear measure, capturing both short-term dynamic interaction and longer-term structural linkage.
In Anticipation mode, Omega Correlation estimates whether the second asset tends to lead or lag the current chart. The output is again a continuous score around the [–1, +1] range. Positive values suggest that the second asset is acting more as a leader, with its past moves bearing informative value for subsequent moves of the chart symbol. Negative values indicate that the second asset behaves more like a laggard or follower. Values near zero suggest that no stable lead–lag structure can be identified.
The anticipation score is built from four elements inspired by quantitative lead–lag and price discovery analysis. The first element is a residual lead correlation, conceptually similar to Granger-style logic. The script first measures how much of the chart symbol’s normalized returns can be explained by its own lagged values. It then removes that component and studies the correlation between the residuals and lagged returns of the second asset. If the second asset’s past returns consistently explain what the chart symbol does beyond its own autoregressive behaviour, this residual correlation becomes significantly positive.
The second element is an asymmetric lead–lag structure measure. It compares the strength of relationships in both directions across multiple lags: the correlation of the current symbol with lagged versions of the second asset (candidate leader) versus the correlation of lagged values of the current symbol with the present values of the second asset. If the forward direction (second asset leading the first) is systematically stronger than the backward direction, the structure is skewed toward genuine leadership of the second asset.
The third element is a relative price discovery score, constructed by building a dynamic hedge ratio between the two prices and defining a spread. The indicator looks at how changes in each asset contribute to correcting deviations in this spread over time. When the chart symbol tends to do most of the adjustment while the second asset remains relatively stable, it suggests that the second asset is taking a greater role in determining the equilibrium price and the chart symbol is adjusting to it. The difference in adjustment intensity between the two instruments is summarised into a single score.
The fourth element is a breakout follow-through causality component. The script scans for breakout events on the second asset, where its price breaks out of a recent high or low range while the chart symbol has not yet done so. It then evaluates whether the chart symbol subsequently confirms the breakout direction, remains neutral, or moves against it. Events where the second asset breaks and the first asset later follows in the same direction add positive contribution, while failed or contrarian follow-through reduce this component. The contribution is also lightly modulated by the strength of the breakout, via the underlying normalized return.
The four elements of the Anticipation mode are combined into a single leading correlation score, providing a compact and interpretable measure of whether the second asset currently behaves as an effective early signal for the symbol you trade.
To aid interpretation, Omega Correlation builds dynamic bands around the active series (correlation or anticipation). It estimates a long-term central tendency and a typical deviation around it, plotting upper and lower bands that highlight unusually high or low values relative to recent history. These bands can be used to distinguish routine fluctuations from genuinely extreme regimes.
The script also computes percentile-based levels for the correlation series and uses them to track two special price levels on the main chart: lost correlation levels and gained correlation levels. When the correlation drops below an upper percentile threshold, the current price is stored as a lost correlation level and plotted as a horizontal line. When the correlation rises above a lower percentile threshold, the current price is stored as a gained correlation level. These levels mark zones where a historically strong relationship between the two markets broke down or re-emerged, and can be used to frame divergence, convergence and spread opportunities.
An information panel summarises, in real time, whether the second asset is behaving more as a leading, lagging or independent instrument according to the anticipation score, and suggests whether the current environment is more conducive to de-alignment, re-alignment or classic spread behaviour based on the correlation regime. This makes the tool directly interpretable even for users who are not familiar with all the underlying statistical details.
Typical applications for Omega Correlation include intermarket analysis (for example, index vs index, commodity vs related equity sector, FX vs bonds), dynamic hedge sizing, regime detection for algorithmic strategies, and the identification of lead–lag structures where a macro driver or benchmark can be monitored as an early signal for the instrument actually traded. The indicator can be applied across intraday and higher timeframes, with the understanding that the strength and nature of relationships will differ across horizons.
Omega Correlation is designed as an advanced analytical framework, not as a standalone trading system. Correlation and lead–lag relationships are statistical in nature and can change abruptly, especially around macro events, regime shifts or liquidity shocks. A positive anticipation reading does not guarantee that the second asset will always move first, and a high correlation regime can break without warning. All outputs of this tool should be combined with independent analysis, sound risk management and, when appropriate, backtesting or forward testing on the user’s specific instruments and timeframes.
The intention behind Omega Correlation is to bring techniques inspired by quantitative research, such as normalized return analysis, residual correlation, asymmetric lead–lag structure, price discovery logic and breakout event studies, into an accessible TradingView indicator. It is intended for traders who want a structured, professional way to understand how markets interact and to incorporate that information into their discretionary or systematic decision-making processes.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.