Build and test a trading strategy by talking to Claude Code: connect it to your TradingView chart, have it write and backtest the strategy, and only forward-test what passes clear rules: AI agent prompt

Writing a trading strategy in Pine Script and reading the backtest used to take coding skills. Davidd Tech shared on X (Oct 23, 2026) a step-by-step setup that drew 130+ bookmarks: install Claude Code, connect it to TradingView through the open-source TradingView-Unified-MCP project, log into TradingView and open a saved chart, then ask Claude to write a Pine Script v6 strategy (his example: BTCUSDT on the 4-hour chart, Supertrend for direction, ATR stop loss and take profit, fees and slippage on), compile it, attach it to the chart and read back the Strategy Tester numbers. His pass rules before a forward test: over 100 trades, drawdown under 20%, profit factor above 1.1 and beating buy-and-hold; otherwise tweak the settings and rerun, then paper-trade for about 3 months with no money before going live. This prompt keeps the agent in test-only mode.

Curated by AgentPlaybook Real Estate · How we make and check prompts

FinanceInvesting & Tradingintermediate

The prompt

You are connected to my open TradingView chart through an MCP server. You are in TEST-ONLY mode: never place, send or connect to real orders or a broker. Market and timeframe: [e.g. BTCUSDT, 4 hour]. Strategy idea: [e.g. Supertrend for direction, ATR-based stop loss and take profit, no trailing stop]. Do this: 1) Write a Pine Script v6 strategy for that idea with fees of [e.g. 0.1%] and slippage of [e.g. 2 ticks] turned on, and explain each rule in plain words. 2) Compile it, attach it to the chart and read back the Strategy Tester report: net profit, max drawdown, profit factor, number of trades, and buy-and-hold return. 3) Grade it against my pass rules: at least [100] trades, max drawdown under [20%], profit factor above [1.1], and beats buy-and-hold. 4) If it fails, change at most two settings at a time (e.g. Supertrend length, ATR multiplier), rerun, and show a table of every attempt so I can see if we're just curve-fitting. Stop after [5] attempts. 5) If it passes, tell me the risks you see and remind me to paper-trade it for [3 months] before using real money. This is not financial advice.
Open in ChatGPT Open in Claude Perplexity Download as agent skill (SKILL.md)

How to use it

  1. Copy the prompt above.
  2. Replace every [bracket] with your own details (or fill in the blanks on AgentPlaybook Real Estate, which remembers your answers for the next prompt).
  3. Paste it into Claude Code, TradingView, TradingView-Unified-MCP and review the answer before you use it.

Works with: Claude Code, TradingView, TradingView-Unified-MCP, Pine Script

Real-world example: x.com/DaviddDotTech/status/2113677833566585180

Before you use it: what to check

Already built into this prompt

Check yourself

Using an AI agent? Download this prompt as a SKILL.md agent skill with these checks built in, or get the .zip for Claude.ai. How to install skills.

Share:Post on XLinkedInFacebookRedditWhatsApp
</> Embed this prompt on your site

Paste this HTML into your blog or website. It's a plain card with no tracking scripts that links back to this prompt.

Want to make this prompt even better? Grade it with the free prompt grader or build your own with the AI prompt generator.

Get the free Solo Founder Stack pack

32 copy-paste agent prompts (PDF) plus 5 new prompts every week.

Get it free

More Finance prompts

Let your AI assistant trade for you on Coinbase, but only inside a small separate portfolio: connect it, have it research and preview every order, and approve each trade yourselfInvesting & Trading · intermediateCategorize transactionsBookkeeping · beginner · worked exampleInvoice reconciliationReconciliation · intermediateExpense policy checkerExpenses · beginnerCash-flow check-inCash flow · beginner · worked exampleReceipt photos to bookkeeping entriesReceipt capture · beginner · worked example

See all Finance prompts →