What I'm about to reveal will completely blow your mind.
I recently used Claude Fable 5 to test twelve of the most famous trading strategies of all time against $BTC.
What I found was that only one actually beat just buying and holding.
Then, I took things a step further, I ran the one winning strategy on stocks, and the results were shocking.
This article walks you through the exact process:
- How to use Claude to backtest any trading strategy
- How to import strategies into TradingView so you can see the real historical data
- How to prompt Claude to generate, analyse, and refine strategies that outperform 99% of traders
- Bonus: How to actually execute & automate trades with AI
This article is pure sauce, and I probably should've paywalled it. This is quite literally how you can copy any profitable trader and automate their entire strategy.
At the very end of this article, I've created a completely free PDF starter resource that you can drop into Claude to start automating your trading - be sure to stick around until the end so I can send it to you directly.
Let's get right into things.

Twelve trading strategies results
Backtesting Trading Strategies 101 (crash course)
Before you can trust any trading strategy, you need to know how it would have actually performed. Not in theory, but with real historical data, entries, and exits.
For this, I like to use Fable 5 in VSCode (feel free to use other models/harnesses as well).
As an example, let's backtest the famous RSI mean-reversion strategy:
Starter Prompt
1Take the classic RSI mean-reversion strategy2and turn it into a fully objective rule set for3on the daily timeframe.45Give me: exact entry rule, exact exit rule,6stop logic, and position sizing.78No discretion - every rule must be computable. + Ask before edits
What we are trying to do here is extract a set of rules that we can then turn into Pine Script code, and backtest on TradingView.
The exact rules you extract can vary, but in general, I'm looking for:
- Entry triggers
- Stop loss triggers
- Exit plan
- Position sizing rules

VSCode output rules \example\
The good thing about Fable is that it's extremely in-depth, and it's why it's my preferred model for complex workflows like this.
Pine Script + TradingView
Once you have your set of trading rules, we're going to convert them into Pine Script so we can import them into TradingView for proper backtesting.
Think of Pine Script as the "language" that translates plain English into the code TradingView needs to pick up what we want to import.
Prompt
1Now write this as TradingView Pine Script v6 strategy code.23Include 0.1% commission per side, fills on next bar open,45$100,000 starting capital. Ready to paste into the Pine Editor.
Your output should look something like this:

Pine Script output
Go ahead and copy this entire code block, and open the Pine Editor in TradingView to create a new script:

How to create a new TradingView script
Paste the entire code block and click "Add To Chart."

Pasting the strategy from Claude
Note: If you run into errors, just take a screenshot, paste it back into your AI model, and ask it for a fix.
Also, note that you may encounter errors if you use incorrect time frames. I like to tell my AI: "Write the code so I can test this across any timeframe."
Results
Once you've successfully added the strategy to your TradingView, you'll see a pop-up at the bottom of your screen that displays all the backtested data and lets you switch through the timeframes, portfolio size, and other variables for the strategy you imported.

Results
For this particular mean-reversion strategy, it would've been up +$5,251 based on all historical data.

Daily time-frame
As you swap through the timeframes, you'll see varying results.
For example, on the 4H chart, this strategy actually would've been in a deep drawdown:

4H timeframe
But this actually isn't the real sauce; if you simply import a random strategy, most of the time, they will fail.
What I'm about to show you next is how you build a real, sustainable, profitable trading strategy.
Refining & Building Winning Strategies
In TradingView, in your pop-up window, you can download a CSV file with all the backtested data from your strategy, including the list of trades, entry/exit prices, etc.
Go ahead and download that file - we'll need it in a second.

List of trades (download CSV)
Then, go back into Claude and ask it to actually explain how to improve the strategy.

Import the CSV + prompt for an improvement plan
Why this is so powerful
Let me take a second to explain why this is so powerful, because I think many people will miss the real alpha if I don't.
Let's say you follow a trader or have picked up a rough trading framework, but you're unsure how to execute it.
With AI and Claude, you can now take that mental framework, everything you know about that trading style, and create a real set of parameters using Pine Script to help you execute.
Instead of guessing whether the strategy works, you can import it into any trading pair, timeframe, and portfolio size to see how it would have performed AND refine it in real-time.
I wish this had existed when I was first learning about markets and trading!
Some notes on building winning strategies
- The strategy you use may vary depending on market conditions (i.e., in trending markets, a momentum strategy is probably best)
- Test your strategies on multiple pairs and asset classes. A momentum strategy may absolutely crush it on equities, but completely suck on something like crypto. Don't give up if your strategy fails on one pair.
- In your Claude projects, you can attach .MD files to explain your exact trading parameters for extra context
- Don't be afraid to go back and forth with Claude. AI is exceptionally good now, and it can fix all your coding errors.
Keep in mind you can also toggle orders on/off on your TradingView charts to visualise where the actual entry/exit points are:

Actually viewing orders on the chart
Bonus: How to Actually Execute & Automate Trades with AI
For those of you who want to take things a step further and fully automate your trading.
The tool you need: a trading MCP
To let Claude (or any AI agent) actually place trades, you need to connect it to your exchange through an MCP server.
If you're using a centralized exchange like Bybit, you'd connect to its MCP server.
What you actually need to set this up:
- An AI agent or harness: Imo, Claude Code is the natural fit here since it can make tool calls directly within a coding environment.
- The exchange's MCP server. Each exchange has its own, so you connect to whichever one you're trading on.
- An API key. You'll need to generate one from your exchange and give it to your agent so it has permission to execute trades on your behalf.
Once that's connected, the entire loop closes: Claude backtests a strategy, you validate the results, and then the same system can watch the market and execute automatically whenever the strategy's conditions are met.

Full automation
A caveat - you don't have to go fully automated.
A middle ground that I've found works well: Have Claude flag you every time there's a trade opportunity that matches your strategy's parameters, and you make the final call on execution.
You can even set up a more advanced workflow where a Hermes agent constantly monitors your portfolio/TradingView and notifies you via Discord, WhatsApp, Telegram, etc.
Final Thoughts
As promised, I created a free PDF guide based on everything in today's guide. You can drop it straight into Claude, and it will help you execute everything I've discussed here.

Full Guide
To access the asset, head to https://milesdeutscher.com.au/ytw59m so I can share it with you directly (100% free, no strings attached).
I hope you found this article valuable.
If you did this valuable, be sure to follow me @milesdeutscher. I share content on AI, how to use AI in markets, and related topics!
For deeper AI insights, feel free to follow me over on @aiedge_.
Thanks for reading.💙





