An AI chat assistant will write you a complete reinforcement-learning trading bot in an afternoon: a training environment, stop-loss and take-profit logic, Sharpe ratios, Telegram alerts and a live exchange loop. We took one such bot, rebuilt it properly for gold and put it through the same written test rules we use for every idea. This is what we learned.
What the generated code got wrong
The chat's code looked finished. Read line by line, it was not:
- It did not run. One line had a missing bracket.
- The observation was one bar too long. A slice that includes both ends gave the agent eleven bars where the model expected ten.
- The win rate was not a win rate. It compared the account value five bars apart instead of counting the profit of each closed trade.
- The Sharpe ratio assumed daily bars (the square root of 252) whatever the timeframe was.
- Every trade used the whole account, and the stop sat 1-3 % away on every market, whatever its volatility.
- It was trained on a random walk. A random walk has nothing to learn, so any result on it is luck.
How we rebuilt it
- Decide at the close, fill at the next open. The agent never sees a bar it trades on.
- Real costs. A round-trip cost on every fill, a stop sized from the 14-bar ATR and 0.25-0.5 % of the account at risk per trade.
- Walk-forward. Train on the past, test on the next year (2022, 2023, 2024 and the first half of 2025), five random seeds each, and a final period held back untouched.
- A null, not zero. Each agent had to beat the same trades in a random order, not just make money. Gold rose a lot in these years, so "it made money" proves little.
- Checks on the checker. Hand-calculated test trades, a look-ahead test that changes only future bars and requires nothing earlier to move, every saved run replayed to the cent, and the trade engine compared trade by trade with an older, independently written version (430 of 430 trades identical).
Round 1: let the agent choose long, short or flat every hour
On 2022 the agent lost in all three versions we registered: a median of -8,279, -32,488 and -4,362 USD on a 100,000 account, 0 of 5 seeds passing in each. The reason was visible in its trades. About 90 % closed on its own signal with small gains, and the 10 % that hit the stop gave back more than everything else earned. It cut its winners early and took its losers in full, and it traded 13 to 120 times a month, paying the cost every time. At the one-hour horizon the direction of gold is close to a coin flip, and a learning agent found nothing to learn there.
Round 2: put the agent on top of a rule that already works
Next we gave the agent less freedom. The entry and the exit came from a plain 4-hour breakout rule whose entry timing had beaten random entries in 20 of 20 trials over sixteen years. The agent could only choose, at each signal, to skip it, take it at half size or take it at full size.
It failed again: 0 of 20 seeds beat their random-order version. The agent skipped 76-97 % of the signals and picked trades about as well as a random subset of the same size would. Over the four test years the agents averaged +5,981 USD, while simply taking every signal made +18,068 USD. In a breakout system a few large winners carry the year, and an agent that skips most signals misses them.
Three more checks without the AI
- Reverse the direction in some market regimes? No. Over 2011-2026 the rule beat its exact opposite in trending, falling and ranging markets alike, by 0.44-0.67 R a trade.
- Half size in ranging markets? Not better than halving a random set of trades of the same size.
- A wider trailing stop? The best width moved from one period to the next (4, 5 or 6 times the ATR), which means none of them is a real improvement.
Round 3: nine times more history and three variants
Finally we trained on about nine times more history (from 2011), in three variants of 20 runs each: a plain reward, a Sortino-style reward that weighs a loss twice as heavily as a gain, and the plain reward plus a hidden Markov regime feature. None of the 60 runs beat its random-order version. The plain and regime variants skipped 73-96 % of the signals and added up to +3,717 and +5,550 USD over the four test years, while taking every signal made +14,236 USD. The Sortino-style variant learned to skip every signal in all 20 runs: with losses weighted double, doing nothing was the best policy it could find. How each method works is explained in How we trained an RL gold bot: HMM, Sortino and PPO.
What actually earned
The plain breakout rule, with no AI layer. From 2011 to mid-2025, risking 0.25 % a trade and starting each year at 100,000, it ended 13 of 15 years positive. The median year was +6.8 %, the worst -2.5 % (2022), the best +21.5 % (2017), and the deepest drop inside a year was 10,922 USD. Recent years were weaker: 2021 -1.0 %, 2022 -2.5 % and 2024 +0.3 %. These are backtest numbers, not a promise of future results.
If you are building an RL trading bot
- Read the generated code line by line before you trust any number it prints.
- Fill at the next bar, charge real costs, and count trades per month before anything else.
- Test against a random version of your own trades, not against zero.
- Give the agent a small, safe job on top of a rule that already works, not the whole market.
- Expect the honest answer to be "no edge", and keep the money you would otherwise have lost.
We run the same tests on other people's robots. The strategy test report costs 30 USD, and before you pay we tell you what can and cannot be tested.