Skip to main content
Glama

run_backtest

Run a MetaTrader strategy tester backtest headlessly from a tester.ini file, wait for completion, and retrieve the report path and logs.

Instructions

Run a Strategy Tester backtest headlessly from a tester.ini and wait for it to finish.

Requires the EA to be deployed first (compile_and_deploy / deploy_ea) and ShutdownTerminal=1 in the ini, otherwise the call runs until timeout_sec. Typically 1-30 minutes; progress notifications are sent every few seconds while waiting. If the tester reports "cannot synchronize history" (first headless start after login), the run is retried once automatically. For long runs prefer start_backtest + get_backtest. Returns run_id, report_path (resolved from Report= in the ini), latest_tester_log and journal_notes/warnings; if warnings mentions start_time_changed the tester moved FromDate because history was missing, so the report is not comparable with other runs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
waitNotrue = block until the terminal exits (needs ShutdownTerminal=1); false = launch and return a run_id for get_backtest.
configYesAbsolute path to the tester.ini file.
portableNoPass /portable so the terminal uses its install folder as data folder.
timeout_secNoGive up (and kill the terminal) after this many seconds.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv0.5.0
    • addedInput schema / properties / config / description
      Added value: +"Absolute path to the tester.ini file."
    • addedInput schema / properties / portable / description
      Added value: +"Pass /portable so the terminal uses its install folder as data folder."
    • addedInput schema / properties / timeout_sec / description
      Added value: +"Give up (and kill the terminal) after this many seconds."
    • addedInput schema / properties / wait / description
      Added value: +"true = block until the terminal exits (needs ShutdownTerminal=1); false = launch and return a run_id for get_backtest."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "title": "run_backtestDictOutput",
      +  "type": "object"
      +}
  2. First observedv0.4.1

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide no behavioral hints (all false), so the description carries the full burden. It discloses expected duration (1-30 minutes), progress notifications, automatic retry on history sync error, output fields, and the `start_time_changed` warning. This goes well beyond minimal requirements and gives the agent a realistic model of side effects and failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Every sentence earns its place: purpose, prerequisites, timing, retry logic, alternative, and return value caveats. Instructions are front-loaded and the structure is logical, with no filler or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with prerequisites, retries, and specific return semantics, the description is thorough. It covers deployment requirements, blocking behavior, timeout, return fields, and the warning about report comparability. The output schema exists, so return details need not be repeated. Nothing critical is missing for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% so parameters are already well-documented. The description adds value by clarifying the interaction between `wait` and `ShutdownTerminal=1`, the timeout fallback, and the resolution of `report_path` from the ini. This exceeds the baseline of 3 for fully covered schemas, but is not essential enough to reach 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise verb+resource: 'Run a Strategy Tester backtest headlessly from a tester.ini and wait for it to finish.' It clearly distinguishes itself from siblings like `start_backtest` and `get_backtest` by emphasizing the blocking behavior and explicitly naming the alternative for long runs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states prerequisites (EA must be deployed, `ShutdownTerminal=1` required) and gives a conditional behavior (otherwise runs until `timeout_sec`). It also provides an alternative: 'For long runs prefer `start_backtest` + `get_backtest`', which is a clear when-not-to-use instruction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.