ATMResearch
Join Overfit - free
Overfit cover card on dark navy, kicker 'AI strategy development': the headline 'Four prompts, in order. 0 of 5 AI rules beat buy-and-hold out-of-sample.' over the line 'The workflow only. The validation step is separate, and it is not optional.', with a corner badge reading '4 prompts · a separate test'.
  1. Overfit/
  2. Research/
  3. AI Trading Strategy Development: The Exact Prompts, Step by Step

March 13, 2025

AI Trading Strategy Development: The Exact Prompts, Step by Step

Share

5 min read

Written by Ali Casey, founder of StatOasis and AlgoChef, creator of the Algo Trading Masterclass (ATM), with over 10 years of experience building systematic trading tools - building algorithmic strategies, testing ideas with data, and teaching traders how to build structured, portfolio-based trading workflows.

Published March 13, 2025 · Updated September 17, 2026 · Method

← Back to Research
Table of contents▾
  • TL;DR — the answer box
  • What this guide is, and what it is not
  • Step 1 — Start from a market edge, not from a prompt
  • Step 2 — Set the experience level and the criteria
  • Step 3 — Name the edge in the prompt itself
  • Step 4 — Ask for exits, and ask for several
  • Step 5 — Ask for filters that remove trades
  • What the output actually looks like
  • The step this page does not cover, and you cannot skip
  • Where AI actually goes wrong
  • Methodology
  • FAQs

The short version

These are the four prompts I use, in order, to get a specific and testable trading strategy out of an AI instead of a paragraph of hedging. This page is the workflow only, and it does not test what the workflow produces. A companion study tested 5 AI-written rules exactly as given: 0 of the 5 beat simply buying and holding out-of-sample, and the AI that wrote them was trained on text published during that out-of-sample decade. Its separate optimizer sweep of 2,304 variants found 0 of the 2,068 eligible ones beating buy-and-hold either.

TL;DR — the answer box

  • Prompt in four narrow passes, not one broad one. Experience and criteria, then the market edge, then exits, then filters.
  • Start from a market edge you can name. An unconstrained model invents behaviour that is not there, and sounds identical when it does.
  • Ask for exits before you ask for profit. Drawdown is the thing you have to ask for. The workflow's third prompt does.
  • The output is a candidate, never a conclusion. In the companion optimizer sweep, the median risk-adjusted score of the top 25 in-sample picks fell 85% out-of-sample.
  • The validation step is not optional and it is not part of this page. It is the whole of the companion study.

What this guide is, and what it is not

This is the how. It is the prompting workflow, the order to run it in, and the four screenshots of the actual prompts.

It is deliberately not the evidence that AI-generated strategies work, because I tested that separately and the answer does not fit in a how-to. If what you want is the verdict — how many survive, by how much they degrade, what beats them — read Can AI Build a Profitable Trading Strategy? instead. That study swept 2,304 variants and implemented 5 AI-written rule-sets.

I am separating them on purpose. A guide that teaches a workflow and also grades it tends to grade it generously.

Step 1 — Start from a market edge, not from a prompt

A market edge is a specific, repeatable behaviour you have a reason to believe in. US index ETFs tending to bounce after several consecutive lower closes is a hypothesis stated that way. "Find me something profitable" is not.

This matters more than any prompt wording. An unconstrained search is data dredging with a chat window in front of it: test enough ideas against the same history and something comes back looking good. An AI asked to search everything will produce a confident, well-structured strategy for a behaviour that does not exist — and it reads exactly like one for a behaviour that does. Naming the edge first is the workflow used here: it turns the model's job into filling in the details of an idea you can already defend. No prompt-versus-prompt test was run to measure the difference.

Step 2 — Set the experience level and the criteria

Prompt 1: the experience level and the concrete criteria the strategy has to meet, before any mention of indicators.

This step's purpose is to change the density of the answer: naming the audience, then handing over the criteria — instrument, direction, holding period, what counts as acceptable — is designed to stop the model hedging across every possibility. Neither effect is something this page measured; it is the workflow's design, not a tested result.

Step 3 — Name the edge in the prompt itself

Prompt 2: the market edge stated explicitly, which narrows the model to one defined behaviour.

Here the edge from Step 1 goes in as a constraint: a mean-reversion, long-only approach on the S&P 500. Everything the model returns from this point sits inside that box. The box does not make the idea right: in the companion optimizer sweep, 1,034 of the 2,068 eligible variants (50%) were still profitable out of sample. Prompt wording was never tested against that number.

Step 4 — Ask for exits, and ask for several

Prompt 3: several alternative exits, requested specifically to reduce drawdown rather than to raise profit.

