Getting Started

Expert Advisors

Backtesting

Deployment

Portfolio Strategies

Risk Management

MT5 Agent Setup

API Reference

Getting Started

Platform Overview

Archomata is an automated forex trading platform that brings together Expert Advisor management, backtesting, live deployment, and risk monitoring under a single dashboard. The platform connects to MetaTrader 5 broker accounts through a lightweight agent that runs on your Windows machine, while the web dashboard gives you full visibility into your strategies, positions, and account performance from any device.

The architecture is built around three core services. The web dashboard (built on Next.js) is where you manage everything: EAs, strategies, accounts, and deployments. The API server (built on FastAPI) handles all business logic, authentication, and data persistence. The MT5 Agent is a polling client that runs alongside your MetaTrader 5 terminal, executing commands like connecting accounts, deploying EAs, and reporting positions back to the platform.

Archomata supports multi-tenancy through organizations. Each organization has its own accounts, agents, strategies, and team members. Role-based access control lets you assign granular permissions -- from read-only viewers to full administrators -- so your team can collaborate safely on shared trading infrastructure.

Creating Your Account

To get started, navigate to the registration page and provide your email address and a password. You will receive an email verification link that must be confirmed before you can sign in. If your organization uses Google or Azure AD for single sign-on, you can authenticate directly through your corporate identity provider -- the platform will automatically link your SSO credentials to your Archomata account when the email addresses match.

After verifying your email and signing in, you will either create a new organization or be invited to join an existing one. Organization administrators can send invitations by email, which include a link to join with a predefined role. If you are the first user in your organization, you will automatically receive administrator privileges.

Your profile settings are accessible from the avatar dropdown in the top-right corner of the dashboard. From there you can update your display name, change your password, manage active sessions, and configure your preferred theme.

Back to top

Expert Advisors

What is an Expert Advisor?

An Expert Advisor (EA) is an automated trading program written in MQL5 that runs inside the MetaTrader 5 platform. EAs execute trades based on predefined rules without manual intervention -- they can open and close positions, manage stop-losses and take-profits, and adapt to market conditions according to their programmed logic. In Archomata, EAs are the fundamental building block of your trading strategy.

Each EA in Archomata is associated with a specific currency pair (symbol) and timeframe. For example, you might have an EA configured to trade EUR/USD on the H1 (one-hour) timeframe. This pairing of EA logic with a specific market and timeframe determines the conditions under which the EA will generate trading signals.

Archomata manages the full lifecycle of your EAs: uploading MQ5 source files, compiling them with MetaEditor, running backtests to validate performance, and deploying the compiled EA to live broker accounts. The platform tracks every version and test result so you have a complete audit trail of your trading algorithms.

Browsing the EA Library

The EA Library is a curated collection of Expert Advisors available to all organizations on the platform. Platform administrators manage the library by publishing and unpublishing strategies and their associated EAs. When you browse the library, you can see each EA's target symbol, timeframe, and historical backtest performance before deciding to incorporate it into your own portfolio.

Organization-specific EAs are visible only to members of that organization. To add an EA to your organization, navigate to the EAs page under the Strategies section and create a new EA record by specifying its name, symbol, and timeframe. You can then upload the MQ5 source file and initiate compilation and backtesting through the platform.

Understanding EA Metrics

When evaluating an EA, Archomata provides a comprehensive set of performance metrics derived from backtesting. Key metrics include net profit (total P&L after all trades), profit factor (gross profit divided by gross loss), maximum drawdown (the largest peak-to-trough decline in equity), and the Sharpe ratio (risk-adjusted return). A profit factor above 1.5 and a Sharpe ratio above 1.0 are generally considered indicators of a robust strategy.

Pay close attention to maximum drawdown, as it directly impacts how much capital you need to withstand losing streaks. The platform also tracks trade count, win rate, average win size versus average loss size, and the longest consecutive losing streak. These metrics together help you assess whether an EA's edge is statistically significant or the result of curve fitting to historical data.

