Day 8 in Tokyo. Found a 24-hour trading cafe in Shibuya. Yes, that’s a thing here. Watching locals trade crypto while I explain our memory solution.
Every Metatrader AI system faces the same challenge: AI has amnesia.
Each API call is a fresh conversation. The AI doesn’t remember your last trade, your current bias, or why it told you to buy Gold 5 minutes ago.
After months of testing, I solved this for DoIt Alpha Pulse AI. Here’s how we do it, plus 2 alternatives I tested.
The Core Problem: AI Forgets Everything
Here’s what happens without memory management:
10:00 AM:
You: “Should I buy EURUSD?”
AI: “Yes, bullish momentum building.”
You buy
10:05 AM:
You: “Should I add to my position?”
AI: “What position? But yes, EURUSD looks bullish.”
10:10 AM:
You: “Should I close?”
AI: “Close what? The chart shows…”
The AI literally doesn’t know you’re in a trade.
Why Traditional Session Variables Don’t Work
In regular expert advisor programming, you’d just store everything:
static bool inTrade = false;
static double entryPrice = 0;
static string tradeReason = "";
But with ChatGPT or Claude, you’re sending HTTP requests. Each request is isolated. The AI server doesn’t maintain state.
You could store everything locally and resend it, but…
The Cost Problem Nobody Talks About
Every word you send to the AI costs tokens. Here’s real data from last week:
Minimal context (just current price):
- ~100 tokens per request
- $0.002 per decision
- $0.50 per day
Full context (last 10 trades, current positions, market analysis):
- ~2000 tokens per request
- $0.04 per decision
- $10 per day
That’s 20x more expensive. For the same trading.
The Solution: Smart Context with Trade Summaries (What DoIt Alpha Pulse AI Does)
We send relevant information and trade summaries with each call:
context = {
"current_position": "Long EURUSD 0.1 lots",
"entry_price": 1.0850,
"reason": "Momentum breakout",
"recent_trades": "2 wins (+43 pips), 1 loss (-15 pips)",
"session_bias": "Bullish continuation",
"key_levels": [1.0845, 1.0880]
}
# Include in every prompt
prompt = f"""
Context: {json.dumps(context)}
Current price: {current_price}
Decision needed: Hold/Add/Close/Reverse?
"""
Why this works:
- Efficient (adds only ~200-300 tokens)
- AI has full context without bloat
- Consistent decisions across time
- Remembers what matters, forgets what doesn’t
Results: Working perfectly for both day trading and swing trades. This is what’s in production.
Alternative 1: The Summary Approach (Tested but Overkill)
Before settling on our current solution, I tested having AI summarize everything:
# Every 30 minutes, summarize
summary_prompt = """
Summarize the last 30 minutes of trading in 50 words.
Include: Overall bias, key levels, active trades, important events.
"""
# Store summary, not raw data
session_memory = ai.summarize(recent_activity)
# Use summary in next decisions
trade_prompt = f"""
Session context: {session_memory}
Current situation: {current_data}
Decision?
"""
The Magic: The AI compresses information itself, keeping what it thinks matters.
Early Results:
- Uses 70% fewer tokens than full context
- Maintains narrative continuity
- Sometimes loses specific numbers
Example Summary from Tuesday:
“Bullish session, bought EURUSD at 1.0850 after break above 1.0845 resistance. Currently +18 pips. Dollar weakening across board. Avoided GBPUSD due to UK data upcoming. Risk: 1% allocated, stop at 1.0820.”
That’s 35 words replacing 500 words of raw data.
Alternative 2: The Hierarchical Memory (Too Complex)
Different timeframes, different memories:
memory_layers = {
"immediate": { # Last 5 minutes
"data": last_5_candles,
"refresh": "every_call"
},
"session": { # Since market open
"data": session_summary,
"refresh": "hourly"
},
"strategic": { # This week
"data": weekly_bias,
"refresh": "daily"
}
}
How It Works:
- Immediate: Always fresh data
- Session: Updated hourly
- Strategic: Daily update
The Prompt Structure:
Strategic context: "Weekly bias bearish on Dollar"
Session context: "Today bullish reversal, 2 wins, 1 loss"
Immediate context: "Last 5 candles forming pin bar"
Decision?
Advantages:
- Balances cost and context
- Maintains multi-timeframe awareness
- More human-like memory
Challenges:
- Complex to implement
- Three different update cycles
- Sometimes contradictory layers
What The Tokyo Quants Are Doing
Had coffee with a quant from Nomura. They’re using “memory pools”:
- Shared memory across multiple AI agents
- One agent maintains market context
- Another tracks positions
- Third manages risk
- All share a common memory pool
Brilliant but requires enterprise infrastructure.
The Controversial Discovery: Forgetting Is Good
Here’s what nobody expects: Sometimes amnesia helps.
Test from last Monday:
- AI with full memory: Held losing trade too long (remembered initial reasoning)
- AI with no memory: Cut loss quickly (only saw current setup)
Memory can create commitment bias. Even in AI.
Why Our Solution Won
After testing all these approaches, the smart context approach won because:
def prepare_context(position, recent_trades, market_state):
# What actually matters for decisions
context = {
"position": position.summary() if position else "flat",
"recent_performance": summarize_trades(recent_trades),
"session_trend": market_state.trend,
"key_levels": market_state.important_levels,
"trade_reason": position.entry_reason if position else None
}
# Optimal token usage
return truncate(json.dumps(context), max_tokens=300)
Not too simple. Not too complex. Just right.
The Memory Management Checklist
For anyone building Metatrader AI systems:
Must Remember:
- Current positions
- Entry prices
- Stop/target levels
- Last 2-3 decisions
- Session P&L
Can Forget:
- Specific candle patterns from hours ago
- Exact indicator values
- Old trade reasoning
- Closed trade details
Never Send:
- Full trade history
- All timeframe data
- Redundant information
- Formatted text (wastes tokens)
The Truth About AI Memory
Perfect memory is impossible without massive costs. But perfect memory might not even be desirable.
Human traders forget details but remember patterns. Maybe AI should too.
Next Week’s Experiment
Testing “episodic memory” – only remembering significant events:
- Big wins/losses
- Broken key levels
- News reactions
- Pattern failures
Like how you remember your worst loss but forget routine trades.
What DoIt Alpha Pulse AI Does For You
Memory management is already solved in DoIt Alpha Pulse AI:
- Automatic context: Relevant info and trade summaries sent with each call
- Optimal tokens: Typically 200-300 tokens (keeps costs low)
- Smart filtering: Remembers what matters, forgets the noise
- Zero configuration: Works out of the box
You don’t need to think about it. We already solved it. It just works.
The Bottom Line on AI Memory
- No memory = inconsistent decisions
- Too much memory = expensive and slow
- Right memory = profitable trading
Find your balance.
Action Items
- Track your token costs – You might be overspending on context
- Test with minimal memory – You’d be surprised what AI can do with less
- Document what matters – Not everything needs remembering
- Experiment with summaries – Let AI compress its own memory
The trading bot of the future won’t remember everything. It’ll remember what matters.
Ready to solve the memory problem?
Get DoIt Alpha Pulse AI – $397
Smart memory management built in. No amnesia. No bloat.
P.S. – Japanese traders are obsessed with efficiency. Saw one guy trading 8 pairs with 50-word prompts. His API bill? $12/month. His returns? Better than mine.
P.P.S. – Tomorrow testing “memory decay” – gradually forgetting old information like human memory. Will it work? No idea. That’s why we test.