AI Agent Strategy Blueprint

Exactly how the XAU/USD AI Agent starter kit works — every component, every rule, and the honest limits. Signal-only, demo-only, by design.

MT4 Bridge — exports live XAU/USD data to JSON every 15 seconds
Python Engine — applies technical + news + risk filters
Telegram Alerts — signal sent to your phone, you decide the trade
By design: the agent never places orders itself. v1 is signals only.

1. Data Strategy — the MT4 Bridge

File: mt4/XAU_AI_Bridge.mq4

What it exports, and why

  • 300 M15 bars — about 3 days of 15-minute candles. Enough history for EMA-50 and RSI-14 to stabilize; old enough data adds no value on M15.
  • Indicators per bar: EMA-20, EMA-50, RSI-14, ATR-14 — the exact inputs the signal engine needs. Nothing more, nothing wasted.
  • Refresh every 15 seconds — near-live without hammering the terminal.
  • Live spread in points — feeds the spread filter (see risk rules).
  • Why M15: it is the trigger timeframe of the main trading strategy (H4 bias → H1 pullback → M15 entry). The agent watches the trigger; the human confirms the higher timeframes.

2. Technical Signal Strategy

File: agent/main.py → technical_signal(). The exact rules:

ConditionSignalLogic
EMA-20 > EMA-50 and 50 ≤ RSI ≤ 68BUY SETUPUptrend + healthy momentum, not overbought
EMA-20 < EMA-50 and 32 ≤ RSI ≤ 50SELL SETUPDowntrend + healthy momentum, not oversold
RSI > 68 or RSI < 32NO TRADEOverbought/oversold — chasing is dangerous
EMA-20 ≈ EMA-50 (flat)NO TRADEChop — moving averages whipsaw in ranges
Fewer than 60 barsNO TRADENot enough data for indicators to be valid

Honest limits

  • EMA and RSI are lagging — they confirm moves, they don't predict them.
  • The engine cannot see support/resistance or chart structure — that is the human's job on the H4/H1 (see the main strategy).
  • In sideways markets it will flip between signals — the RSI bands (32–68) exist to reduce exactly this.

3. News Engine Strategy

File: agent/NEWS_ENGINE_SPEC.md — design for the production engine. Status in v1: placeholder (check the calendar manually until connected).

What it will ingest

CPI / Core CPIPCE / Core PCEFOMC + dot plotNFPPPIGDPISMRetail SalesJobless ClaimsFed speechesDXYUS 10Y yieldOilGold ETF flowsCentral-bank buyingGeopolitics

The rules

  • Every event graded LOW / MEDIUM / HIGH / CRITICAL.
  • Blackout on HIGH/CRITICAL: no signals from 30 min before until 15 min after (matches the config).
  • All events timestamped in UTC, converted to PKT for alerts.
  • Store Actual vs Forecast vs Previous — the surprise moves gold, not the number alone.
  • Never assume "war = gold up." Combine the headline with DXY, yields, oil, volatility and the actual price reaction.
  • Multiple confirmations required before any BUY/SELL setup is produced.

4. Risk Strategy

File: agent/config.example.json — the numbers that protect capital.

Configured guards

  • Risk per trade: 0.5% — position size is derived from this, never from gut feeling.
  • Spread filter: 80 points max — wide spreads mean news chaos or illiquidity; signals are skipped.
  • News blackout: 30 / 15 min — wired into the engine, not left to memory.
  • Multi-timeframe ready: config lists M15/H1/H4/D1 — the engine will require higher-timeframe agreement before promoting a signal (planned).
  • Human rule: max 2 acted signals per day; 1% daily loss cap — then the platform closes.

5. Alert Strategy

File: agent/main.py → telegram() — the loop runs every 60 seconds.

What you receive

  • Signal (BUY SETUP / SELL SETUP / NO TRADE), live price, EMA-20, EMA-50, RSI, ATR.
  • The reason for the signal and the news-filter state — so you can verify, not blindly follow.
  • Every alert ends with: "SIGNAL/DEMO ONLY — no automatic order execution."
  • Alerts never fire without a configured Telegram bot — no token, no messages, no noise.

Planned improvement: alert only when the signal changes state, instead of every loop.

6. Safety & Path to Production

Why v1 is deliberately limited — and what comes next.

Now (v1): signals only — the code physically cannot send orders to MT4.
Next: connect a real news/calendar API to the news engine.
Then: multi-timeframe confirmation (H1/H4 agreement) + paper-trade logging.
Then: 3+ months of logged demo results, reviewed weekly in the journal.
Only then: consider an execution bridge — small size, hard daily loss cap, kill switch.

Related: XAU/USD beginners guide · what moves gold prices · complete XAU/USD strategy