Equity curves are displayed alongside these metrics to give you a visual sense of how the EA performed over time. Look for smooth, consistently upward-trending curves rather than ones that depend on a few large winning trades. Periods of flat or declining equity reveal the drawdown characteristics you should expect in live trading.

Creating Custom EAs

To add a custom EA, go to the EAs page and click "Add EA." Provide a name, select the target symbol (such as EUR/USD or GBP/JPY), and choose the timeframe the EA is designed for. Once created, you can upload your MQ5 source file. The MT5 Agent will compile the source using MetaEditor64 on your Windows machine and report the compilation result back to the platform.

If compilation fails, the error details from MetaEditor are returned so you can diagnose and fix the issue in your MQ5 code. Successful compilation produces an EX5 binary that is ready for backtesting and deployment. We recommend running at least one backtest before deploying any new EA to a live account.

Back to top

Backtesting

Running Your First Backtest

Backtesting lets you evaluate how an EA would have performed against historical market data before risking real capital. To run a backtest, navigate to your EA's detail page and initiate a new backtest run. The platform will send a backtest command to your MT5 Agent, which executes the test using the MetaTrader 5 Strategy Tester on your Windows machine.

Configure the backtest parameters including the date range, initial deposit, leverage, and the modeling mode. "Every tick" mode provides the highest accuracy by simulating every price movement, while "Open prices only" runs much faster and is suitable for EAs that only trade on bar opens. Choose a date range that covers multiple market conditions -- at least two to three years is recommended for most forex strategies.

Once the backtest completes, the MT5 Agent reports the results back to the platform, where they are stored and associated with the EA. You can view past backtest results at any time from the Backtests section or from the EA's detail page. Each result includes the full set of performance metrics and an equity curve chart.

Interpreting Backtest Results

A good backtest result shows consistent profitability across the entire test period, not just a few lucky months. Start by examining the equity curve: a smooth, upward-trending line suggests the strategy has a genuine edge, while a jagged or hockey-stick-shaped curve may indicate over-optimization. Compare the net profit against the maximum drawdown -- a strategy that earns $10,000 but has a $9,000 drawdown is far riskier than one earning $5,000 with a $1,000 drawdown.

Evaluate the profit factor (the ratio of gross profit to gross loss). Values below 1.0 mean the strategy loses money; values between 1.0 and 1.3 are marginal; values above 1.5 indicate a strong edge. Also consider the number of trades: a strategy with only 20 trades over three years does not provide enough data for statistical confidence, while thousands of trades give you a much clearer picture of expected performance.

Be aware of backtesting limitations. Spread variations, slippage, and requotes in live markets are not perfectly modeled. Results during low-liquidity periods (such as holidays or news events) may differ significantly from live performance. Use backtesting as a filter to eliminate bad strategies, but always validate with a demo account before going live.

Walk-Forward Analysis

Walk-forward analysis is a method for validating that a strategy generalizes beyond the data it was optimized on. The concept is straightforward: divide your historical data into a series of in-sample (training) and out-of-sample (testing) windows. Optimize the EA's parameters on the in-sample data, then test performance on the immediately following out-of-sample period. Repeat this process across the entire dataset.

A strategy that performs well in walk-forward testing is far more likely to succeed in live trading than one that was only optimized on a single backtest period. If the out-of-sample results are consistently profitable and close to the in-sample results, the strategy is considered robust. If out-of-sample performance degrades significantly, the strategy may be over-fitted to historical patterns that will not repeat.

Archomata's AI analysis agent can assist with walk-forward evaluation by automating the segmentation of test periods and aggregating performance metrics across windows. Use the Analysis section to review agent runs that include walk-forward breakdowns and optimization recommendations.

Back to top

Deployment

Connecting a Broker Account

Before deploying any EA to live trading, you need to connect at least one broker account to the platform. Go to the Accounts section and add a new account by providing your MT5 account login number and assigning it to an agent. The agent is the bridge between Archomata and your MetaTrader 5 terminal -- it runs on the same Windows machine where MT5 is installed.

