Skip to main content
Glama

backtest_condition

Read-onlyIdempotent

What happened AFTER a condition in the past, on one symbol and timeframe — "how did BTC do after RSI dropped below 30 on 4h", "is a golden cross on ETH daily actually bullish", "what usually follows a −5% day on SOL". Runs an event study over the whole stored tape (up to 1000 candles: ~41 days on 1h, ~166 days on 4h, ~3 years on 1d): occurrences, average / median forward return, win rate, average best and worst excursion per horizon, the unconditional baseline over the same tape and the EDGE the condition adds over it, the last five episodes, and whether the condition is active on the latest bar. Same condition vocabulary as screen_symbols. Quote the edge and the sample size together — a 3-sample stat is an anecdote.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair, e.g. BTCUSDT (a bare "BTC" is read as its USDT perpetual)
horizonsNoBars ahead to measure returns over (≤ 4). Default per interval ≈ 4h / 1d / 3d: 1h → [4, 24, 72], 4h → [6, 18, 42], 1d → [1, 3, 7].
intervalNoCandle timeframe4h
conditionsYesUp to 3 conditions, AND-ed. Examples: RSI oversold = {"metric":"rsi","op":"lt","value":30}; above the 200 EMA = {"metric":"priceVsEma","op":"gt","value":0,"period":200}; golden cross = {"metric":"emaSpread","op":"crossAbove","value":0,"period":50,"period2":200}; MACD bullish cross = {"metric":"macdHistogram","op":"crossAbove","value":0}; dumped 5% in a day = {"metric":"changePct","op":"lt","value":-5,"period":24}.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
toNo
tipNoRare: one sentence about a TraderSpy feature this connector cannot do, with the page it leads to
urlNoThe coin's chart on traderspy.app
barsNoCandles the study ran on (the whole stored tape)
fromNo
recentNoNewest episodes first: { openTime, barsAgo, price, returnsPct { "<bars>": pct } }
symbolNo
horizonsNoPer look-ahead: { bars, samples, avgReturnPct, medianReturnPct, winRatePct, avgMaxUpPct, avgMaxDownPct, bestPct, worstPct, baselineAvgReturnPct, edgePct } — edge = avg − unconditional baseline
intervalNo
warningsNo
activeNowNoConditions hold on the latest closed bar
conditionsNo
occurrencesNoEpisodes — the FIRST bar of each run where the conditions held
horizonHoursNo
coverageHoursNo
currentValuesNoLatest value of every metric involved
evaluableBarsNo
lastOccurrenceNo{ openTime, barsAgo, price }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / conditions / items / properties / metric / description
      Previous value: -"Metric. Defaults in brackets. rsi(14): RSI, 0–100; stochastic(14,3): Slow stochastic %K (period, %D smoothing), 0–100; cci(20): Commodity Channel Index; mfi(14): Money Flow Index, 0–100; williamsR(14): Williams %R, −100–0; adx(14): Average Directional Index; roc(12): Rate of change in %; macdHistogram(12,26): MACD histogram (fast, slow; signal 9); atrPct(14): ATR as % of price; volumeRatio(20): Bar volume ÷ average of the previous N bars; bbPercentB(20): Position inside Bollinger (20, 2): 0 = lower band, 1 = upper band; bbWidthPct(20): Bollinger band width as % of the middle band; priceVsEma(50): % distance of close from EMA(period); > 0 = above; emaSpread(50,200): % of EMA(period) over EMA(period2); crossAbove 0 = golden cross; supertrend(10): +1 in an up-trend, −1 in a down-trend (ATR period, multiplier 3); changePct(24): % change of close over the last N bars; price: Close price"New value: +"Metric. Defaults in brackets. rsi(14): RSI, 0–100; stochastic(14,3): Stochastic %K (period; raw %K, the line TradingView draws with 14,1,3), 0–100; cci(20): Commodity Channel Index; mfi(14): Money Flow Index, 0–100; williamsR(14): Williams %R, −100–0; adx(14): Average Directional Index; roc(12): Rate of change in %; macdHistogram(12,26): MACD histogram (fast, slow; signal 9); atrPct(14): ATR as % of price; volumeRatio(20): Bar volume ÷ average of the previous N bars; bbPercentB(20): Position inside Bollinger (20, 2): 0 = lower band, 1 = upper band; bbWidthPct(20): Bollinger band width as % of the middle band; priceVsEma(50): % distance of close from EMA(period); > 0 = above; emaSpread(50,200): % of EMA(period) over EMA(period2); crossAbove 0 = golden cross; supertrend(10): +1 in an up-trend, −1 in a down-trend (ATR period, multiplier 3); changePct(24): % change of close over the last N bars; price: Close price"
  2. Changed3 schema fields changed
    • changedOutput schema / additionalProperties
      Previous value: -falseNew value: +true
    • addedOutput schema / properties / tip
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "properties": {
      +        "links": {
      +          "anyOf": [
      +            {
      +              "items": {
      +                "additionalProperties": true,
      +                "properties": {
      +                  "label": {
      +                    "type": [
      +                      "string",
      +                      "null"
      +                    ]
      +                  },
      +                  "url": {
      +                    "type": [
      +                      "string",
      +                      "null"
      +                    ]
      +                  }
      +                },
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ]
      +        },
      +        "text": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        }
      +      },
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Rare: one sentence about a TraderSpy feature this connector cannot do, with the page it leads to"
      +}
    • addedOutput schema / properties / url
      Added value: +{
      +  "description": "The coin's chart on traderspy.app",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
  3. Added

TDQS

A4.4/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true/idempotent, so safety is covered; the description goes well beyond by disclosing the data tape limit (up to 1000 candles, with the concrete ~41d/166d/3y implication per interval) and the statistical caveat that a 3-sample stat is an anecdote. That is exactly the operational context an agent needs before quoting results.

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

Conciseness4/5

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

Opening sentence is strongly front-loaded with purpose and examples, and the closing instruction to quote edge alongside sample size is high-value. It is a dense single block rather than a leaky one, though the enumeration of return statistics overlaps with the output schema and could be trimmed.

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 4-parameter analytics tool with a full output schema and read-only annotations, the definition still covers the things structured fields cannot convey: the stored tape length per interval, the AND-ed multi-condition model, metrics in their own units, and the sample-size caveat. Nothing needed to invoke or interpret it correctly is missing.

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

Parameters3/5

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

Schema description coverage is 100% — periods, defaults, enum semantics and the condition examples are all already documented in the schema. The description adds only the cross-reference that the condition vocabulary matches screen_symbols, which is mildly useful but does not deepen parameter meaning, so the baseline 3 applies.

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 states a specific verb+resource (event-study backtest of a condition on one symbol/timeframe) and immediately anchors it with three concrete example questions. It also positions itself against the sibling screen_symbols by noting the shared condition vocabulary, so an agent can tell the two apart without opening either schema.

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

Usage Guidelines4/5

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

The 'what happened AFTER a condition in the past' framing plus the three example questions make the intended use case unambiguous. However, it never states when to avoid this tool (e.g. conditions with too few occurrences) or explicitly names screen_symbols as the alternative for the forward-looking counterpart, so the guidance is clear but not exhaustive.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.