Quantum Stat Arb Engine
- 专家
- 版本: 1.10
- 激活: 5
Quantum Stat-Arb Engine is an Expert Advisor for pairs trading. It monitors the price ratio between two symbols (by default the chart symbol and GBPUSD), opens an opposite-direction position on each symbol when the ratio moves far from its average, and closes both when the ratio returns toward the mean.
How it works
- On each new closed bar of the analysis timeframe, the ratio A/B is compared with its mean and standard deviation over the lookback window to obtain a Z-score.
- The correlation of bar-to-bar changes of both symbols over the same window must be positive and at least the minimum correlation; negatively correlated pairs are not traded.
- Z-score above the entry level: sell A and buy B. Below the negative entry level: buy A and sell B.
- Leg A uses the base lot. Leg B is sized so both legs have similar ATR(14) value, using each symbol's tick value.
- Exit: both legs are closed when |Z| falls to the exit level.
- Margin for both legs is checked first; if the second leg fails, the first is closed.
Risk protection
- Leg stop: each leg can carry a stop loss at a multiple of ATR(14) (default 6).
- Basket stop: both legs are closed when the combined loss reaches a percentage of the balance (default 2%).
- Broken pair: if one leg is closed (for example by its stop), the remaining leg is closed on the next tick.
Live trading
Live execution is disabled by default. With InpAllowTrading = false the EA only monitors and displays the statistics. Set InpAllowTrading = true to let it trade. In the Strategy Tester trading is always enabled so the logic can be evaluated.
Inputs
- Symbol A (empty = chart symbol, default), symbol B, analysis timeframe, lookback bars
- Entry Z, exit Z, minimum correlation
- Base lot, allow trading, use leg stops, leg stop in ATR multiples, basket stop %, magic number
Notes and limitations
- Both symbols must exist at your broker with the exact names entered and have history; otherwise the EA stays idle.
- Relationships between symbols can change or break down; a high past correlation does not ensure the ratio will revert. Costs on two legs affect results.
- Requires margin for two simultaneous positions.
Risk warning
Trading leveraged products carries a high level of risk. Tester results do not guarantee future performance. Test on a demo account first and risk only capital you can afford to lose.
Recommended use
Closely related pairs such as EURUSD/GBPUSD or AUDUSD/NZDUSD, H1 or higher.
