Building Forex Pulse: An AI Trading Bot That Learns From Every Trade
I've been building a forex trading bot called Forex Pulse. Not a weekend hack — a full autonomous trading system with machine learning models, an agentic AI decision pipeline, and a self-improving feedback loop that learns from every single trade it takes.
Here's what it actually is, how it works, and what the numbers look like so far.
What It Does
Forex Pulse trades 9 currency pairs plus gold on OANDA, running 24 hours a day. It watches M5 candles (5-minute intervals) for mean-reversion setups, scores them with a binary ML classifier trained on millions of bars, then passes each signal through a multi-layer AI gauntlet before placing real orders on a practice account.
The entire thing is written in Python 3.12, built around an async event bus where components communicate through subscriptions rather than importing each other directly. Every piece — the data feed, the signal engine, the risk guard, the position manager — is decoupled. That architecture has saved me more times than I can count during refactors.
The ML Stack
The core directional model is a LightGBM binary classifier (UP/DOWN) with 45 features spanning multiple timeframes (M5, M15, M30, H1). It's deliberately shallow — 15 leaves, 100 trees. Deep architectures overfit on forex noise. An Asian-hours specialist model handles the quieter 22:00–05:00 UTC window with a different feature set.
On top of the M5 model, there's a scalp pipeline running on M1 candles. The V3 scalp model hits 68.2% accuracy at confidence >= 0.60, firing about 27 trades per day across 9 pairs. It uses an 8-gate pipeline: session filter, spread ratio, volatility regime, M5 alignment, momentum burst detection, ML prediction, and risk management.
There's also a Trade Outcome Predictor — a fundamentally different model that doesn't predict direction at all. It predicts "will this trade win?" The key discriminators aren't directional features; they're path features like choppiness, maximum adverse excursion, and ATR acceleration.
The Agentic Layer
This is where it gets interesting. Pure ML gets you to about 53% bulk accuracy on forex with classical technical features. I've tested 300+ configurations — different architectures, per-pair models, ensembles, neural variants, alternative label definitions. They all plateau at the same ceiling. Classical indicators are saturated.
So the bot has an agentic AI layer on top. A Thesis Desk generates macro-level market views every 4 hours using Claude Sonnet, then a Technician and Risk Manager (both Haiku) evaluate each pair against that thesis. Signals that conflict with the macro view get vetoed or downweighted.
But the part I'm most excited about is the Living System. After every single trade closes, a Growth Coach (Sonnet) evaluates what happened — was the entry timing good? Was sizing appropriate? Did the exit capture the available move? It scores four agents (Strategist, Technician, Risk Manager, Scalp Trader) using real pip movement data, MFE/MAE from M1 candles, and session/regime context.
Those scores feed into ability profiles with EMA smoothing and ratcheting floors, so agents never permanently regress. An Experiment Engine (Opus) proposes parameter hypotheses with safety collars. Darwinian weighting ranks agents by performance and adjusts their influence accordingly.
The system publishes parameter recommendations to Firestore — it doesn't auto-apply them yet. I want to watch the recommendations accumulate before giving it that lever.
The Dashboard
Everything streams to a cloud dashboard at forex-pulse-bot.web.app. It's React + TypeScript, deployed on Firebase Hosting with Firestore as the realtime data layer. I recently did a full UI overhaul — sacred geometry design language, Flower of Life hero section, prismatic color palette, pure Firestore realtime subscriptions (deleted all the polling infrastructure).
The dashboard shows open positions with live P&L, the thesis desk's current macro view, scalp gate readiness per pair, the Living System's agent scores, and an AgenticFlow infographic that visualizes the complete 4-layer decision pipeline in real time. There's also a model metrics bar showing deployed model accuracy, Sharpe ratio, and feature counts.
I check it on my phone throughout the day. Cloud is the product — localhost is just for development.
The Honest Numbers
I'm not going to sugarcoat this. The bot is currently in paper-money learning mode with relaxed gates, and it's losing money: 213 trades, 17.8% win rate, -$35,953 net on a $100K practice account.
But the breakdown tells a more nuanced story. Scalp dwell timeouts account for 118 of those trades at 0% WR — the scalp pipeline exits too early before the trade has a chance to develop. SL hits account for 12 trades at -$22,687. And trades held longer than 15 minutes have a 52% win rate. The bot is fundamentally a swing trader being forced to scalp.
These are paper dollars. The entire point of this phase is to generate learning data for the Living System. Every loss teaches the scoring pipeline something about which conditions produce wins and which don't.
USD/JPY is the only profitable pair so far at +$988. That's consistent with what the model's calibration data shows — it has a genuine edge on JPY but struggles with the highly correlated USD cluster.
What I've Learned
Classical technical indicators have a hard ceiling. After testing 300+ configurations across 16 architecture variants, 24 per-pair variants, 9 ensemble methods, and 6 neural architectures, they all converge at ~53% bulk accuracy. The paths to break through are wavelet denoising (+5.3pp in testing) and non-price data sources — news sentiment, COT reports, rate differentials.
P&L math is deceptively hard. The bot shipped a bug where JPY-pair profits were reported at 100x their actual value because the P&L conversion from quote currency to USD was wrong. I now have regression tests specifically guarding against this.
Correlation is the real risk. EUR/USD, GBP/USD, AUD/USD, and NZD/USD are all highly correlated. Without a correlation gate, the bot piles into the same effective position across four pairs and gets blown up 4x simultaneously. The gate now allows hedging (opposite directions cancel USD exposure) but blocks concentration.
class_weight="balanced" will silently kill your model when the minority class (FLAT) is under 1% of samples. The model learns to predict FLAT on everything and fires zero trades in production. This cost me an entire weekend.
What's Next
The plan is to watch the Living System accumulate data, tighten gates based on what it learns, and push toward consistent positive returns on paper. Once the system can sustain ~1% per week — an honest, realistic target — I'll put $100 of real money behind it.
The wavelet denoising research is the most promising technical path forward. Extended non-price feature history (COT, FRED rates, VIX) is the other major lever. Both need more engineering before they're deploy-ready.
If you want to see the dashboard live, it's at forex-pulse-bot.web.app. What you see there is real data from real OANDA practice orders, updated in real time.