TwoKey AI MT5
- Experts
-
Abdullah Uygar Tuna
IT professional focused on algorithmic trading, quantitative analysis and practical MetaTrader 5 tools. I publish what I test, including what does not work. - Version: 1.11
- Activations: 10
The AI proposes the trade, hard risk rules decide. Claude, GPT or Gemini with your own API key.
TwoKey AI is an Expert Advisor for MetaTrader 5 that asks a large language model for a trade decision and then checks it against risk rules the AI cannot change. A trade needs two keys: the proposal of the AI and the approval of the EA.
How it works
On a schedule you set, the EA sends a compact market context (price bars on two timeframes, ATR, EMA and RSI values, swing levels, open positions, risk state in percent) to the AI provider you choose. The model answers in a fixed JSON format: open, close, partial close, tighten the stop or hold, with a confidence level and a short rationale. The EA validates every field, rejects stale or out-of-policy answers and sizes the position itself. Any invalid or missing answer becomes HOLD, and the reason is logged.
AI providers
Anthropic Claude, OpenAI, Google Gemini or an OpenAI-compatible endpoint, with your own API key (not included). Add the provider address under Tools, Options, Expert Advisors, Allow WebRequest. The key is sent only to that provider and is never written to logs. No account number, name, broker or balance is sent. A daily cost ceiling and a call limit keep the API bill under control.
Risk rules the AI cannot change
- risk per trade from the stop distance, lot sizes always rounded down
- daily loss limit and maximum drawdown (static or trailing), each with a lock
- open-risk cap, position caps and currency exposure caps, trades per day
- cooldown after a losing streak, no reversal and no adding to a losing position
- stop bounds in ATR, minimum reward-to-risk, stop verified after every fill
- spread, session, Friday and news filters
Prop-firm mode adds profit-target tracking, a protective mode near the target and an autonomy ceiling.
Autonomy and dashboard
Choose Conservative, Moderate or Full autonomy. The on-chart dashboard shows the status, provider and model, the last decision with confidence and rationale, risk and cost meters and open positions. You can switch autonomy, pause AI calls, switch shadow mode, stop new trades or close all positions. Actions that add risk ask for confirmation, and no button changes a hard limit. Dark and light theme, minimise and drag.
Testing
MetaTrader does not run web requests in the Strategy Tester, so the AI itself cannot be backtested. In the tester, and in the free demo, the EA runs a rule-based fallback strategy through the same risk layer, or replays AI decisions you recorded on demo. Start live in shadow mode on a demo account: decisions are shown and logged, nothing is executed.
Requirements
MetaTrader 5, hedging or netting account, an API key with credit from one provider, WebRequest allowed for its address. A VPS is recommended. No DLLs.
Setup guide, presets (.set files) and FAQ: https://www.mql5.com/en/blogs/post/779010
Trading involves a risk of loss. Results depend on market conditions, the model and your settings; no result is guaranteed.