This is the prompt most people skip. Neither this page nor the companion study compared entry prompts with and without an explicit drawdown request, but in this workflow's own experience, asking for entries alone got entries; asking for drawdown-reducing exits is what got exits aimed at that goal. Asking for several exits also gives you something to compare, which matters later — a strategy whose result changes wildly depending on which exit you pick was never robust to begin with.

Step 5 — Ask for filters that remove trades

Prompt 4: filters framed as a way to remove weak entries, not to add new ones.

A filter should take trades away. Framing the request that way produced a single meaningful condition in this example, an Internal Bar Strength threshold, rather than a stack of indicators that each remove a handful of trades and collectively fit the past. Sample size sets the floor: the companion study would not even score a variant on fewer than 30 in-sample trades, and 236 of its 2,304 variants failed that bar before any result was read.

What the output actually looks like

Running those four prompts on a defined edge, in this worked example, produced something concrete enough to test:

  • Market: S&P 500
  • Entry: 3 lower closes within 4 bars
  • Exit 1: RSI(2) above 65
  • Exit 2: after 4 bars
  • Filter: Internal Bar Strength below 0.2

Tested over 18+ years of daily data, that produces this:

The worked example's equity curve — and the most misleading chart on this page, for the reason directly below.

Read that chart carefully, because it is the exact shape that fools people. It rises. It has no benchmark line on it. It has no random-entry control on it. Nothing about it tells you whether this strategy beat simply owning the index over the same 18 years, and nothing about it tells you whether a search of similar rules would have produced an equally pretty curve by chance.

I am leaving the chart on this page because it is honest about what the workflow produces. What it is not is evidence that the workflow produces something that works.

The step this page does not cover, and you cannot skip

Everything above gets you a candidate. Whether any AI-produced candidate is real is a separate question, and this page does not answer it by assertion: the companion study below tested 2,068 optimizer-swept variants and five separately AI-generated rule-sets. This exact candidate was not itself run through that pipeline; here is what happened to the ones that were:

  • 0 of 2,068 eligible optimized variants beat buy-and-hold out-of-sample. Not the best one. None of them.
  • The median risk-adjusted score of the top 25 in-sample picks fell 85% when tested on data they had never seen, from 0.80 to 0.12.
  • 1,034 of the 2,068 eligible optimized variants (50%) were still profitable out-of-sample, and the median net profit across all 2,068 was $0.00.
  • Of 5 AI-written rule-sets implemented verbatim, 2 passed a Monte Carlo screen: each one's out-of-sample profit beat at least 95% of random-entry runs. 0 of the 5 beat buy-and-hold, and the AI that wrote them was trained on text published during the out-of-sample decade.
  • Buy-and-hold on the same window returned $87,835 on a $35,000 account.

Those numbers are not measured on this page and they are not mine to summarise loosely — every one comes from the companion study, which is where the method, the controls and the full tables live.

The practical consequence for this workflow: treat the AI's output the way you would treat a strategy a stranger emailed you. Split your data before you start, keep a slice the strategy has never touched, and compare the result to owning the index rather than to zero. Scoring a rule on data it was not built from is the standard way to test one.

Where AI actually goes wrong

Hallucinated behaviour. The model will describe an indicator doing something the real calculation does not do, in fluent and specific language. Ask it to restate the rule in plain English, then re-derive the indicator yourself before trusting any curve.

Silent code errors. If you ask for code, expect logic bugs that do not throw — a lookahead in the fill, an off-by-one in the bar index. Both produce a backtest that runs cleanly and reports a number that never happened.

Neither of those two failures was measured, on this page or in the companion study. They are a checklist to run every time, not a finding.

Overfitting, which is not an AI problem. This is worth being precise about, because it is where this page used to overlap with the study. Curve-fitting is what any optimizer does when nothing stops it, human or machine. The canonical paper on it makes the point without mentioning AI at all: search enough variants and an impressive-looking backtest becomes likely even with no edge present. This page's own companion study shows the pattern: 0 of 2,068 eligible optimizer-swept variants beat buy-and-hold out-of-sample, and the top 25 in-sample picks lost a median 85% of their score once tested on data they had not seen. This study separately tested 2,304 optimizer-swept variants and five AI-generated rules, and an AI can write either kind up in prose confident enough to disguise what it is. The defence is the same as it has always been: test on data the rule never saw, and compare against a control that has no edge in it. The companion study measures how far the top in-sample picks fell once the data was new.

If you want a defined market edge to prompt from rather than inventing one, and a testing framework to check what comes back, that is what the Algo Trading Masterclass is built around. Every study behind this workflow — including the one that grades it — is published in full at StatOasis.com/Overfit

