MTContext Docs
Tool Reference

Coaching

5 tools in this category.

Overview

Coaching includes 5 tools for this workflow area.

Available tools: backtest_strategy, explain_trade, get_fibonacci_levels, get_news, get_sentiment.

Use the parameter tables and examples below as the canonical request contract.

backtest_strategy

Runs a rule-based strategy backtest over historical bars fetched from the EA, evaluated against real server-computed indicator series (sma, ema, rsi, atr, macd, stddev, bollinger, adx, cci, stochastic) aligned index-for-index with the bars — not a hard-coded context. strategy.entry/strategy.exit accept either the legacy flat shorthand (rsi_above, rsi_below, price_above_ema, price_below_ema, macd_cross_above_zero, macd_cross_below_zero) or a condition tree ({all:[...]}, {any:[...]}, {not:<node>}, leaves {left, op, right} with op in gt|gte|lt|lte|cross_above|cross_below). Price fields open/high/low/close are addressable as pseudo-indicators. adx (params: {period}, default 14) is a composite indicator with fields adx (default), plus_di, minus_di, computed via Wilder's method — it warms up roughly 2*period bars in (DI needs period bars, then adx itself needs another period DX values), later than every other indicator here, so a short bar window can leave it null for the whole range (zero entries from that leaf, never a false pass/fail). cci (params: {period}, default 14) is a single-series indicator, no field. stochastic (params: {k_period, d_period, slowing}, defaults 5/3/3) is a composite indicator with fields k (default), d, matching get_indicator's STOCHASTIC parameter names and defaults. Bounded: tree depth <= 4 (per entry/exit tree), <= 32 nodes and <= 8 distinct indicator series (pooled across the whole strategy). Maximum 5000 bars — larger requests return BACKTEST_TOO_LARGE before any dispatch. Unknown condition keys/indicators or oversized trees return BAD_PARAMS before any dispatch. Times out after 30 seconds and returns BACKTEST_TIMEOUT. direction (long|short|both, default long) and cost_points (default 0, a raw price-unit deduction applied once per round trip) are echoed in the response's model block along with risk_per_trade_pct. Optional stop_loss: \{type:"atr_multiple", value, period?\} (stop = entry ± ATR(period, default 14) * value) or \{type:"points", value\} (stop = entry ± value, a raw price-unit distance like cost_points). When set, the stop is checked intrabar against bar.high/bar.low (conservative gap-through fill), takes priority over a same-bar exit-condition signal, and position sizing becomes stop-distance-aware: risk_per_trade_pct% of balance is the constant dollar risk per trade regardless of stop width, so backtests with different stop widths are genuinely risk-comparable. Without stop_loss, sizing is the legacy fixed-leverage-proxy formula (not stop-distance-aware) — results with and without stop_loss are NOT directly comparable to each other. An atr_multiple stop counts toward the 8-distinct-series cap and returns BAD_PARAMS if the strategy's own conditions already use all 8. Only fixed-distance/ATR-multiple stops are supported — structure-based (swing-level) stops are out of scope. Requires the analytics capability (Enterprise+ tier).

Parameters

NameTypeRequiredDefaultDescription
symbolstringYes
timeframestringYes(one of: M1, M5, M15, M30, H1, H4, D1, W1, MN1)
barsintegerYes
strategyobjectYes
initial_balancenumberNo10000
risk_per_trade_pctnumberNo1
directionstringNo"long"(one of: long, short, both)
cost_pointsnumberNo0
stop_lossanyNo

Example Request

{
  "tool": "backtest_strategy",
  "arguments": {
    "symbol": "EURUSD",
    "timeframe": "M1",
    "bars": 100,
    "strategy": {}
  }
}

Usage Notes

  • Start with a smaller count/bars value while iterating, then increase once the workflow is stable.
  • Use one timeframe for quick checks and multiple timeframes only when you need cross-timeframe analysis.

explain_trade

Explains a trade: what conditions existed at entry, the risk/reward ratio, SL/ATR ratio, and whether it aligns with common strategies. Works for both open positions and closed trade history. Returns POSITION_NOT_FOUND if ticket not found. Requires the analytics capability (Team+ tier).

Parameters

NameTypeRequiredDefaultDescription
ticketintegerYes
timeframestringNo"H1"(one of: M1, M5, M15, M30, H1, H4, D1, W1, MN1)

Example Request

{
  "tool": "explain_trade",
  "arguments": {
    "ticket": 123456,
    "timeframe": "M1"
  }
}

Usage Notes

  • Use one timeframe for quick checks and multiple timeframes only when you need cross-timeframe analysis.

get_fibonacci_levels

Computes Fibonacci retracement and extension levels from swing high and low price points. Pure server-side computation — no EA dispatch required. Available at Free+ tier.

Parameters

NameTypeRequiredDefaultDescription
swing_highnumberYes
swing_lownumberYes
directionstringNo"UP"(one of: UP, DOWN)

Example Request

{
  "tool": "get_fibonacci_levels",
  "arguments": {
    "swing_high": 1,
    "swing_low": 1
  }
}

get_news

Returns recent forex/financial news articles from NewsAPI.org. Requires NEWS_API_KEY environment variable — returns NEWS_NOT_CONFIGURED if not set. Returns NEWS_UNAVAILABLE if the feed is unreachable. Results cached 5 minutes. Optionally filter to news relevant to a symbol's currencies (symbol) or an explicit currency list (currencies) within a lookback window (hours, default 24, max 168) — hours only takes effect when a relevance filter is present; with no symbol/currencies, the unfiltered feed (and hours' absence of effect on it) is byte-for-byte unchanged from before filtering existed. When filtering, more articles than limit are fetched from the feed so relevance/window filtering doesn't undershoot the requested limit. Relevance matching is a synchronous keyword-lexicon pass — no LLM call is made in the request path. An unresolvable symbol returns UNKNOWN_SYMBOL rather than silently falling back to unfiltered results. Requires the analytics capability (Team+ tier).

Parameters

NameTypeRequiredDefaultDescription
querystringNo
symbolstringNo
currenciesarrayNo
hoursintegerNo24
limitintegerNo10

Example Request

{
  "tool": "get_news",
  "arguments": {}
}

get_sentiment

Returns retail trader positioning sentiment for a symbol from Myfxbook Community Outlook (free, no key required). Includes long/short percentages and a contrarian signal (when retail is >70% long, signal is SHORT). Returns SENTIMENT_UNAVAILABLE if the feed is unreachable. Results cached 15 minutes. Requires the analytics capability (Team+ tier).

Parameters

NameTypeRequiredDefaultDescription
symbolstringYes

Example Request

{
  "tool": "get_sentiment",
  "arguments": {
    "symbol": "EURUSD"
  }
}

On this page