When you issue a "connect" command, the MT5 Agent receives it during its next poll cycle, logs into the broker account using the MT5 API, and reports the account's balance, equity, and connection status back to the platform. Once connected, the agent periodically pushes state updates including current balance, equity, margin, and all open positions.

Each agent can manage multiple broker accounts. The Agents page shows each agent's heartbeat status (online, offline, or stale) so you always know whether your bridge is running. If an agent goes offline, its accounts will stop receiving state updates, but existing positions and deployments remain active on the broker side.

Deploying an EA

To deploy an EA, navigate to the Deployments section and create a new deployment by selecting an EA and a target broker account. The platform sends a deploy command to the account's agent, which copies the compiled EX5 file to the appropriate MetaTrader 5 directory and attaches it to the specified chart. Deployment status is tracked in real time -- you will see the command progress from "pending" through "running" to "success" or "error."

Each deployment has a unique bridge ID that links it back to the specific agent and account. You can deploy multiple EAs to the same account (on different symbols or timeframes) and the same EA to multiple accounts. The Deployments list shows the current status of each deployment, and you can issue commands to stop or remove deployments at any time.

We strongly recommend deploying to a demo account first and monitoring performance for at least a few weeks before switching to a live account. The platform treats demo and live accounts identically, so your workflow and monitoring experience will be the same.

Monitoring Live Deployments

The Positions page provides a real-time view of all open and recently closed positions across your accounts. Each position shows the symbol, direction (buy/sell), lot size, open price, current price, and unrealized P&L. The MT5 Agent pushes position updates to the platform on every state sync cycle (every few seconds by default), so the dashboard stays current.

The Accounts page displays equity history charts that track your account's balance and equity over time. You can view snapshots for different periods -- the last hour, 24 hours, 7 days, or 30 days -- to spot trends and evaluate deployment performance. These snapshots are stored as equity_snapshots in the database for long-term analysis.

If something goes wrong with a deployment, you can close all positions for a specific account directly from the dashboard. The close command is sent to the MT5 Agent, which executes it against the broker. For critical situations, the kill switch feature (covered in Risk Management) provides an automatic safety net.

Back to top

Portfolio Strategies

Building a Strategy

A portfolio strategy in Archomata is a structured grouping of multiple EAs with defined risk parameters and automation rules. Rather than deploying EAs individually, strategies let you manage a coordinated portfolio where each EA plays a defined role and consumes a portion of the overall risk budget. Create a new strategy from the Strategies section by giving it a name and description.

Once the strategy is created, assign EAs to it. Each EA assignment specifies which Expert Advisor to include and what share of the strategy's risk budget it should consume. This portfolio approach means you can diversify across multiple symbols, timeframes, and trading styles while maintaining control over your total exposure.

Strategies have a lifecycle: they start in "draft" status while you are building and testing them, and can be activated when you are ready to trade. Platform administrators can publish strategies to the platform-wide library, making them available for all organizations to adopt. Organizations can then apply their own overrides to customize risk parameters for published strategies.

Strategy Versioning

Portfolio strategies support versioning, mirroring the EA version system. Each version snapshots the strategy's full configuration -- EA assignments, rules, and risk budget mode -- at a point in time. This lets you track how your portfolio has evolved, compare configurations, and understand what changed between iterations.

Create a new version from the strategy detail page by clicking "Create Version." The system captures the current state of all EA assignments and rules into a JSONB snapshot. Versions follow a lifecycle: draft, testing, pending review, published, and archived. The strategy's "current version" pointer updates automatically when you create or publish a version. A maximum of 5 active versions are kept; older versions are automatically archived.

Risk Budget Allocation

The risk budget is a percentage-based allocation system that prevents any single EA from consuming too much of your strategy's total risk capacity. When you assign an EA to a strategy, you specify a risk budget percentage. The platform warns you if the total allocation across all assigned EAs exceeds 100%, which would indicate over-leveraging.

Each strategy has a risk budget mode that controls how the budget is distributed at runtime:

  • Fixed (default) -- each EA gets its assigned percentage. Inactive EAs' budget goes unused.
  • Equal Dynamic -- active EAs split 100% equally, each capped at its assigned maximum.
  • Proportional -- inactive EAs' budget is redistributed proportionally to active EAs, capped at 150% of their base allocation. Lower priority number means last to be cut on oversubscription.