Methodology & risk note: This article runs no backtest of its own. The worked example is a single S&P 500 strategy produced by the prompts shown and tested on 18+ years of daily data in 2025; it carries no benchmark and no control, and is presented as an illustration of output shape rather than as a result. Every quantitative claim about whether AI-generated strategies survive testing is inherited from the companion study on SPY daily OHLCV, 1993-02-02 to 2026-06-12: 2,304 variants swept, 2,068 eligible at 30+ in-sample trades, in-sample to 2016-06-03 and out-of-sample from 2016-06-06, $35,000 starting capital, flat-only with no compounding, frictionless, next-open fills, measured against buy-and-hold and a seeded random-entry control. All results are historical and for educational purposes only. Past performance does not guarantee future results. Not investment advice.

Methodology

Data source
No new backtest. The worked example is a single S&P 500 strategy produced by the prompts below and tested on 18+ years of daily data in 2025; every quantitative claim about whether AI-generated strategies survive testing is inherited from subjects/ai-strategy-validation (issue 140), which ran 2,304 variants and 5 AI-generated rule-sets on SPY daily OHLCV, 1993-02-02 to 2026-06-12.
Date range
The worked example covers 18+ years of S&P 500 daily data as tested in 2025. The inherited evidence covers 1993-02-02 to 2026-06-12, split in-sample to 2016-06-03 and out-of-sample from 2016-06-06.
Entry / exit rules
Inherited from the source study, and stated here for the worked example only: entry after 3 lower closes within 4 bars, exit on RSI(2) above 65 or after 4 bars, with an Internal Bar Strength filter below 0.2. Signals are read at the close and filled at the next open.
Sizing
The worked example's equity curve is a single-unit backtest with no compounding, shown as an illustration of output shape rather than as a result. Sizing for every inherited number is the source study's: $35,000 starting capital, flat-only, no compounding, frictionless.
Overlap mode
Inherited from the source study: flat-only, so overlapping signals are skipped rather than stacked.
Look-ahead
Inherited from the source study: the decision is made on the close of one bar and the fill happens at the open of the next, so no signal or fill uses a price the market had not yet published. One limit the code cannot remove: the AI that wrote the source study's five rules was trained on text published during its out-of-sample window.
Minimum sample
Inherited from the source study, which required at least 30 in-sample trades for a variant to be eligible — an override of the engine's default 50, declared there.
Buy-and-hold benchmark
Inherited from the source study: buy and hold SPY across the out-of-sample window returned $87,835.34 on a $35,000 basis. That is the hurdle none of the 2,068 eligible optimized variants cleared, and it is the number this article uses to keep the worked example honest.
Random control
Inherited from the source study: a seeded random-entry control, frequency-matched to the median out-of-sample trade count, averaged over 10 seeds from a fixed base seed. In that companion study, a rule passes the Monte Carlo screen only if its out-of-sample profit beats at least 95% of these random-entry runs; this page's own worked-example candidate was not run through it.
Parameter scopeInherited from the source studies

This article runs no backtest of its own. Every declaration here belongs to the studies it cites, and is stated as they stated it.

This article searched nothing and tuned nothing. It documents a prompting workflow; the one strategy it shows was produced by that workflow and never optimised further. All parameter-space claims come from the source study, which swept 2,304 variants and reports the spread.

Evidenced by

This article reports no backtest of its own. Every figure in it comes from these studies, each of which can be read and checked on its own terms.

  • —Can AI Build a Profitable Trading Strategy? I Backtested 5 LLM-Generated Rules on SPY to Find Out

Run to v1 of the StatOasis research standard - the rules every study here has to meet before it is published. The version is the study's own: a standard that gained a rule later never reaches back and claims this one met it.

Historical backtest results are not a guarantee of future returns. This content is for educational purposes only and is not investment advice. Hypothetical performance disclosure (CFTC Rule 4.41).

Frequently asked questions

How do I actually prompt an AI to build a trading strategy?⌄

In four passes, not one. First set your experience level and the concrete criteria the strategy has to meet. Second, name a specific market edge so the model works inside a defined behaviour instead of searching everything at once. Third, ask for several alternative exits aimed at reducing drawdown rather than raising profit. Fourth, ask for filters that remove low-quality entries. In the worked example on this page, a single 'build me a profitable strategy' prompt returned a paragraph of hedging, and the four narrow prompts used here returned something specific enough to test.

What is a market edge, and why start there?⌄

A market edge is a specific, repeatable market behaviour you have a reason to believe in — for example, that US index ETFs tend to bounce after several consecutive down closes. Starting there matters because it converts the AI's job from open-ended search into filling in the details of a defined idea. Neither this page nor the companion study ran a constrained-versus-unconstrained prompt test, but the risk to watch for is an unconstrained model generating a strategy for a behaviour that does not exist while sounding just as confident as it would describing a real one.

