Executive summary
Gold is a macro instrument before it is a technical one: its price is driven by real yields, dollar strength and risk appetite, yet most retail systematic strategies trade it on price patterns alone. This project designs an agent architecture that reads the macro calendar and central bank communication, converts that unstructured information into a structured regime and conviction score, and feeds it to a rule-based execution layer that trades XAU/USD with explicit risk limits.
Architecture
The system is deliberately split into layers that can be tested, replaced and audited independently — the interpretation of macro news never touches order placement directly.
- Ingestion layer. Scheduled collection of the macroeconomic calendar, released prints versus consensus, US real yields, the dollar index and positioning data, normalised into a single time-stamped event table.
- Interpretation layer. A large language model agent scores each event on a fixed rubric (direction, magnitude, surprise versus consensus, persistence) and produces a structured JSON output rather than free text, so that every downstream decision is traceable to a numeric field.
- Regime layer. Aggregation of individual event scores into a macro state — disinflation, growth scare, hawkish repricing, risk-off — with a persistence rule that prevents the state from flipping on a single print.
- Execution layer. A deterministic MQL5 expert advisor on MetaTrader 5 maps the regime and conviction score to a target exposure, then applies volatility-scaled position sizing, ATR-based stops and a hard daily loss limit.
- Guardrails. The agent can only widen, reduce or flatten exposure within pre-set bounds; it cannot alter risk limits, leverage or the instrument universe.
Backtesting protocol
- Point-in-time data. Macro events are replayed with their original release timestamps and first-print values to avoid look-ahead from subsequent revisions.
- Realistic frictions. Spread widening around releases, slippage and swap costs are modelled explicitly, since a news-driven strategy is precisely where idealised fills flatter results the most.
- Walk-forward validation. Parameters are fitted on a rolling in-sample window and evaluated out-of-sample, reporting Sharpe, maximum drawdown, hit rate and average holding period.
- Ablation tests. The macro layer is switched off to isolate how much performance genuinely comes from the macro signal rather than from the risk management overlay.
Strategy versus benchmark
The interactive chart could not be loaded (the Plotly CDN is unreachable). The full analysis is available in the PDF write-up.
Illustrative data — placeholder pending publication of the final backtest results.
Discussion
On using an LLM in a trading loop. The model is used as a classifier of text, never as a forecaster of prices. Its output is constrained to a fixed schema, logged, and consumed by deterministic rules — which keeps the strategy reproducible and makes every trade explainable after the fact.
- The dominant risk is not model error but data leakage: any backtest built on revised macro series will overstate performance.
- Regime persistence rules matter more than signal precision — reacting to every print produces turnover that the cost model erases.
- Next steps: extend the same architecture to a second macro-driven instrument to test whether the regime layer generalises beyond gold.