Organizations can override the risk budget allocations on published platform strategies to match their own risk tolerance. These overrides are stored separately and do not affect the original strategy definition, so each organization can customize without impacting others.

Strategy Rules & Automation

Strategy rules define automated behaviors that apply to the entire portfolio. Each rule specifies a condition type and an action. Supported condition types include:

  • Schedule -- time of day, day of week, day of month, week of month
  • Market -- ADX threshold, ATR percentile, max spread
  • Portfolio -- drawdown threshold, profit target, consecutive losses

Actions include activate, deactivate, reduce/increase risk (with multiplier), close all positions, set risk budget, and notify. Each rule targets a specific EA within the strategy and can be individually enabled or disabled.

Rules are managed through the strategy's detail page using a structured form with condition-specific configuration fields. This allows you to build layered risk management: the kill switch handles per-account emergencies, while strategy rules handle portfolio-level automation.

Back to top

Risk Management

Kill Switch Protection

The kill switch is Archomata's primary safety mechanism. When activated for an account, it signals the MT5 Agent to close all open positions and prevent new trades from being opened. The kill switch can be activated manually from the dashboard at any time, or it can trigger automatically when risk thresholds are breached. Every kill switch activation and deactivation is recorded in a dedicated audit log for full traceability.

The kill switch operates at the account level. When triggered, the RiskGuardian component in the MT5 Agent closes all positions for that account and sets a persistent flag that blocks further trading. To resume trading after a kill switch event, an administrator must manually deactivate the kill switch from the dashboard. This deliberate manual reset ensures that someone reviews the situation before trading resumes.

Kill switch state is persisted to a local JSON file on the agent machine, so it survives agent restarts. Even if the agent process crashes and restarts, previously activated kill switches remain active until explicitly cleared.

Drawdown Thresholds

The platform monitors two types of drawdown for automatic kill switch activation. Maximum drawdown measures the decline from peak equity to current equity -- if this percentage exceeds the configured threshold (default: 10%), the kill switch activates. Daily loss measures the decline from the day's starting balance -- if this exceeds its threshold (default: 5%), the kill switch activates.

You can also enable trailing drawdown mode, which resets the peak equity reference point at the start of each trading day. In standard mode, peak equity only ever increases (it is the all-time high water mark). In trailing mode, each new day starts fresh, meaning the drawdown measurement is relative to recent performance rather than the account's all-time peak. Trailing drawdown is more forgiving for accounts that have had historical highs they may not revisit.

A third threshold limits the maximum number of open positions per account (default: 10). If an EA attempts to open more positions than the configured limit, the kill switch activates. This prevents runaway strategies from over-exposing an account.

Per-Account Risk Overrides

Default risk thresholds apply globally to all accounts managed by an agent, but you can configure per-account overrides for situations where different accounts have different risk profiles. For example, a small test account might have a more permissive 15% maximum drawdown, while a large production account might be restricted to 5%.

Per-account overrides are configured through the MT5 Agent's environment variables using the MT5_AGENT_PER_ACCOUNT_RISK setting, which accepts a JSON dictionary mapping account IDs to their specific thresholds. Each override can specify max_drawdown_pct, max_daily_loss_pct, and max_positions independently. Any threshold not specified in the override falls back to the agent's global default.

The RiskGuardian evaluates thresholds on every state sync cycle. When account data arrives, it computes the current drawdown and daily loss percentages, compares them against the applicable thresholds (per-account overrides if configured, otherwise global defaults), and activates the kill switch if any limit is breached. All threshold evaluations and state changes are written to the risk audit log file.

Back to top

MT5 Agent Setup

Installing the Agent

The MT5 Agent is distributed as a standalone Windows executable that requires no Python installation. It acts as a bridge between the Archomata platform and your MetaTrader 5 broker accounts, running as a system tray application on your Windows machine.

