Cointegration Buy and Sell Signals

Apr 26, 2025

Static chart image
Signals
Correlation
Dashboard
Moving Averages
Volatility

The Cointegration Buy and Sell Signals indicator is a sophisticated technical analysis tool designed to identify high-probability market turning points using advanced statistical models. It leverages concepts from statistical arbitrage and mean reversion to detect trend exhaustion before it becomes fully apparent on price charts.

Usage

The tool produces Buy and Sell labels on the chart when specific statistical criteria are met. It is best used as a reversal system or a filter for overbought/oversold setups.

  • Standalone Reversals: Trade signals as independent entries for mean-reversion setups.
  • Signal Filtering: Use the provided diagnostic table to confirm if market conditions (correlation and stationarity) are suitable for a trade.
  • Signal Stacking: Combine these signals with other trend indicators or volume-based tools to confirm movement and reduce false entries.

The indicator features a diagnostic dashboard in the top-right corner to help users interpret the underlying data:

  • Z-Score: Indicates how extreme the current price deviation is.
  • Z-Score Momentum: Shows if the extreme deviation is starting to revert.
  • Correlation: Confirms if the short and long EMAs are still statistically related.
  • Stationary: A "Yes/No" toggle indicating if the spread is stable enough for mean-reverting strategies.

Details

The script operates by analyzing the relationship between a short-term and long-term EMA. Instead of a simple difference, it performs a rolling linear regression to calculate residuals. These residuals are normalized by historical price volatility (ATR) to ensure the indicator remains scale-invariant across different asset classes.

To issue a signal, the script calculates a Z-score and compares it against dynamic thresholds based on historical percentiles. It also incorporates a Pearson correlation filter and a stationarity proxy (similar to an ADF test) to ensure that mean reversion is statistically probable. A signal control mechanism ensures that Buy and Sell signals alternate and respect a user-defined cooldown period.

Settings

  • Short EMA: Sets the period for the reactive short-term moving average.
  • Long EMA: Sets the period for the baseline long-term moving average.
  • Z-Score Lookback: The number of bars used to calculate the mean and standard deviation of the spread.
  • Volatility Window: The period used to normalize the spread by historical volatility.
  • Correlation Lookback: The period used to test the statistical alignment between the two EMAs.
  • Hurst Approximation Window: A multiplier used to determine the stationarity of the spread.
  • Z Threshold Percentile: Determines how extreme the Z-score must be to trigger a signal (e.g., 90% filters for the top/bottom 10% of values).
  • Min Bars Between Signals: A cooldown setting to prevent overtrading and signal clusters in volatile markets.

FAQ

How do I use the diagnostic table?

The table provides real-time confirmation. For example, a signal is most reliable when "Stationary" is "Yes" and "Corr" is above 0.7. If these conditions aren't met, the indicator may suppress signals to avoid low-probability trades.

Can this be used on any timeframe?

Yes, because the indicator uses volatility normalization and dynamic thresholds, it adapts to the price action of any timeframe or asset class, including stocks, forex, and crypto.

How can I access Cointegration Buy and Sell Signals?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free access on the following platforms
tradingviewSymbolTradingView
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

ninjatraderNinjaTrader
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

metatrader4MetaTrader 4/5
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

thinkorswimThinkorswim
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.