Cointegration Buy and Sell Signals
Apr 26, 2025

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 indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.