Every AI trading assistant I've used has the same problem: amnesia.
You ask Claude to analyze a gold trade. It gives you solid analysis — identifies the London session breakout, notes the resistance level, suggests a stop loss. Great.
Next week, the exact same setup appears. And Claude has zero memory of what happened last time. Did that breakout work? Did the stop loss get hit? It doesn't know. It can't know.
That's not how real traders think. A veteran trader carries thousands of pattern recognitions in their head. They call it "feel for the market" — but it's really just memory refined into judgment over time.
So I asked: what if we could give AI that same kind of memory?
The Problem: AI Agents Are Stateless
Most AI trading tools today work like this:
- You give the AI some market data
- It analyzes and gives a recommendation
- The conversation ends
- Next time, it starts from zero
There's no learning loop. No way for the AI to say "last time I saw this pattern in Asian session, it failed 4 out of 5 times — I should be cautious."
Existing solutions don't solve this either. Trading journals are built for humans, not agents. Backtesting frameworks test strategies, but don't give the AI a persistent memory it can query in real-time.
The Solution: A 3-Layer Memory Architecture
We built TradeMemory Protocol — an open-source memory layer for AI trading agents.
It has three layers, inspired by how human traders actually develop expertise:
L1: Raw Trade Memory
Every trade is automatically recorded with full context — entry price, exit price, stop loss, take profit, timeframe, session, outcome, and the AI's reasoning at the time.
Think of it as a perfect trading journal that never forgets a detail.
L2: Pattern Memory
This is where it gets interesting. A reflection engine periodically reviews L1 data and extracts patterns:
- "London session breakouts on XAUUSD: 73% win rate (n=41)"
- "Counter-trend entries during NFP: 23% win rate — avoid"
- "Pullback entries after strong trend days: 81% win rate when RSI < 40"
The AI discovers what works and what doesn't — from its own history.
L3: Strategy Memory
L2 patterns get promoted into active strategy adjustments:
- "Asian session detected → reduce position size by 0.8x (based on lower win rate)"
- "Strong trend day + pullback setup → increase confidence, full position"
This is memory becoming real-time judgment. The AI equivalent of "feel for the market."
Why MCP?
We built this on Anthropic's Model Context Protocol (MCP) because it solves distribution. Any MCP-compatible AI agent — Claude, GPT-based agents, open-source models — can plug into TradeMemory and immediately get persistent memory.
The protocol exposes 7 tools:
-
record_trade— Log a trade with full context -
get_trade_history— Query past trades with filters -
reflect_on_trades— Trigger pattern discovery -
get_patterns— Retrieve discovered patterns -
get_strategy_adjustments— Get real-time strategy modifications -
get_memory_stats— Dashboard of memory state -
search_memory— Semantic search across all memory layers
No API keys to manage, no separate dashboard. The AI talks directly to its own memory.
The Reflection Engine
The core innovation is the ReflectionEngine. After enough L1 trades accumulate, it uses Claude's API to analyze the history and extract patterns.
It's essentially the AI reflecting on its own decisions — what worked, what didn't, and why. The patterns it discovers get stored in L2, and the strongest patterns get promoted to L3 as active strategy adjustments.
This is inspired by the Reflexion framework and the FinMem paper from 2023, which proved that layered memory architectures improve LLM trading performance. We took that academic insight and engineered it into a production-ready, pluggable protocol.
Real-World Usage
My own quantitative trading system, NG_Gold (trading XAUUSD on MT5), is the first production user of TradeMemory Protocol. The system runs three strategies — VolBreakout, Pullback Entry, and IntradayMomentum — and every trade flows through the memory system.
Getting Started
git clone https://github.com/mnemox-ai/tradememory-protocol.git
cd tradememory-protocol
pip install -r requirements.txt
python -m pytest tests/ -v # 36 tests passing
See the full Quick Start Guide for MCP integration setup.
What's Next
- Demo with real trade data flowing through L1 → L2 → L3
- More platform adapters (Interactive Brokers, crypto DEX)
- Multi-agent memory sharing (multiple AI agents learning from the same trade history)
- Community-contributed pattern libraries
Links
- GitHub: github.com/mnemox-ai/tradememory-protocol
- Architecture docs: ARCHITECTURE.md
- License: MIT
Built by Mnemox in Taipei. We build memory infrastructure for AI agents.
If you're working on AI trading agents or have ideas about what memory patterns would be useful, I'd love to hear from you in the comments or on GitHub.
Top comments (0)