Educational content only, not financial advice. Trading carries a real risk of loss.
A practical, no-code path from idea to a working trading bot: what a bot can and cannot do, how to connect Claude to TradingView with an MCP bridge, five rules every strategy needs, a simplified turtle breakout as the worked example, how to check trades by hand, how to read a backtest honestly, and how to switch the bot on as alerts you still approve yourself.
Reading map
- Part I — What a bot is: what an AI trading bot does, the difference between fully and semi-automatic, and what no bot can do (sections 1 and 2).
- Part II — The setup: TradingView Desktop, the Claude desktop app and the free MCP bridge between them, with a connection test (sections 3 to 5).
- Part III — The strategy: the five rules every bot needs and the simplified turtle breakout used as the example (sections 6 and 7).
- Part IV — Build, check, backtest, switch on: the build prompt, checking trades by hand, reading the backtest and creating alerts (sections 8 to 12).
- Part V — Oversight: four rules that keep you in control (section 13), then a comparison table, a final perspective, a quick reference and a FAQ.
Why This Matters
Building a trading bot used to mean learning a programming language. Now you can describe your rules in plain English and an AI writes the code, adds it to your chart and fixes its own errors. In the worked example below, Claude produced a strategy whose backtest showed a 729% profit in a few minutes.
That speed is exactly the risk. The same backtest, compared with simply holding Bitcoin, lost by a wide margin, and the drawdown figure everyone looks at only counted closed trades. Writing the bot is now the easy part. Checking it, reading its results honestly and staying in control is the real work, and that is what most of this guide is about.
The AI writes the code in minutes. The judgment is still yours.
Part I — What a Bot Is
1. A program that follows rules
A trading bot is a program that executes clear trading rules on its own. It watches the market, finds buy and sell signals and can place orders. Its biggest advantage over a human is consistency: the same signal always triggers the same action, with no fear, greed or fear of missing out.
An AI trading bot is one that is built and tested with an AI model, here Claude. Bots can run in two modes:
- Fully automatic: orders go straight to the broker, day and night.
- Semi-automatic: the bot sends you a signal and you decide whether to buy or sell.
This guide stays semi-automatic on purpose. For anyone new to bots, approving each trade is the most important safety net you have.

2. What no bot can do
A bot can watch many markets around the clock without getting tired. What it cannot do matters more:
- It cannot predict the future. Nothing can, with certainty.
- It cannot turn a bad strategy into a good one. It only executes what you give it, faster.
- It cannot take responsibility. Every trade it makes is yours.
Keep these three limits in mind whenever a result looks too good.
Part II — The Setup
3. TradingView Desktop and the right plan
You need three things. The first is the TradingView desktop app. This workflow does not work in the browser or on a phone, because the bridge talks to the desktop application. You also need a TradingView plan that includes technical alerts, which means Essential or higher, because the bot’s signals are delivered as alerts.
4. The Claude desktop app and the MCP bridge
The second is the Claude desktop app. The free plan can run a few requests, enough to test the workflow; regular use needs a paid plan.
The third is the bridge: a free, open-source TradingView MCP server published on GitHub. MCP (Model Context Protocol) is the standard way to give Claude tools. This one lets Claude see your chart, read prices, write Pine Script and create alerts. It is a community project, not made by TradingView or Anthropic.

Two rules for the install:
- Read the repository page first. Only install software you understand and trust, whatever a tutorial says.
- Let Claude guide you. Paste a setup prompt into Claude and it walks you through every step for Windows or Mac. If anything fails, paste the exact error message back to Claude. That is usually faster than searching forums.

5. Pick a model and test the connection
Use the strongest model you can afford. In the recording, Opus 5.5 with the Extra thinking level was the recommended balance; the Max level uses roughly four times as many tokens and can drain a plan quickly.
Then test the bridge with a simple question:
Can you tell me what chart I am looking at right now in TradingView?
Tell me the chart and what the price is right now.
Claude answered with the symbol (Bitcoin, BTCUSD), the timeframe (daily) and the current price, about $78,000, all matching the chart. If it cannot see your chart, the bridge is not working yet; go back to the install steps before building anything.

Part III — The Strategy
6. Five rules every bot needs
Before any code, write down five rules. If one is vague, the bot will be vague.
| Rule | Question it answers | Example used here |
|---|---|---|
| 1. Market and timeframe | What do we trade, on which candles? | Bitcoin, daily chart |
| 2. Entry | Exactly when do we buy? | Close above the 55-day high |
| 3. Stop loss | Which price proves the trade wrong? | 2 × ATR(20) below the entry close |
| 4. Exit | When do we take the result? | Close below the 20-day low |
| 5. Position size | How much of the account is at risk? | 1% per trade |
The timeframe matters because a strategy that works on daily candles can fail completely on one-minute charts. The stop loss matters because losses are asymmetric: after a 50% loss you need a 100% gain just to get back to even, and putting everything on one trade can end the game for good.

