ZScore Cointegration
- Indicatori
- Oleksandr Art'omenko
- Versione: 1.2
- Aggiornato: 29 gennaio 2026
- Attivazioni: 5
The indicator calculates and displays the Z-Score spread (cointegrated spread) between two financial instruments. It is based on the ordinary least squares (OLS) method to estimate the relationship coefficient between the prices of two symbols and then normalizes the spread distribution into Z-Score values.
In a separate indicator window you will see:
-
Main Z-Score line (red)
-
Upper and lower thresholds (silver, dashed), set by the user
When the thresholds are reached the indicator signals a potential spread reversal:
-
Z-Score ≥ +Threshold → signal to sell the first symbol and buy the second
-
Z-Score ≤ −Threshold → signal to buy the first symbol and sell the second
Additionally, text labels with recommended position sizes (Lots) for both instruments are displayed on the chart, calculated either manually or automatically based on volatility (ATR).
How to use
-
Apply the indicator to any timeframe on the symbol you want to use as the first instrument (Symbol1).
-
Open the indicator’s properties window and specify the second symbol (Symbol2) to analyze the spread with.
-
Set the cointegration period and the Z-Score calculation period, as well as the desired threshold.
-
Choose the lot-sizing method: manually enter both sizes or leave the automatic calculation of the second lot by volatility.
-
When signals appear on the chart, refer to the color of the labels:
-
Green – buy
-
Red – sell
REMEMBER: The main secret in "Pair Trading" is to correctly select two interconnected and correlated instruments.
If you want a professional Expert Advisor for Pairs trading, check out PCA Pairs Trader Pro
Indicator parameters
| Parameter | Default | Description |
|---|---|---|
| Symbol2 | “GBPUSD” | The symbol of the second instrument for spread calculation. |
| InputSize | 0.1 | The lot size for the first instrument (Symbol1). |
| InputLot2 | 0 | The fixed lot size for the second instrument. If 0, size is automatically calculated by ATR. |
| ATRperiod | 14 | ATR period for volatility-based lot sizing. |
| CointegrationPeriod | 100 | Number of bars used for OLS regression when estimating the β coefficient (cointegration). |
| ZScorePeriod | 100 | Number of bars over which the mean and standard deviation of the spread are calculated for Z-Score normalization. |
| ZScoreThreshold | 2.5 | Z-Score threshold for generating entry/exit signals. The upper threshold is drawn dashed; the lower is its mirror negative. |
| DebugMode | false | Enable detailed logging (Print) for debugging and reviewing intermediate calculations (price copies, regression coefficients, lot labels, etc.). |
This indicator is ideal for creating arbitrage and market-neutral strategies on two related, correlated instruments. It automatically adapts to changing volatility and provides clear entry/exit levels based on the statistical properties of the spread time series.
