r4lph.io

Free code Tom Basso's trend rules

My AI Tests Famous Trading Systems

Tom Basso's trend rules and position sizing, free Python backtest

My AI coding agent read 9 long interviews with Market Wizard Tom Basso, rebuilt his trend rules and his position sizing, and tested four of his claims on 24 ETFs. It checked its own work. This is the code it wrote: the full Python backtest.

Download the code (zip, 17 KB) Source on GitHub

Free, with no sign-up. This is an experiment in what AI agents can build and verify, not trading advice.

The honest result

Before costs, coin-flip entries beat Basso's entry rule: a median of +3.1% a year against +2.6%. After costs, only 14% of the coin-flip runs made money, and his system beat 89% of them. But his system made only +0.4% a year after costs. SPY, bought and held, made +10.7% a year. The profit before costs came from his exits and his sizing, not from his entry.

+3.1%

a year before costs. Median of 100 coin-flip runs with his sizing. His entry rule made +2.6%.

14%

of 500 coin-flip runs made money after costs. His system beat 89% of them.

+0.4%

a year after costs. His 21-day system with his full sizing. SPY, bought and held, made +10.7%.

30 of 2,992

trades made $11.6M on a $10M account. The other 2,962 trades lost $14.1M.

TestBefore costsAfter costs
Coin flip, median return a year+3.1%−1.8%
Coin-flip runs that made money94% of 10014% of 500
His 21-day Keltner system, return a year+2.6%+0.4%
SPY, buy and hold, return a year+10.7%+10.7%

TradingView

This episode has no TradingView script. The agent built the test in Python only. Basso's sizing caps the total risk of all open positions together, across the whole portfolio. A TradingView strategy tests one symbol, so it cannot show the part of the system that did the work.

What is in the zip

README.md
What the test found, the rules in short, and why there is no TradingView script.
RESULTS.md
The setup, the four tests, the result tables and the limits. It links to the time in each of Basso's talks where he gives a setting.
python/
The full backtest: the engine, the data download, the four tests and the charts from the video.

Run the Python backtest

From the python/ folder, with Python 3.12 or later:

pip install -r requirements.txt
mkdir -p data results
python fetch.py data
python sizing_study.py data results
python more_tests.py data results 500
python cost_check.py data results
python charts.py results

How the agent checked its work

The rules and the sizing settings come from Tom Basso's own talks and interviews, 2016 to 2026. RESULTS.md links to the time in each video where he gives them.

The video

Coin Flips Beat Tom Basso's Entry Until Costs Hit

Download the code All free code

This is an experiment in what AI agents can build and verify, not trading advice. The code is free to use, change and share.