Smart Pair Trading — Input Parameters Guide

25 June 2026, 11:20
Sugianto
0
26
Smart Pair Trading — Input Parameters Guide (v1.04)

A detailed reference for every input of the Smart Pair Trading EA. 

Inputs (General)

MainSymbol (default: EURUSD) — The primary symbol, traded as leg A, the first side of the spread.

SecondSymbol (default: XAUUSD) — The second symbol, traded as leg B. The EA hedges A against B, so the two should be correlated (or inversely correlated).

LotSizeA (default: 0.04) — Lot size for leg A. When auto-lot is enabled, this value instead serves as the A:B ratio rather than a fixed size. Automatically normalized to your broker's volume rules (min / step / max).

LotSizeB (default: 0.02) — Lot size for leg B. Ideally set so the notional value of both legs is balanced (beta-weighted), keeping the spread market-neutral.

ShowPanel (default: false) — Show or hide the on-chart dashboard. Visual only; it does not affect trading.

CalcTF (default: M1) — The timeframe used for all calculations (correlation, OLS regression, Z-score). This is the data timeframe, not the chart timeframe.

ZPeriod (default: 1000) — Number of bars used to compute the mean, standard deviation, beta/alpha, and Z-score. Larger values are smoother and more stable but slower to react. Minimum 10 (the EA fails to initialize below this).


Money Management (Auto-Lot) 

UseAutoLot (default: false) — When enabled, lot sizes are computed automatically from free margin (the fixed LotSizeA/LotSizeB are then used only as the A:B ratio). When disabled, the EA uses the fixed lots as before.

RiskPercent (default: 5.0) — Percentage of free margin used as the margin budget for one pair. The EA scales both legs so the pair's total margin ≈ RiskPercent% of current free margin, keeping the A:B ratio intact. Range 0.1–100. Removes the need to re-tune lots manually whenever the account size changes.


Entries / Exits

EntryThreshold (default: 1.92) — The Z-score level required to open a position. When |Z| ≥ this value, the spread is considered stretched enough to enter. Recommended range 1.5–2.0. Higher = more selective.

ExitThreshold (default: 0.9) — The Z-score level for a normal exit (full mean-reversion). When |Z| falls to ≤ this value, the trade is closed. Must be smaller than EntryThreshold (otherwise the EA fails to initialize).

BetaSmoothing (default: 0.2) — EMA smoothing factor applied to the Z-score to reduce noise and false signals. 0 = off (raw Z), 0.1–0.5 = light-to-moderate smoothing. (Despite the name, this is a smoothing coefficient, not the regression beta.)


Correlation Filter

MinCorrelation (default: 0.80) — Minimum correlation between the two symbols required to allow a trade. Below this, entries are blocked — preventing trades when the relationship weakens. Range 0.5–1.

UseReturnsForCorr (default: false) — Compute correlation from log-returns instead of price levels. (Since v1.01 this is a real, editable input on the panel.)

CorrPeriod (default: 100) — Number of bars used for returns-based correlation. Ignored while UseReturnsForCorr = false.

UseAbsoluteCorr (default: true) — Use the absolute value of correlation. When true, a strong negative correlation (e.g. −0.85) still counts as valid — useful for pairs that move in opposite directions (such as EURUSD vs XAUUSD).


Risk / Logistics

MagicNumber (default: 2025) — Unique ID tagging this EA's positions, so they are never confused with manual trades or other EAs.

SlippagePoints (default: 30) — Maximum allowed slippage on execution (in points). Automatically multiplied by 10 for 3/5-digit symbols (3-digit gold, 5-digit forex).

CloseTarget (default: 5) — The "Smart Exit" — closes early once the Z-score has converged part of the way from entryZ back toward zero. Range 1–9: 1 = exit very early (90% of |entryZ| remaining), 5 = mid-way (50%), 9 = very late (10% remaining).

CloseProfit (default: 100.0) — Profit target in account currency for the combined P/L of both legs. 0 = off.

CloseLoss (default: 0.0) — Loss limit in account currency (stop loss). 0 = off. Recommended to set a value for live trading.

SecondsWaitAfterClose (default: 600) — Mandatory pause (in seconds) after closing before a new trade may open. 600 = 10 minutes. Range 0–86400.

LossCooldownSec (default: 60) — Extra rest (in seconds) applied specifically after a losing close, on top of SecondsWaitAfterClose. Range 0–3600.


Time Open Allowed (entry window)

OpenStartHour / OpenStartMinute (default: 01:00) — The hour:minute when opening new positions becomes allowed.

OpenEndHour / OpenEndMinute (default: 23:00) — The hour:minute when opening new positions stops. Overnight sessions are supported when start > end.


Time Close Allowed (exit window)

CloseStartHour / CloseStartMinute (default: 01:30) — The hour:minute when Z-based position closing becomes allowed.

CloseEndHour / CloseEndMinute (default: 23:00) — The hour:minute when closing stops. Take-profit, stop-loss, and smart-exit are only evaluated inside this window, so set it wide enough that exits are never missed.


Dashboard

FontSize (default: 15) — Dashboard font size in points. Cosmetic only.


Built-in Safeguards (automatic, not inputs)

These behaviors are always active and shape how the inputs play out:

  • Dual-symbol market gate — the EA only trades when BOTH symbols' markets are open, avoiding the "Market closed" leg failure on Monday reopen.
  • Retry brake — a failed open/close locks the candle and starts the cooldown, so the EA can't spam rejected orders.
  • Affordability (margin) guard — entries are skipped cleanly if free margin can't cover both legs, preventing "No money" rejects.
  • Verified close — the pair is marked flat only after both legs are confirmed closed; if a leg's market is shut, the close is deferred and retried, so positions are never orphaned.