Pairs & Relationship Diagnostics

Engle-Granger Cointegration Test Calculator

Enter aligned X and Y level series, declare a fixed residual-ADF lag and calculate the augmented Engle–Granger two-step statistic for Y on X. The page exposes the fitted spread, MacKinnon cointegration references and direction sensitivity without claiming a stable pair, mean-reversion edge or trade setup.

Y-on-X direction explicitTwo-step residual auditNo pairs-trade verdict

Enter aligned X and Y level series

Use the same timestamps, frequency and preprocessing in both columns. Direction is fixed as Y on X and is not symmetric.

Entered

Whole lags only. Version 1.0.0 uses the entered lag exactly and performs no hidden selection.

Enter 20 to 500 finite levels, oldest to newest, with one aligned timestamp per row.

Y is the response in the first-stage Y-on-X equation; row count and order must match X.

Cointegration boundary: The null is no cointegration under this directed constant-included specification. The model does not verify that both input series are integrated of order one, that the relation is stable or that the fitted residual is tradable.

Two-step cointegration reference

Entered Stationarity and Cointegration 1.0.0.

Derived
Enter two aligned level seriesThe result will expose the Y-on-X regression, row residuals, fixed-lag residual ADF statistic and cointegration-specific MacKinnon references.

How the augmented Engle–Granger calculation works

Step 1: Yt = intercept + slope × Xt + ut
Step 2: Δut = γut−1 + ΣδiΔut−i + εt

Version 1.0.0 first fits ordinary least squares in one declared direction: Y on X with a constant. It records the slope, intercept, fitted Y and residual for every aligned row. Reversing X and Y creates a different first-stage equation and can change the two-step result.

The second stage applies a no-constant fixed-lag ADF regression to the fitted residual sequence. Although the residual regression has no constant, its test statistic is evaluated with the cointegration-specific MacKinnon response surfaces for two I(1) series and a constant in the first-stage equation.

The 1%, 5% and 10% critical references are not ordinary one-series ADF critical values. Version 1.0.0 uses the MacKinnon N=2 finite-sample curves with n minus one observations, matching the declared statsmodels 0.14.6 oracle.

Worked example from the audited fixture

The audited fixture contains 48 aligned level observations and declares one lag for the residual ADF step.

  1. The first-stage Y-on-X equation estimates slope 1.48214117, intercept 1.25190533 and residual population deviation 0.29439384.
  2. The residual statistic is −4.11579461, the cointegration-specific approximate p-value is 0.00487607 and the 5% finite-sample critical reference is −3.46922086.

Reproduce it: select “Load audited example” above. The governed engine retains full precision and rounds only the visible interface.

How to interpret the result

  • Begin with direction. The page fits Y on X; it does not search both directions and select the more favorable output.
  • The residual statistic is evaluated against cointegration-specific, not ordinary ADF, reference surfaces. Substituting one-series critical values would be incorrect.
  • The maintained Engle–Granger setup expects both level series to be I(1). This browser page cannot establish integration order from the same test result.
  • A fitted residual can change with the window, lag, deterministic terms, structural breaks, price scaling, missing observations and data revisions.
  • Cointegration is a statistical long-run relation under assumptions. It does not supply transaction costs, entry thresholds, position sizing, stop logic or evidence of out-of-sample profitability.

Assumptions and limits

  • Enter 20 to 500 equal-length level observations aligned by meaningful timestamps and frequency; malformed or unequal rows fail closed.
  • The calculator cannot verify that X and Y are each I(1), that timestamps match, or that data sourcing and preprocessing are consistent.
  • Only a constant-included Y-on-X first stage is supported. Johansen systems, multiple regressors, trend terms and alternative directions are outside Version 1.0.0.
  • The residual ADF lag is entered manually and used exactly. No AIC, BIC, t-statistic lag search or multiple-specification correction is performed.
  • Near-perfect collinearity is rejected because the numerical residual test becomes unstable and an infinite statistic is not a useful browser result.
  • No cointegration, stable-pair, mean-reversion, hedge-ratio recommendation, strategy-validation, forecast, grade, signal, position instruction or trade recommendation verdict is generated.

Which time-series diagnostic answers which question?

ADF, KPSS and Engle–Granger do not produce one interchangeable stationarity score. Their null hypotheses, deterministic terms, lag roles and reference distributions differ. The comparison below keeps those choices visible before any user interprets a p-value or critical boundary.

Comparison of nulls, alternatives, reference families and lag roles
DiagnosticNull hypothesisAlternativeReference familyLag role
Augmented Dickey–FullerUnit rootNo unit root under constant or trend choiceLower-tail MacKinnon approximationFixed augmentation lag
KPSSLevel or trend stationarityUnit-root component under chosen nullPublished 0.01–0.10 tableFixed Newey–West lag
Engle–GrangerNo cointegration for Y on XCointegration under two-series assumptionsN=2 MacKinnon approximationFixed residual ADF lag
Ljung–BoxNo residual autocorrelation through hAt least one nonzero residual autocorrelationChi-square approximationMaximum lag and fitted orders

Frequently asked questions

  • It calculates a reference for the null of no cointegration after fitting a constant-included Y-on-X relation and applying a fixed-lag ADF regression to its residuals.
  • The first-stage ordinary-least-squares equation is directional; reversing the response and predictor changes the fitted equation and can change the two-step result.
  • Enter aligned level observations for two series that the maintained analysis treats as integrated of order one, using matching timestamps, frequency and preprocessing.
  • Each residual equals entered Y minus the fitted intercept minus the fitted slope times entered X for that same aligned row.
  • Residual cointegration statistics have a different distribution, so the page uses MacKinnon N=2 response surfaces for a constant-included first-stage equation.
  • No. Integration order is a maintained user assumption and must be evaluated separately; the two-step output cannot establish it for both inputs.
  • No. A statistical long-run relation does not supply stable hedge ratios, execution costs, entry thresholds, exits or out-of-sample performance evidence.
  • No. It generates no cointegration verdict, stable-pair label, mean-reversion claim, trade signal, position instruction or recommendation.

Sources and methodology

Version 1.0.0 was locked after its regression statistics, reference values and example outputs were independently recomputed with statsmodels 0.14.6 and SciPy 1.13.1. The browser calculator performs local arithmetic and does not upload entered observations. Reference probabilities remain conditional on the disclosed model and data assumptions.

Verify the ordered evidence before testing it

Reconcile the exact symbol, price basis, statement window, observation timestamps, timezone, sampling frequency, missing rows, spread, commission, financing, currency conversion, rollover adjustments and preprocessing before entering a series. Correct regression arithmetic cannot repair selected, misaligned or cost-inconsistent evidence.

XM

Review applicable statements, symbol specifications and execution terms.

Check XM terms

FBS

Confirm account-history and trading-cost conventions for your region.

Check FBS terms

FXOpen

Verify statement, charge and execution records before deriving inputs.

Check FXOpen terms

Risk and affiliate disclosure: Leveraged forex and CFD trading can result in substantial losses. These are affiliate links, so ForexMT4Indicators.com may receive compensation if you register or trade through them, at no additional cost to you. Availability and terms vary by jurisdiction and broker entity.

Disclaimer: The results from this tool are estimates for educational and informational purposes only and may differ from your broker's figures. This is not financial or investment advice. Trading forex and CFDs carries a high level of risk and can result in the loss of all your capital. Always verify calculations with your broker and trade within your risk tolerance.