The z-score puts the spread in its own standard deviations, so one set of bands can be read across periods
Start with the spread, not with either price. Fit the hedge ratio on a training window by least squares on log prices, then form the spread as one log price less the hedge ratio times the other, minus an intercept.
The half life comes from regressing the change in the spread on its lagged level. If the slope is negative, the half life is about minus the natural log of two divided by the slope, in sessions. The exact form is minus ln 2 over ln(1 plus the slope). A slope near zero or positive means there is no pull back at a usable speed on that sample.
The z-score is the spread minus its rolling mean, divided by its rolling standard deviation. A window of a few half lives is a common starting point, not a law. Entry at a large absolute z-score, exit near zero and a stop further out are conventions that depend on costs and the sample.
The chart shows the z-score of a Nifty and BANKNIFTY pair on a 60 session window, with one and two standard deviation bands. On this sample the fitted half life runs for most of the sample length, far past that window, and the Engle Granger test does not reject, so the spread shows no usable pull back and the window is only a drawing choice. A z-score is not a cointegration test.
Two cautions. Choosing the window and the bands on the same data that then tests the trade is look ahead in disguise. Lot size rounding and futures rolls also change the effective hedge, so a clean z-score on paper can trade differently in practice.
Before you trade. Derivatives trading carries a high risk of loss. SEBI's study "Profitability of Individual Traders in the Equity Derivatives Segment (FY25 to FY26)" (August 2026) found that 87.7% of individual traders in equity F&O made net losses in FY26, with aggregate net losses of Rs 91,685 crore. Read the SEBI study