PROTECTED SOURCE SCRIPT
momentum spread strategy ilker

This script is the opposite of a traditional mean-reversion pairs trading strategy. It is a "Cointegration Breakdown" or "Momentum Divergence" tool.
Instead of betting on a spread's Z-Score to revert to 0, this strategy is designed to identify when the statistical relationship (the "elastic band") has snapped. It then provides signals to trade with the momentum as the spread diverges.
It filters for true breakouts by waiting for a "Momentum Regime," which is confirmed only when the pair's relationship becomes statistically unstable.
## 📈 Key Features
1. The Momentum Regime (Blue Background)
This is the core of the indicator. The background turns BLUE to signal a "Momentum Regime". This is the only time you should look for a momentum trade.
The blue background activates only if TWO conditions are met simultaneously:
• 1. Relationship Instability: The pair's relationship is broken. This is confirmed when either the rolling Correlation Z-Score (purple line) breaks down OR the Volatility Ratio (orange line) becomes unstable.
• 2. Divergence Confirmation: The Half-Life calculation (from our v2.8 script) shows "N/A (Divergent)" in the dashboard. This mathematically confirms the mean-reverting force (\lambda) is gone (it has turned positive) and the spread is statistically diverging.
If the background is GRAY, the script is in a "Neutral" or "Mean-Reversion" state, and all momentum signals should be ignored.
2. Momentum Breakout Signals
This strategy inverts the Z-Score logic. The 0-line is not a profit target; it is the breakout line.
• BUY Signal (Blue Triangle ▲): Appears only if the background is BLUE and the Z-Score (blue line) crosses ABOVE 0. This is your long momentum entry.
• SELL Signal (Fuchsia Triangle ▼): Appears only if the background is BLUE and the Z-Score crosses BELOW 0. This is your short momentum entry.
3. Built-in Trade Management
• Take Profit (X Cross): Your profit target is the outer band. The script plots an 'X' when the Z-Score hits the +2.0 band (for longs) or the -2.0 band (for shorts).
• Stop Loss (X Cross): Your stop is a failure of the momentum. The script plots an 'X' if the Z-Score re-crosses the 0-line against your trade.
4. Full Quant Dashboard
All the statistical components are plotted for analysis:
• Price Z-Score (Blue Line): Your primary momentum indicator.
• Z-Score Correlation (Purple Line): Lets you visually confirm the correlation breakdown.
• Volatility Ratio (Orange Line): Lets you visually confirm the volatility spike.
• Half-Life Dashboard: Confirms the regime by showing "N/A (Divergent)".
## 🛠 How to Use (Required Setup)
IMPORTANT: This indicator is designed to run on a spread chart (e.g., M2K/MES or MGC/SIL).
1. Load your spread chart first (e.g., type M2K/MES in the ticker bar).
2. Add this indicator to the chart.
3. Go into the indicator's Settings (⚙).
4. In the "Inputs" tab, you MUST fill in the two individual tickers:
• Ticker du Symbole 1 (REQUIS): M2K
• Ticker du Symbole 2 (REQUIS): MES
5. The script uses these two inputs to calculate the Volatility and Correlation filters. The main Z-Score is calculated from the spread chart itself.
This tool is for traders who want to capture explosive divergence moves that happen during fundamental news or regime changes, while filtering out the "noise" of stable, mean-reverting periods.
Instead of betting on a spread's Z-Score to revert to 0, this strategy is designed to identify when the statistical relationship (the "elastic band") has snapped. It then provides signals to trade with the momentum as the spread diverges.
It filters for true breakouts by waiting for a "Momentum Regime," which is confirmed only when the pair's relationship becomes statistically unstable.
## 📈 Key Features
1. The Momentum Regime (Blue Background)
This is the core of the indicator. The background turns BLUE to signal a "Momentum Regime". This is the only time you should look for a momentum trade.
The blue background activates only if TWO conditions are met simultaneously:
• 1. Relationship Instability: The pair's relationship is broken. This is confirmed when either the rolling Correlation Z-Score (purple line) breaks down OR the Volatility Ratio (orange line) becomes unstable.
• 2. Divergence Confirmation: The Half-Life calculation (from our v2.8 script) shows "N/A (Divergent)" in the dashboard. This mathematically confirms the mean-reverting force (\lambda) is gone (it has turned positive) and the spread is statistically diverging.
If the background is GRAY, the script is in a "Neutral" or "Mean-Reversion" state, and all momentum signals should be ignored.
2. Momentum Breakout Signals
This strategy inverts the Z-Score logic. The 0-line is not a profit target; it is the breakout line.
• BUY Signal (Blue Triangle ▲): Appears only if the background is BLUE and the Z-Score (blue line) crosses ABOVE 0. This is your long momentum entry.
• SELL Signal (Fuchsia Triangle ▼): Appears only if the background is BLUE and the Z-Score crosses BELOW 0. This is your short momentum entry.
3. Built-in Trade Management
• Take Profit (X Cross): Your profit target is the outer band. The script plots an 'X' when the Z-Score hits the +2.0 band (for longs) or the -2.0 band (for shorts).
• Stop Loss (X Cross): Your stop is a failure of the momentum. The script plots an 'X' if the Z-Score re-crosses the 0-line against your trade.
4. Full Quant Dashboard
All the statistical components are plotted for analysis:
• Price Z-Score (Blue Line): Your primary momentum indicator.
• Z-Score Correlation (Purple Line): Lets you visually confirm the correlation breakdown.
• Volatility Ratio (Orange Line): Lets you visually confirm the volatility spike.
• Half-Life Dashboard: Confirms the regime by showing "N/A (Divergent)".
## 🛠 How to Use (Required Setup)
IMPORTANT: This indicator is designed to run on a spread chart (e.g., M2K/MES or MGC/SIL).
1. Load your spread chart first (e.g., type M2K/MES in the ticker bar).
2. Add this indicator to the chart.
3. Go into the indicator's Settings (⚙).
4. In the "Inputs" tab, you MUST fill in the two individual tickers:
• Ticker du Symbole 1 (REQUIS): M2K
• Ticker du Symbole 2 (REQUIS): MES
5. The script uses these two inputs to calculate the Volatility and Correlation filters. The main Z-Score is calculated from the spread chart itself.
This tool is for traders who want to capture explosive divergence moves that happen during fundamental news or regime changes, while filtering out the "noise" of stable, mean-reverting periods.
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 제한 없이 자유롭게 사용할 수 있습니다 — 여기에서 자세히 알아보기.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 제한 없이 자유롭게 사용할 수 있습니다 — 여기에서 자세히 알아보기.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.