strategy-backtesting

strategy-backtesting is a skill for Claude Code from Miha21222/tradingview-mcp. It costs 72 tokens per session (1,394 once invoked), scanned A, original, MIT.

A backtesting tool for rule-based forex strategies using historical price bars. Backtesting means applying trading rules to past data to measure how they would have performed.

In plain words
What is it for?
Use it to test built-in or declarative strategies, compare settings and timeframes, inspect results such as win rate and expectancy, and render recent trades as chart images.
Why use it?
It applies consistent assumptions for position size, currency conversion, spread, and trade fills, so results are easier to compare than estimates based on charts alone.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the tradingview-mcp plugin — 10 skills, 1 MCP server shipped together

Good fit Use it to test built-in or declarative strategies, compare settings and timeframes, inspect results such as win rate and expectancy, and render recent trades as chart images.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/miha21222/tradingview-mcp/strategy-backtesting
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Miha21222/tradingview-mcp --skill strategy-backtesting
Clone the repo
git clone --depth 1 https://github.com/Miha21222/tradingview-mcp

Made for: Claude Code.

Or install tradingview-mcp, the plugin that ships this one along with the rest of its 10 skills, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for strategy-backtesting

README.md
[![agentmods](https://agentmods.dev/badge/skills/miha21222/tradingview-mcp/strategy-backtesting.svg)](https://agentmods.dev/skills/miha21222/tradingview-mcp/strategy-backtesting)
Your own site
<a href="https://agentmods.dev/skills/miha21222/tradingview-mcp/strategy-backtesting"><img src="https://agentmods.dev/badge/skills/miha21222/tradingview-mcp/strategy-backtesting.svg" alt="Measured on agentmods" height="20"></a>
Per session 72 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,394 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00072 $0.01394
Opus 5 $0.00036 $0.00697
Sonnet 5 $0.00014 $0.00279
Haiku 4.5 $0.00007 $0.00139

Measured 7d ago against content hash 4ba1547c9521, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

strategy-backtesting scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/strategy-backtesting/SKILL.md · 102 lines

How it starts

The opening of the file, as written. The whole thing — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Strategy backtesting

Run vetted strategies over historical bars with account-correct math: pip sizes (incl. JPY), risk-based position sizing from the actual stop distance, pip-scaled spread, and explicit fill semantics. Strategies are declarative YAML or built-in only — never run user/LLM Python code (blocked by the hard rules).

When to use

  • You want a statistical read (win rate, expectancy, profit factor, R distribution) on a rule-based idea, not a gut feeling.
  • You need to compare a strategy across parameters or timeframes.
  • You have a declarative spec and want to run it over fresh data.

Tools

  • tv_backtest_run — run a built-in strategy (sma_cross, breakout, smc_h4_m15) with full currency/spread/fill controls.
  • tv_backtest_render_trades — same backtest, but renders the most recent N closed trades to PNGs (entry line, SL red, TP green, exit labeled with R, band over the trade's lifetime) for a visual sanity check of the fills; needs headless Chromium. extra_markup_json layers custom drawings (killzones, boxes, text, markers, hex colors — full tv_chart_render schema) onto every image.
  • Fully custom screenshots: tv_backtest_run gives every trade's entry/exit times + prices + sl/tp; feed them to tv_chart_render with end_time (window any historical trade) and your own markup_json. A user's preferred style (colors, what to draw, sizes) belongs in a skill file so the agent applies it every time — that's the customization path, no code changes.
  • tv_strategy_list — list declarative YAML strategies in TV_STRATEGY_DIR.
  • tv_strategy_run — run a declarative YAML strategy (same engine as backtest).
  • tv_data_get_bars — fetch the bars you intend to test.

Honest interpretation checklist

  1. Fill model: default is next-bar-open (trade_on_close=false). Trades that signal on a bar fill at the next open — this is the conservative real-world default. trade_on_close=true fills at the signal bar close (optimistic; only if your execution genuinely works that way).
  2. Look-ahead: ensure the strategy only used information available at the signal bar (the built-ins shift their indicators by one bar). Never test a rule that references the outcome bar.
  3. Sample size: per setup, fewer than ~30 trades is not evidence. Report # Trades with every conclusion; a 100% win rate on 4 trades is noise.
  4. Currency: account_currency and quote_to_account_rate are explicit. When the quote (e.g. JPY) differs from the account currency, supply the rate — the tool refuses to guess.
  5. Spread: spread_pips is modeled as a relative rate exact at a reference price; it is applied once at entry (backtesting.py semantics). Treat reported P&L as pre-tolerance, not a broker quote.
  6. R: each trade's r = pnl / (size * |entry - sl|); a stop-hit is ~-1.0R. Judge a strategy by expectancy in R, not by total P&L (account size is arbitrary).

Read the full file on GitHub · 102 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 102 lines · 72 tokens per session scan A 4ba1547c9521

Subscribe to this mod's changes

strategy-backtesting is a skill published in the GitHub repository Miha21222/tradingview-mcp (0 stars, last pushed 12d ago), licensed MIT. It adds 72 tokens to every session and 1,394 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories