EKAI ClaudeTrader EA
- Experts
- Versione: 3.0
- Attivazioni: 5
EKAI ClaudeTrader - AI Analyst that Executes
Automates execution of multi-timeframe structural analysis generated by Claude Sonnet via the Anthropic API. Requires your own CLAUDE API key.
EKAI ClaudeTrader is a Multi-Instrument Expert Advisor that automates the execution of a structured multi-timeframe technical analysis produced by the Anthropic Claude Sonnet language model. At every M15 bar close, the EA sends a normalized market context to the Anthropic API and receives a structured JSON decision that may be executed as a pending order under your risk constraints.
HOW IT WORKS
At each M15 bar close for each configured symbol, the EA performs the following cycle:
1. Builds a normalized market context: 50 M15 candles, 50 H1, 30 H4, 20 D1, plus ATR(14), RSI(14) on M15 and H1, EMA(50) on M15, EMA(200) on M15 and H4, recent swing high/low on M15 and H1, day open/high/low, current spread and session state, plus your risk constraints.
2. Sends the context to the Anthropic Messages API via WebRequest.
3. Receives a JSON decision following a strict schema: NO_TRADE, BUY_LIMIT, SELL_LIMIT, BUY_STOP or SELL_STOP, with entry, stop-loss, take-profit, risk/reward ratio, validity in minutes, confidence (0-1) and a short rationale.
4. Applies hard risk gates: minimum confidence to execute, maximum open positions globally, one position per symbol, consecutive-loss pause, daily stop, cooldown, spread extreme rejection.
5. If all gates pass, places a pending order sized automatically from your risk percentage per trade and the stop distance (equity × InpRiskPercent / 100) / lossPerLot).
6. While positions are open, applies automatic breakeven (configurable R multiple), trailing stop from configurable R multiple using M15 swings, and time-based exit if the position does not reach +1R in N hours.
The model behaves conservatively by default. NO_TRADE outcomes are expected on the majority of bars because the methodology requires explicit multi-timeframe confluence (H4 and D1 provide context), at least 3 confluence factors, acceptable R:R, non-extreme spread, and no open position on the symbol.
METHODOLOGY APPLIED BY THE LLM
The system prompt instructs the model to default to NO_TRADE and only override when the setup is unambiguous. It evaluates multi-timeframe alignment (H4/D1 bias), price structure (higher highs/lows or lower highs/lows), volume-weighted context, momentum (RSI), volatility regime (ATR), and basic smart money concepts when applicable. Hard rules force NO_TRADE on extreme spread, mixed H4/D1 bias without a reversal pattern, fewer than 3 confluence factors, R:R below the configured minimum, or any configured news blackout window.
The decision is returned as a strict JSON contract, which the EA parses and validates before any order is placed. A malformed or out-of-contract response is logged and skipped.
TECHNICAL FEATURES
- Primary timeframe: M15 (one API call per bar close per symbol)
- Multi-symbol via instance-per-chart with a configurable whitelist
- Default analyzed symbols: EURUSD, GBPUSD, GBPAUD, USDJPY, NAS100, US30, XAUUSD, EURNZD (editable)
- Automatic broker symbol prefix/suffix detection (e.g. #EURUSD, EURUSD.m, EURUSDpro)
- Pending orders preferred (LIMIT for pullbacks, STOP for breakouts). Market orders optional
- Automatic lot sizing from risk percent and stop distance
- Automatic breakeven move and trailing stop from configurable R multiples
- Time-based exit for stale positions
- Daily stop, consecutive-loss pause with auto-restart after N hours, global max open positions
- Decision schema version 1.0 (contract parsed strictly, invalid responses logged)
- Prompt caching enabled by default on the Anthropic API (reduces input tokens for recurring system prompt)
- CSV decision log per month (every API call: timestamp, symbol, bid/ask, decision, confidence, levels, rationale, latency, tokens, http status, validation status)
- CSV execution log per month (every order event: SENT, FILLED, SL hit, TP hit, manual close, close reason, PnL)
- Optional NDJSON audit trail with full request bodies for forensic review
- HUD panel on chart: last decision, confidence, open PnL, daily PnL, state
RISK CONTROLS
- Master switch for execution (shadow mode by default on first run)
- Minimum confidence threshold to execute
- Risk per trade as a percentage of equity (default 0.10%)
- Daily stop: close all and block new orders if intraday drawdown exceeds threshold (default 1.5% of day-start equity)
- Consecutive loss limit: pause trading for N hours after N losses in sequence (default 3 losses, 24h pause)
- Maximum open positions across all symbols (default 3)
- One position per symbol at a time, no pending-order stacking
- Cooldown bars after losses (configurable)
- Pause state persists across MT5 restarts
REQUIREMENTS
Platform:
- MetaTrader 5, build 3800 or higher
- Windows 10/11 native or VPS recommended for 24/7 operation
Your own Anthropic API key:
- You must have an active Anthropic account with API access
- Paste your key into the InpApiKey input before first run
- Anthropic bills you directly based on token usage. The EA does not intervene in billing
- Model recommended: claude-sonnet-5-5 (or the dated model ID available in your console)
WebRequest whitelist:
- Add https://api.anthropic.com to the WebRequest allowed URL list in MT5 Options -> Expert Advisors
Approximate API cost:
- 1 symbol running 24/7: roughly USD 2 per day
- 8 symbols running 24/7: roughly USD 16 per day
- Exact cost depends on your Anthropic plan and token volume
Broker:
- Any broker offering the symbols you want to trade
- The EA has been tested on forex majors and crosses, US index CFDs, and gold
INSTALLATION
1. Buy and download the EA from this MQL5 Market listing.
2. In MT5: File -> Open Data Folder -> MQL5 -> Experts, verify the EA is installed. If not, re-run the Market installation flow.
3. Tools -> Options -> Expert Advisors -> Allow WebRequest for listed URL -> add https://api.anthropic.com
4. Open an M15 chart for each symbol you want to analyze.
5. Drag the EA onto the chart.
6. In the inputs: paste your Anthropic API key in InpApiKey. Review the risk parameters. Keep InpExecuteTrades = false on first run to observe decisions without placing orders.
7. Once comfortable with the EA behavior, set InpExecuteTrades = true to enable execution.
8. Common tab: enable Allow algorithmic trading.
CONFIGURATION
More than 40 inputs organized in blocks:
- API configuration: key, URL, model ID, timeout, max tokens
- Diagnostics: list available models, verbose journal
- Strategy: primary timeframe, candle counts per timeframe, minimum confidence
- Risk constraints sent to the model: max risk per trade, min RR, news blackout, cooldown
- Visualization: HUD panel, proposed order drawings on chart, colors
- Logging: CSV decisions, request body capture (NDJSON), verbose
- Token optimization: prompt caching toggle
- Execution master switch and whitelist
- Risk limits: daily stop, consecutive loss limit, max open global, pause duration
- Position management: breakeven R, breakeven buffer, trailing start R, time-based exit hours
Conservative defaults by design. The master execution switch is off by default to require explicit opt-in.
WHAT YOU SEE WHILE IT RUNS
- The HUD on chart shows the latest decision and confidence, open PnL for the day, open positions count, and state
- The Journal prints every decision with its rationale and every order event
- The CSV files under Common Files/EKAI_ClaudeTrader/ provide a complete audit trail
WHAT THIS EA DOES NOT DO
- It does not guarantee profits
- It does not include backtest results promising historical performance. The Strategy Tester cannot replicate live API behavior, so the shown test is a simplified internal fallback (EMA-based) that exists solely for Market validation. Do not interpret Strategy Tester results as representative
- It does not transmit your MT5 account number, balance, trader identity, or any personal data to the API. The payload contains only normalized market context
- It does not execute trades without your explicit opt-in via InpExecuteTrades = true
SUPPORT
Product support is handled through the Comments section of this MQL5 Market listing. Please include:
- Product version
- MT5 build
- Symbol and timeframe
- Clear description of the issue
- Journal screenshot if applicable
Response target: 24-72 business hours.
RISK WARNING
Trading forex, CFDs and leveraged instruments involves substantial risk of loss. Past performance of any technical methodology does not guarantee future results. The EA automates the execution of decisions produced by a third-party language model (Anthropic Claude); the model may produce incorrect decisions, the API may be temporarily unavailable, your broker may reject orders, and your network may fail. Validate the EA on a demo account for a sufficient period before trading real capital. Never trade capital you cannot afford to lose. The EA author and TSDCCORP Trading Resources are not responsible for trading losses, API costs billed by Anthropic, broker fees, network outages, or any direct, indirect, incidental or consequential damages arising from the use of this product.
