How to Use Claude for Trading (and What It Can't Do)
To use Claude for trading, give it one written rule and a real data file, ask it to list every ambiguity before it writes code, then run that code yourself and check the result against an independent count. It writes and explains; it does not see live prices or know whether a rule has an edge.
Claude is a language model made by Anthropic, and for a trader it is a fast, literal assistant: it turns a rule you wrote into code, explains that code line by line, and points out where your wording was vague. It does not watch the market, and it cannot tell you whether a rule makes money.
This page is the workflow, with one prompt run on real data from start to finish. The wider claims about AI in markets, and what regulators have said about them, sit on the AI trading page.
Before you start
A rule you can write in one plain sentence, with numbers in it. “Buy strength” is not a rule. “A day whose close is above the highest close of the previous 20 trading days” is one, because a computer and a second person would both mark the same days.
A saved data file you can hand over, because the model has no market feed of its own. A CSV of daily bars exported from your charting platform or a data provider works. Anything the model says about prices it was not given comes from training data with a cutoff date, not from the market today.
A way to run the code yourself, so every answer gets checked rather than trusted. Python on your own computer handles a script; the Pine Editor in TradingView handles an indicator. The set up TradingView page covers the chart side.
The steps
1. Write the rule in one sentence before opening the chat
Put the numbers in: the lookback, the price field, the timeframe. If the sentence needs the word “when it looks like”, the rule is not finished yet.
2. Attach the data file and name its columns
Say what each column holds and what period it covers. A model that is told “close” is the column to use will not quietly switch to the adjusted close.
3. Ask for the ambiguities as a list before any code
Word it as a separate numbered request. The list shows you every decision the model made on your behalf, and it is the fastest place to catch a misunderstanding.
4. Ask for code that prints a count you can verify
A per-year count, a total, or the dates of the first five signals. Output that can be counted by another method is output that can be checked.
5. Tell it not to judge profitability or guess the numbers
This keeps the answer on the job it can do. A model asked whether a rule works will produce a confident paragraph; a model asked for code produces something testable.
6. Run the code yourself and recount one result another way
Use a second script, a spreadsheet, or the marks on a chart for one year. If the two disagree, the disagreement is the most useful thing the exercise produced.
7. Change one ambiguity at a time and record each count
Strict or equal, close or high, raw or adjusted. Write each count next to its decision, so the effect of the wording is on paper before anything is tested with money.
How to tell it worked
The model’s count and your recount agree in every period you checked, to the day. A gap of even 1 day in one year means either the code or your recount is wrong, and finding out which is the point.
You can name at least 3 decisions the rule depended on without scrolling back to the chat.
The Pine version matches the Python version for 1 full year. Count the markers the indicator draws on the chart for that year and compare the number with the script’s line for the same year.
Nothing in your notes says the rule is good. At this stage you have a rule that is coded correctly, which is the input to a backtest, not the output of one.
What Claude can and cannot do
It can write, read and explain code. Pine Script, Python and spreadsheet formulas are all within reach, and asking it to explain its own script line by line is often the fastest way to learn the language. The Pine Script page covers what the language itself can do.
It cannot see live prices. Anthropic’s models overview, read 26 Sep 2026, lists four current models: Claude Fable 5.1, Claude Opus 5.5, Claude Sonnet 5 and Claude Haiku 4.5. It gives Claude Opus 5.5 a reliable knowledge cutoff of June 2026. Anything after that, including yesterday’s close, exists for the model only if you paste it in or connect a tool that fetches it.
It can be wrong while sounding certain. A statistic, a date or an indicator default can come back wrong in a fluent sentence. Anything that goes into a decision gets checked against the original.
It is not a signal service. Anthropic’s own Usage Policy, effective 15 Sep 2025 and read 26 Sep 2026, lists “use cases related to financial decisions, including investment advice” as high-risk. A business putting that kind of output in front of consumers must have a qualified professional review it and must tell people AI was involved. That rule is written for companies building on Claude, but it shows how the maker itself classes the job.
A prompt run on real data
This is an example of the workflow, not a trading result. The prompt below was given to Claude (Claude Opus 5.5, working as a coding agent with the file available to it) on 26 Sep 2026 with SPY daily bars from Yahoo Finance attached, the same SPY daily file published on this site. The answer was saved before the code was run and was not edited afterwards. The one change on this page: the file’s name is shown as SPY_FILE in both the prompt and the script.
I’ve attached SPY_FILE, SPY daily bars with the columns date, open, high, low, close, adjclose. My rule: a “breakout day” is a day whose close is above the highest close of the previous 20 trading days. 1. Restate the rule in one sentence and list every ambiguity you had to decide to code it. 2. Write a Python script (standard library only) that counts breakout days per calendar year from 2016 to 2025 using the close column, and prints one line per year. 3. Write the same rule as a Pine Script v6 indicator that marks those days on a TradingView daily chart. Do not tell me whether the rule is profitable, and do not guess the counts - I will run the script.
Claude listed seven decisions. Strictly above rather than equal; the 20 sessions before today, not including today; the highest close rather than the highest high; the raw close rather than the adjusted one; a window that runs across year ends; every qualifying day counted, so five new highs in a row are five days; and no filling of market holidays. Its script, exactly as returned:
import csv
from collections import Counter
PATH = "SPY_FILE"
LOOKBACK = 20
dates, closes = [], []
with open(PATH, newline="") as f:
for row in csv.DictReader(f):
dates.append(row["date"])
closes.append(float(row["close"]))
counts = Counter()
for i in range(LOOKBACK, len(closes)):
prior_high = max(closes[i - LOOKBACK:i])
if closes[i] > prior_high:
counts[dates[i][:4]] += 1
for year in range(2016, 2026):
print(year, counts.get(str(year), 0))
Run on the file, it printed 49, 61, 42, 77, 67, 75, 26, 58, 65 and 61 for 2016 through 2025, a total of 581 days. A separate script written for this page, looping over the bars its own way, returned the same number in all 10 years. The busiest year was 2019 with 77 and the quietest was 2022 with 26.
The Pine indicator was not compiled for this page. The check for it is the one in the list above: count its markers for a single year on a daily SPY chart and compare that with the script’s line.
The original data
Two sets of figures come from this site’s own files. The first is the prompt example, re-run with each of Claude’s listed decisions switched the other way. Over the same 2,514 trading days from 2016 to 2025, the rule as written marks 581 breakout days, 23.1% of sessions. Counting a close equal to the prior high as well gives 585. Using the dividend-adjusted close gives 607.
Measuring against the highest high instead of the highest close gives 370, which is 36.3% fewer. One word in the sentence moved the count by more than a third, and nothing in the prompt would have shown it without step 3. All five columns, year by year, are in the breakout counts CSV.
The second set measures demand. In the 24,971 unique videos collected for this site’s search study, counted by title with the site’s standard method, 58 name Claude, from 39 channels, at a median of 26,995 views, and 13 of those passed 100,000. The largest three drew 598,435, 502,813 and 343,258.
Pairing Claude with TradingView has the highest median of the groups measured here. Those 14 titles have a median of 71,201.5 views. Across all 37 titles naming ChatGPT or GPT the median is 4,246, and the 17 that pair ChatGPT or GPT with TradingView have a median of 1,539. Titles naming Claude Code number 17, at a median of 63,104, and Gemini appears in 10, at a median of 8,012.
With groups of 10 to 17 videos, one popular upload can shift a median a long way, so read these as signs of interest, not a firm ranking.
Claude videos also run long. Their median length is 16.3 minutes, against 7.9 for ChatGPT or GPT titles and 12.1 for the whole corpus. Only 2 titles name both Claude and ChatGPT, so head-to-head comparisons barely exist in this sample.
Promises did worse here, not better. Of the 58, 11 carry a result claim: profit, money, “makes”, a dollar or percentage figure, “results” or passive income. Those 11 drew a median of 18,072 views; the other 47 drew 49,154. The broader AI-trading titles on the AI trading page show the opposite pattern, and neither set checks whether any claim was true.
One limit on these counts: the corpus was gathered through searches, and 17 of the 58 Claude videos came from searches about algorithmic trading, bots or automation, so the sample leans toward builders. The corpus carries no upload dates, so no trend by year can be drawn from it. Every group and its title rule is in the title counts CSV.
When it fails
The first failure is asking it for an edge. “Write me a profitable strategy” returns code that runs and a description that sounds tested. Nothing about either shows the rule works, and the overfitting page explains why tuning it until it looks good makes this worse.
The second is trusting a number it states. Without a data file, a figure about past prices comes from memory, not from a calculation, and it can be off by a little or by a lot.
A third is the silent decision. Close or high, strict or equal: the example above moved by 36.3% on one of them, and a model that is not asked will pick one without saying so.
A fourth is a script that repaints. An indicator that reads the current, unfinished bar can show a signal during the session that is gone by the close; Claude’s own answer flagged this for its Pine version. The write a Pine script page covers the fix.
And a fifth is skipping the test. A correctly coded rule still needs costs, an out-of-sample period and a strategy tester run before it means anything. The backtest a strategy page is the next step.
Related
AI trading covers what AI can and cannot do in markets and what regulators have warned about. Pine Script explains the language Claude writes for TradingView. And backtesting is how a rule that is coded correctly gets tested before money is involved. A breakout page covers the kind of signal the example counts.
Ask for the list of decisions before asking for the code. Every rule written in English hides three or four choices, and the model will make each of them silently unless it is told to say them out loud. Read that list first, because it is where the answer actually gets decided.
— Michael Whitman
This page is educational, not financial advice. Test every idea on your own charts before risking money.