7. The worked example: a simplified turtle breakout
The example strategy comes from the turtle traders. In 1983 Richard Dennis argued with William Eckhardt about whether trading could be taught. Dennis trained complete beginners for two weeks on a trend-following system: buy breakouts above recent highs, sell when price breaks below recent lows.
The simplified version, named “Turtle Breakout 55-20”, uses these rules:
- Entry: buy when the daily close is above the highest high of the previous 55 days.
- Stop loss: two times the 20-day Average True Range (ATR) below the signal day’s close. It is set once, at entry, and never moved.
- Exit: sell when the daily close falls below the lowest low of the previous 20 days. Because that level rises with the price, the exit trails the trend.
- Size: risk 1% of the account per trade, so the position size is 1% of the account divided by the distance to the stop.
- Simplifications: long only, closing prices only, no adding to positions.
It is an example to learn the workflow, not a recommendation.

Part IV — Build, Check, Backtest, Switch On
8. The build prompt
Give Claude the rules in clear words and ask for a Pine Script strategy, TradingView’s own language. The prompt in the recording started like this:
Build this trading bot as a TradingView Pine Script strategy,
using the latest Pine Script version, and add it to my chart.
Create it as a NEW script named "Turtle Breakout 55-20 Bot".
Do not edit or save over any of my other scripts.
Before you write any code, repeat every rule back to me in
plain English and list anything you had to assume, so I can
check it first.
BOT RULES: Simplified Turtle Breakout (55/20)
...
Two details make this prompt work. “Create it as a NEW script” and “do not edit or save over” protect the scripts you already have. And “repeat every rule back in plain English” forces a checkpoint before any code exists.

9. Read the plain-English summary before you say go
Claude replied with the chart, the direction (long only), the exact entry, stop, exit and size rules, and a list of assumptions: for example, that the stop and size appear in each alert, that the numbers (55, 20, 2 × ATR, 1%, start date) are editable in the script’s settings panel, and that a trade still open at the end of the data stays open in the backtest. It ended with: “Reply go or tell me what to change, and I’ll build it.”
Read this part properly. It is the cheapest moment to catch a misunderstanding: a wrong lookback, a stop that trails instead of staying fixed, or a size rule you did not intend.

After “go”, Claude writes the script, compiles it in TradingView, fixes its own errors and adds it to the chart. Depending on your settings it may ask you to allow certain actions; understand each one before you click. A few minutes later the chart shows buy and sell markers and the code sits in the Pine Editor.

10. Check at least three trades by hand
Never trust the first version. AI still makes mistakes, and a bot that is wrong in a subtle way can look excellent in a backtest. Pick at least three trades and check each rule against the chart:
- Entry. Did the candle close above the highest high of the previous 55 days? In the example, a green line marks that level.
- Stop. Is the stop line flat from entry to exit? In the example it is orange. A stop that moves means the bot broke the “set once” rule.
- Exit. Did the bot sell on the first close below the 20-day low (the red line)?
- Size. Is the risk 1% of the account divided by the distance to the stop?



This is also a test of you. If you cannot check a rule on the chart, you do not understand it well enough to notice when the bot gets it wrong.
11. Read the backtest honestly
A backtest runs your rules over past candles to show how the strategy would have done. Make it realistic before you read it: include commissions and slippage, because every real trade costs something and rarely fills at the exact price you expected.
The example’s key statistics (October 2009 to November 2026, $10,000 starting capital):
| Metric | Value | How to read it |
|---|---|---|
| Total profit | +$72,927 (+729.27%) | Impressive, but only meaningful next to buy and hold |
| Max drawdown | $2,746 (3.29%) | Counts closed trades only; open losses can be much deeper |
| Profitable trades | 45% (18 of 40) | Win rate is not the score |
| Profit factor | 7.6 | About $7.60 won for every $1 lost |

Three lessons from these numbers:
- Win rate is not the score. This bot lost more often than it won and still made money, because its average win was far larger than its average loss.
- Concentration. Most of the profit came from a few very large winners. Miss one of them in live trading and the result looks very different.
- Compare with buy and hold. One click in the report shows what simply holding the asset would have done. Here, holding Bitcoin crushed the strategy, as it beats almost any active strategy on Bitcoin since 2013.

