ATMResearch
Join Overfit - free
Overfit cover card on dark navy, kicker 'AI strategy development': the headline 'Four prompts, in order. 0 of 2,068 held.' over the line 'The workflow only. The validation step is separate, and it is not optional.', with a corner badge reading '4 prompts · 2,304 variants'.
  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

4 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 August 21, 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. Whether the output survives testing is a different question, and I answered it separately by running 2,304 variants — the short version of that answer is that 0 of the 2,068 eligible ones beat simply buying and holding.

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 an AI will not volunteer.
  • The output is a candidate, never a conclusion. In the companion test, the top 25 in-sample picks lost 85% of their risk-adjusted score 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 verbatim.

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 an edge. "Find me something profitable" is not.

This matters more than any prompt wording. 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 converts the model's job from open-ended search into filling in the details of an idea you can already defend.

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.

Telling the model who it is talking to changes the density of the answer. Telling it the criteria — instrument, direction, holding period, what counts as acceptable — stops it hedging across every possibility.

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. It is also the cheapest place to be wrong: in the companion test only 50% of the 2,068 eligible variants were still profitable out of sample, which is a coin flip, and no amount of prompt refinement rescues a behaviour that was never there.

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. Ask for entries and an AI will give you entries; drawdown is not something it volunteers. 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 tends to produce 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 is the reason to care: 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

Run those four prompts on a defined edge and you get something concrete enough to test. In this case:

  • 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 the candidate is real is a separate question, and I tested it properly rather than asserting it:

  • 0 of 2,068 eligible optimized variants beat buy-and-hold out-of-sample. Not the best one. None of them.
  • The top 25 in-sample picks lost 85% of their risk-adjusted score when tested on data they had never seen.
  • Only 50% of eligible variants were still profitable out-of-sample — a coin flip.
  • Of 5 AI-written rule-sets implemented verbatim, 1 passed a Monte Carlo screen for a genuine edge.
  • 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.

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.

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 AI just does it faster and describes the result more persuasively. The defence is the same as it has always been: out-of-sample testing, walk-forward analysis, and comparing against a control that has no edge in it. The companion study measures exactly how much damage it does.

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 nothing uses information the market had not yet published.
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. It is the baseline that separates a real edge from the best-looking result of a large search.
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. A single 'build me a profitable strategy' prompt returns a paragraph of hedging; four narrow prompts return 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. An unconstrained model will happily generate a strategy for a behaviour that does not exist, and it will sound exactly as confident either way.

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 a controlled test of this exact question, 0 of 2,068 eligible AI-searched strategy variants beat simply buying and holding the same market out-of-sample, and the top 25 in-sample picks lost 85% of their risk-adjusted score when tested on data they had not seen. The prompting workflow on this page produces a candidate. Whether that candidate is real is a separate question with a separate answer, and it is measured in the companion study.

Does AI hallucinate when writing trading strategies?⌄

Yes, in two distinct ways. It invents indicator behaviour that does not match the real calculation, and it writes code with silent logic errors — 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 existed. Challenge the answer, ask it 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 · 9 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 · 13 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
  • Digital Products
  • 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