Can I trust the strategy the AI hands back?⌄

Not on its own output, no — and this is the part worth being blunt about. In the companion optimizer sweep, 0 of 2,068 eligible optimizer-sweep variants beat simply buying and holding the same market out-of-sample, and the median risk-adjusted score of the top 25 in-sample picks fell 85% when tested on data they had not seen. The same study separately tested 5 AI-written rules exactly as given, and 0 of the 5 beat buy-and-hold out-of-sample, with the limit that the AI that wrote them was trained on text published during that out-of-sample decade. The prompting workflow on this page produces a candidate. This exact candidate was not itself run through that companion study's pipeline; what the pipeline shows is how the other optimizer variants and AI-written rules held up when tested properly.

Does AI hallucinate when writing trading strategies?⌄

Two known failure modes are worth checking for every time, though neither this page nor the companion study measured how often either one happens. The first is an indicator described doing something its real calculation does not do. The second is code with a silent logic error, such as a lookahead in the fill or an off-by-one in the bar index. Either one produces a backtest that runs cleanly and reports a number that never existed. Ask the AI to restate the rule in plain English, and re-derive the indicator yourself before you trust any equity curve it produces.

Do I need to be able to code to use this?⌄

Not for the prompting. You do need a way to test the result on data the strategy was not built from, because that is the step that decides whether you have anything. The workflow here is tool-agnostic — the prompts are the same whether you end up testing in a platform, a spreadsheet or code.

Read the Tools, Software & Tech Stack hub
← Back to Research

Table of contents

  • TL;DR — the answer box
  • What this guide is, and what it is not
  • Step 1 — Start from a market edge, not from a prompt
  • Step 2 — Set the experience level and the criteria
  • Step 3 — Name the edge in the prompt itself
  • Step 4 — Ask for exits, and ask for several
  • Step 5 — Ask for filters that remove trades
  • What the output actually looks like
  • The step this page does not cover, and you cannot skip
  • Where AI actually goes wrong
  • Methodology
  • FAQs

Overfit - the newsletter

Skip the hype. Trust the data.One practical takeaway per issue.

Running a quick security check before this can be sent.

Delivered +2 times a month - when the work is ready, not on a calendar.I'll never sell your address.Unsubscribe in one click, any time.

Related Articles

Back to all research
#140

Can AI Build a Profitable Trading Strategy? I Backtested 5 LLM-Generated Rules on SPY to Find Out

Aug 22, 2026 · 11 min read

Two experiments on SPY: a 2,304-variant optimizer sweep standing in for what AI does when it hunts for "the best strategy," and 5 AI-generated rules implemented verbatim. The optimizer's top-25 risk-adjusted score collapsed 85% out-of-sample, and 0 of 2,068 eligible strategies beat buy-and-hold.

Read more→
#131

StrategyQuant X Review: The No-Code Way to Build Trading Strategies

May 30, 2025 · 14 min read

I have run StrategyQuant X on an Ultimate licence since 2019, I am a paid affiliate, and my course is built around it — all stated up front. Here is the verified 2026 pricing ($1,290 Starter, $1,490 Professional, $2,900 Ultimate), the edition gate that decides the purchase, what Build 144 changed, and who should not buy it.

Read more→

Overfit - the newsletter

Skip the hype. Trust the data.

One practical, evidence-driven takeaway per issue - strategy testing, portfolio construction, market structure, trading psychology, tactical asset allocation.

Running a quick security check before this can be sent.

Delivered +2 times a month - when the work is ready, not on a calendar.I'll never sell your address.Unsubscribe in one click, any time.

StatOasis is calm, evidence-based algorithmic-trading education, founded by Ali Casey. Ali builds systematic trading strategies and teaches the workflow behind them: research, build, test, combine, deploy. He writes the Overfit newsletter, published since 2024, and runs the Algo Trading Masterclass.

Socials

  • X ↗
  • YouTube ↗
  • Instagram ↗
  • LinkedIn ↗
  • GitHub ↗
  • Muck Rack ↗
  • LinkedIn SO ↗
  • GitHub SO ↗

Products

  • Overfit - the newsletter
  • Algo Trading Masterclass
  • StatOasis Community
  • 36 Ways to Buy the Dip
  • AlgoChef ↗

Reading & tools

  • Research
  • Methodology
  • Survive the Decade
  • Wall of Love

StatOasis

  • About Ali Casey
  • Contact
© 2026 StatOasis. Calm, evidence-based.
PrivacyTermsHypothetical resultsCalifornia