Two more habits: test the same rules on other timeframes, and remember that every backtest trade is simulated. A backtest shows the past. A crash or a new kind of market can break any strategy.
12. Switch it on as alerts you approve
In semi-automatic mode the bot sends a signal and you press buy or sell. Claude can create the alert through the same MCP bridge. The request in the recording was spoken by voice:
Create an alert system for the strategy "Turtle Breakout 55-20".
Send an alert every time the bot buys or sells, using the bot's
own messages, to both email and the app. Make the alerts last as
long as possible, don't touch my other alerts, and tell me the
settings you used when you're done.
Claude created the alert, left an older test alert untouched and listed its settings:
| Setting | Value |
|---|---|
| Symbol and chart | BTCUSD, daily |
| Condition | Turtle Breakout 55-20 Bot (55, 20, 20, 2, 1) |
| Trigger | Every order fill: each buy, stop-loss sell and 20-day-low sell |
| Message | The bot’s own text, e.g. “BUY BTC, price …, Stop Loss …, size … BTC” |
| Expiration | Open-ended |
| Notifications | In-app (mobile push) and email |

The alert appears under Alerts in the top-right of TradingView, already active. Alerts run on TradingView’s servers, so they reach your phone and inbox even when TradingView is closed. One catch: if you change the strategy, you must recreate the alert.

Part V — Oversight
13. Four rules that keep you in control
- You are responsible for every trade, automated or not. Not the bot, not Claude, not a course.
- Claude never gets your broker login, API keys or the order button. An AI can trade while you sleep, and it still makes mistakes. Keep the final click with you.
- Pause at the limit. If live drawdown gets worse than the worst drawdown in the backtest, stop the bot. Either the market changed or the test was wrong.
- Renew your alerts. On standard TradingView plans alerts expire after about two months; set a reminder.

Semi-Automatic vs Fully Automatic
| Semi-automatic (this guide) | Fully automatic | |
|---|---|---|
| Who places the order | You, after an alert | The bot, through a broker connection |
| What Claude can touch | Chart, scripts, alerts | Also your broker account |
| Cost of a bot mistake | One alert you can ignore | A real order, possibly overnight |
| Speed | Minutes to react | Instant |
| Good for | Learning, new strategies | Tested strategies with hard limits |
Final Perspective
The interesting change is not that AI can write a trading bot. It is that the bottleneck moved. Coding used to be the hard part, so few people got far enough to discover that their strategy was weak. Now anyone can reach a backtest with a three-digit return in an afternoon, which makes honest checking the skill that matters.
The workflow in this guide builds that checking in at every step: a plain-English summary before code, three trades checked by hand, a backtest compared with buy and hold, alerts instead of automatic orders, and clear rules for when to stop. Follow those steps and the AI does what it is good at, writing and fixing code, while you keep the part that decides whether money is at risk.
Quick Reference
| Step | What to do |
|---|---|
| Install | TradingView Desktop (Essential plan or higher), Claude desktop app, TradingView MCP from GitHub |
| Test | Ask Claude which chart is open and the price |
| Rules | Market and timeframe, entry, stop, exit, size |
| Build | Ask for a NEW Pine Script strategy; rules back in plain English first |
| Approve | Read the summary and assumptions, then reply “go” |
| Check | Three trades by hand: entry, fixed stop, exit, size |
| Backtest | Add commissions and slippage; compare with buy and hold |
| Switch on | Alerts on every order fill, to app and email |
| Oversight | No broker access for Claude; pause past the backtest’s worst drawdown; renew alerts |
FAQ
Do I need to know how to code?
No. You describe the rules in plain English and Claude writes the Pine Script, adds it to the chart and fixes its own compile errors. You do need to understand your rules well enough to check trades on the chart.
Does this work in the TradingView web app?
Not with this setup. The MCP bridge connects to the TradingView desktop app, so the workflow does not work in a browser or on a phone. Alerts still reach your phone once they exist.
Can I use the free Claude plan?
The free plan can run a few requests, enough to test the connection and a first build. Building and revising strategies regularly needs a paid plan, and the strongest models give the most reliable code.
Is the turtle breakout a good strategy?
It is a teaching example. Its backtest made money but lost clearly to simply holding Bitcoin, and its profit came from a few large trades. Use it to learn the workflow, then test your own ideas the same way.
Should I let the bot trade automatically?
Not at first. Start semi-automatic: the bot sends alerts and you place the orders. Never give an AI your broker login, API keys or order button, and only consider automation for a strategy you have tested thoroughly, with strict limits.
Why does my alert stop working after a while?
On standard plans TradingView alerts expire after about two months, and any change to the strategy requires recreating the alert. Check your alerts list regularly.
Further Reading
- The TradingView MCP project’s README on GitHub: what it can access and how to install it safely.
- TradingView’s documentation on Pine Script strategies, the Strategy Tester and alerts.
- On AIBotRadar: more guides on Claude, MCP and AI automation.
Not financial advice. The strategy is a simplified example; backtest results are simulated and do not predict future returns. Plans, model names and menus change often.
