/tradingview-mcp:strategy-backtestingfrom TradingView MCP
Backtest built-in and declarative strategies with correct forex math (R sizing, pip/JPY, spread, fill model). Use when validating a rule-based idea on historical data, sizing a strategy, or interpreting backtest stats. Triggers: backtest, run the strategy, validate this idea, what's the win rate, walk-forward.
Ships in TradingView MCP. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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).
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.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.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).# Trades with every conclusion; a 100% win rate on 4 trades is noise.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.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.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).Habits distilled from the honest minority of public "AI trading" setups — the ones that showed their strategy losing. Run them before calling anything good:
tv_desktop_read_strategy returns it as
buy_hold_return. A strategy below buy-and-hold is not "profitable", whatever
the net profit says.spread_pips=0 /
zero commission, once with the user's real spread + commission. Report both;
the gap is the strategy's cost sensitivity. If the realistic run flips the
sign, say that first.Quote returns as expectancy in R and profit factor; never headline a total P&L percentage (in-sample single-asset numbers like "3600%" are the standard sign of an overfit loop).
tv_data_get_bars(symbol, timeframe, count) (or let the tool).tv_backtest_run(strategy, symbol, timeframe, count, spread_pips, cash, ...).summary (win rate, profit factor, expectancy, max drawdown) and the capped
recent trades (each with direction, size, units, R, session).
3b. Eyeball the fills: tv_backtest_render_trades(strategy, symbol, ..., max_renders)
renders each recent trade on the actual bars — check the entry sits where the rule
says, the SL/TP bracket looks right, and a -1R exit actually tags the SL line.sma_cross); a strategy is only "better" with
enough trades and a spread/commission-realistic expectancy above the baseline.tv_strategy_list) and re-run via
tv_strategy_run instead of repeating parameters.H4 bias (BOS/CHoCH on resampled bars, confirmed only at the breaking H4 close) +
M15 FVG retrace entry, SL at the far gap edge, TP at rr. Run it on M15 bars
(the tool rejects H4 and slower). Params: swing_length (H4 structure),
rr, risk_amount, expiry_bars (zone lifetime in bars), use_choch
(bias flips on CHoCH too), min_stop_frac (skip micro-stops). It is a
mechanical simplification of the owner's H4→M15 scheme — no killzone window,
no liquidity-sweep precondition yet — so treat raw results as a harness
baseline, not a verdict on the discretionary setup.
name: my_breakout
description: breakout, wider RR
strategy: breakout # must be a vetted built-in
params: # class-attribute params of that strategy
lookback: 25
rr: 3.0
risk_amount: 150
name and symbol are managed by the tool — do not set them in params.
references/walk-forward.md — in-sample/out-of-sample discipline.risk-sizing for position-size decisions and strategy-review for the
owner's 5-block audit of the strategy definition itself.What SKILL.md sets; muted values are Claude Code's defaults
11 skills in this plugin
/chart-markupRender candlestick charts with SMC/ICT markup overlays to PNG files. Use when you have a scan result or a set of levels/timestamps and want a visual for review or for attaching to a note. Triggers: render the chart, draw the FVG, make a PNG of this setup, visualize the scan, markup chart./journal-syncLoad a trade journal of any shape (FX Replay export, your own session CSV, a broker export) into one normalized record schema, and import FX Replay exports into a Notion trade journal using the documented mapping. Use when reading a journal, computing journal stats, ingesting a backtest/analytics export, de-duplicating re-imports, or syncing trades. Triggers: load my journal, read my trades, journal stats, import FX Replay, sync journal, push trades to Notion, map the CSV./Other plugins' skills for the same job
npx claudepluginhub miha21222/tradingview-mcp --plugin tradingview-mcp