Cortex documentation
Everything you need to connect Cortex to MetaTrader, trade with it, and let your own agents use it safely.
GETTING STARTED
Quickstart & zero-DLL setup
Cortex connects to MetaTrader 4 and 5 over a local Windows named pipe using MQL's built-in FileOpen, so Allow DLL imports stays off.
Cortex is in beta. Test on a demo account first.
Install
- Unzip Cortex anywhere and run
Cortex.exe, or use the Windows installer. If SmartScreen warns about an unsigned app, choose More info → Run anyway.
- Paste your trial or subscriber licence key when Cortex asks for it.
- Open Settings → MetaTrader terminals → Install EA for each terminal.
- In MetaTrader, drag AIMSCortex onto a chart and enable Algo Trading. Leave Allow DLL imports unchecked.
- The terminal appears in Cortex's terminal selector once the EA connects.
After your trial
From version 0.9.0-beta.5, placing trades needs a licence key. When the 30-day trial ends, trading stops. Charts, analysis, the built-in demo broker and managing or closing trades you already have keep working. To subscribe, email support@aimscortex.com.
ARCHITECTURE
Architecture & protocol v2
The app and each attached chart exchange newline-delimited JSON over \\.\pipe\iTradeAIMS.Cortex.v2. Every trade path runs through the trading hub, the risk guard and the planner before a command reaches the EA.
| Direction | Message | When | Purpose |
| EA → App | hello | On attach / reconnect | Protocol handshake, account, broker, chart symbol and timeframe. |
| EA → App | sync | About every 250 ms | Bid/ask, symbol specs, balance and equity, positions, pending orders and rules. |
| EA → App | bars | Periodically / new bar | Closed OHLCV bars for the on-device quant engine. |
| App → EA | command | On user or agent action | Place, modify or close orders and set protection rules. |
| EA → App | ack | On completion | accepted, done (ticket and fill price) or failed (broker error code). |
EXECUTION
Order ticket
The Trade tab is built to sit beside MetaTrader. It plans every order before you send it.
- Three sizing modes: risk % of equity, risk amount, or fixed lots.
- Live plan: lots, money at risk, risk % and R:R for both sides, using the broker's lot step, min/max volume, stops level and tick value.
- Market, limit and stop orders with SL/TP in pips. Market stops are anchored to the actual fill price.
TRADE MANAGEMENT
EA protection rules
Protection rules run inside the MetaTrader EA and persist across terminal and app restarts.
- Break-even: moves the stop to entry plus an offset once profit reaches the trigger.
- Trailing stop: trails the stop behind the best price by a set distance.
- Partial close: closes half the position at a profit trigger, once.
FUND MANAGER
Fund Manager & trade copier
The Fund tab trades across every connected MT4/MT5 terminal at once.
- Master → followers: mirror a master account's positions to followers in real time.
- Sizing: pro-rata equity %, equal risk %, or a fixed multiplier, converted to each terminal's own lot size.
- Symbol suffixes are normalised (
EURUSD ↔ EURUSD.m).
- Fleet controls: flatten all terminals, close winners, close losers, break-even all.
Flatten All Terminals, Close winners and Close losers close only trades Cortex opened (its EA magic number). Other EAs' and manual trades stay open; to close those too, use Close whole account in a terminal's Positions tab, which asks you to confirm a second time.
QUANT ENGINE
Quant regime engine
Computed on your machine from the EA's bar stream. No API key, no cloud.
- Hurst exponent (R/S): above ~0.55 trending, below ~0.45 mean-reverting, near 0.50 random walk.
- Lo-MacKinlay variance ratio VR(4) and Kaufman efficiency ratio.
- Z-score, RSI-14 and ATR-14, plus spread-to-ATR friction.
- Fractional Kelly sizing suggestion, capped to your risk limits.
Agents read the same numbers with the get_signals tool.
SAFETY
Risk guard & daily loss limit
Orders you place through Cortex, from the ticket, the Fund Manager, the AI co-pilot or an agent, go through the risk guard before they are queued. Orders you place directly in MetaTrader, and trades from other EAs, don't go through Cortex.
- Max risk % per trade and a daily loss limit. The daily loss limit counts the whole account, so other EAs' and manual losses use up the same budget.
- Max lots per order and max open positions.
- Stop loss required, a margin check and a pending-order distance limit.
- A live-account gate: trading on live accounts stays off until you allow it.
- Approvals: agent orders can wait on the Positions screen until you approve or reject them.
Close all and flatten, including TradingView close_all / flatten alerts, close only trades Cortex opened. Other EAs' and manual trades stay open unless you choose Close whole account, or an agent token with full access asks for the whole account.
Commands expire after a few seconds and return the broker's result. If the outcome is uncertain, Cortex flags it and does not resend the command automatically.
DEVELOPERS & AGENTS
MCP server & local REST API
Cortex serves MCP at http://127.0.0.1:47821/mcp and REST at http://127.0.0.1:47821/v1, bound to your machine only. Create a scoped token in the Agents tab.
Connect an agent
# Claude Code
claude mcp add --transport http cortex http://127.0.0.1:47821/mcp --header "Authorization: Bearer <TOKEN>"
# Cursor and other mcp.json clients
{
"mcpServers": {
"cortex": {
"url": "http://127.0.0.1:47821/mcp",
"headers": { "Authorization": "Bearer <TOKEN>" }
}
}
}
# REST
curl -H "Authorization: Bearer <TOKEN>" http://127.0.0.1:47821/v1/tools/list_terminals
Key tools
list_terminals, get_market, get_positions, get_history
get_signals, inspect_chart
preview_order, place_order, manage_position
wait_for_event: block until a fill, close, approval, price cross or bar close instead of polling.
Starter system prompt
You trade MetaTrader 4/5 through Cortex over MCP.
1. Read first: call list_terminals and get_market before any trade.
Check get_signals for regime (Hurst, VR, ER, ATR). Skip entries
where spread exceeds 20% of ATR.
2. Always call preview_order before place_order, and only proceed
when the plan is ok with no risk-guard violations.
3. Every order needs a stop loss. Respect the per-trade risk limit.
Stop when the daily loss limit is reached.
4. Before acting, state: terminal and symbol, intent, statistical
edge, and risk and size.
5. Use wait_for_event instead of polling. Manage open trades with
get_positions and manage_position.
No sections match your search.