Installation steps:

  1. Download ArchomataAgentSetup.exe from the Archomata platform (choose Dev or Production build)
  2. Run the installer on your Windows machine (requires Windows 10/11, 64-bit)
  3. The installer automatically detects MetaTrader 5 by checking the Windows registry and common installation paths
  4. If MT5 is not found, the installer:
    • Downloads the official MT5 installer from MetaQuotes CDN (https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe)
    • Runs the MT5 installation silently with no dialogs or user interaction required
    • Displays a progress bar with status messages during the 2-5 minute installation
    • Verifies successful installation by checking for terminal64.exe in the installation directory
  5. The agent installs to C:\Program Files\Archomata\Agent
  6. Windows startup is configured automatically (the agent will run on login by default)
  7. The agent starts minimized in the system tray with no console window
  8. Look for the gold "A" icon in your system tray (notification area)
  9. Right-click the tray icon and select Settings
  10. Enter the API key from the Archomata dashboard (see Configuring API Keys below)
  11. The agent automatically connects to the API and starts MetaTrader 5 minimized if not already running

MT5 Auto-Start and Monitoring: The agent automatically launches MetaTrader 5 minimized on startup if it's not already running. Every 30 seconds, the agent checks if the MT5 process (terminal64.exe) is still active. If MT5 crashes or is closed unexpectedly, the agent automatically restarts it to maintain uninterrupted trading operations.

The agent starts automatically on Windows login by default. You can toggle this behavior in the Settings window. The agent runs in the background with no console window—all interaction happens through the system tray menu. Production builds connect to https://app.archomata.com while development builds use https://app-dev.archomata.com.

Configuring API Keys

The MT5 Agent authenticates with the Archomata API using an API key. In the platform dashboard, navigate to the Agents section and click Add Agent. Enter a name for the agent and click create. The API key is displayed once—copy it immediately as it cannot be retrieved later.

On your Windows machine where the agent is installed:

  1. Right-click the agent's tray icon (gold "A")
  2. Select Settings from the context menu
  3. Paste the API key into the API Key field
  4. The key is encrypted and stored securely in %APPDATA%\Archomata\config.json
  5. Click Save—the agent will immediately connect to the API

The Settings window also displays the MetaTrader 5 installation status. You'll see one of the following:

  • Installation found, Connected to account [login] — MT5 is installed and logged into a broker account
  • Installation found, Not authenticated — MT5 is installed but not logged in
  • MetaTrader5 package not installed — The agent will use a mock adapter for testing

For advanced users or development builds, environment variables with the MT5_AGENT_ prefix can override default settings. However, the standalone executable uses hardcoded API URLs: production builds point to https://app.archomata.com and development builds point to https://app-dev.archomata.com.

Agent Features

The standalone agent includes a full graphical interface accessible from the system tray. Right-click the tray icon to access:

  • Settings — Configure API key, toggle Windows startup, view real-time MT5 installation and authentication status
  • Logs — View all agent activity logs with an export button that saves to your Downloads folder
  • Check for Updates — Manually check for new agent versions (also checks automatically on startup)
  • About — View version information and company details
  • Exit — Gracefully shut down the agent and disconnect from all MT5 accounts

Automatic Features:

  • MT5 Auto-Start — Launches MetaTrader 5 minimized on agent startup if not already running
  • MT5 Crash Monitoring — Checks every 30 seconds if MT5 is running and automatically restarts it if the process has stopped
  • Update Checking — Checks for new agent versions on startup and when manually triggered. Displays release notes and download links when updates are available
  • Windows Startup — Enabled by default, starts the agent automatically when you log into Windows
  • Secure Storage — API key is encrypted using Fernet encryption and stored in %APPDATA%\Archomata\config.json

All logs are kept in memory and can be viewed at any time through the Logs window. The export feature creates a timestamped text file in your Downloads folder, useful for troubleshooting or sharing with support. Updates must be installed manually by downloading and running the new installer.

Troubleshooting Connections

Agent shows as offline in dashboard: Right-click the tray icon and select Logs to view recent activity. Verify that the agent can reach the API server. The agent sends heartbeats every few seconds—if the dashboard doesn't receive a heartbeat within 2 minutes, the agent appears as offline. Check your internet connection and firewall settings.

Account fails to connect: Ensure that MetaTrader 5 is running and logged into your broker account. The agent requires MT5 to be open and authenticated. The agent automatically starts MT5 minimized on startup and monitors the process every 30 seconds—if MT5 crashes or is closed, it will be automatically restarted. In the agent's Settings window, check the MT5 status indicator. If it shows "Not authenticated," open MT5 and log in. The agent will detect the connection automatically.

Cannot find tray icon: Look for the gold "A" icon in the system tray (bottom-right of your taskbar). If you don't see it, click the up arrow (^) to show hidden icons. The agent starts minimized with no window—all interaction happens through the tray icon.

Commands stay in "pending" status: This means the agent hasn't picked up the command yet. Check the Logs window for errors. Verify that the agent is polling the API by looking for regular "polling" log entries. Commands are processed in order, so a stuck command may block others—check the Commands section in the dashboard for details.

Update check fails: The update checker requires internet access to query /api/version. If the check fails, you can still download new versions manually from the Archomata platform. The agent will continue working with the current version until you update.

Agent won't start on Windows login: Check the Windows startup setting in the agent's Settings window. If enabled but not working, verify that the registry entry exists by opening Task Manager → Startup tab and looking for "ArchomataAgent." You can also manually add the agent to startup by placing a shortcut in %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup.

Back to top

API Reference

Authentication

The Archomata API uses two separate authentication mechanisms. User-facing endpoints require a JWT Bearer token obtained by signing in via POST /api/auth/login. Access tokens are short-lived (15 minutes) and must be refreshed using the httpOnly refresh token cookie, which is automatically set during login and has a 7-day lifetime. Include the access token in the Authorization: Bearer <token> header for all /api/* requests.

MT5 Agent bridge endpoints (/poll, /state, /heartbeat, /commands/{id}/result) use API key authentication via the X-API-Key header. The API key is hashed with bcrypt and stored alongside the agent record in the database. These two auth systems are completely separate -- user tokens cannot access bridge routes, and API keys cannot access user routes.

Endpoints Overview

The API is organized into several route groups. All CRUD endpoints under /api/* require a valid user JWT and are filtered by the user's organization. List endpoints support pagination via limit and offset query parameters.

  • /api/eas -- Expert Advisor CRUD (create, list, read, update, delete)
  • /api/backtests -- Backtest result management
  • /api/accounts -- Broker account management, equity history via /api/accounts/{id}/equity-history
  • /api/agents -- MT5 Agent registration and status
  • /api/deployments -- EA deployment lifecycle
  • /api/positions -- Open and closed position tracking
  • /api/commands -- Command queue management, status polling, retry
  • /api/strategies -- Portfolio strategy CRUD, EA assignments, rules, publishing
  • /api/runs -- AI agent run tracking

Health checks are available at /healthz, which returns the API status, database connectivity, and connection pool statistics. This endpoint requires no authentication and is suitable for uptime monitoring.

Rate Limits & Errors

The API enforces rate limits on authentication endpoints and bridge routes using an in-memory sliding window limiter. Login attempts are rate-limited to prevent brute-force attacks, and bridge polling routes are rate-limited per API key to prevent excessive load. Requests that exceed the rate limit receive a 429 Too Many Requests response with a Retry-After header indicating when the client can retry.

All API errors follow a consistent JSON format with a detail field containing a human-readable error message. Common HTTP status codes include 400 (validation error or bad request), 401 (missing or invalid authentication), 403 (insufficient permissions), 404 (resource not found), and 409 (conflict, such as duplicate entries). The API also enforces request timeouts -- long-running requests are terminated to prevent resource exhaustion.

Failed commands in the command queue can be retried up to 3 times using POST /api/commands/{id}/retry. Commands that remain in "pending" status beyond a timeout period are automatically marked as expired. Expired commands can also be retried if the underlying issue has been resolved.

Back to top