Your AI-generated trading bot passed the backtest. Then it lost money in live trading.
The problem may not be a syntax error. It may be a backtest that used future information, a position size that ignored volatility, a spread the tester never charged, or a broker-state bug that duplicated exposure.
This practical debugging guide shows you how to find the failure before you risk more capital. It gives you a fixed order of inspection, a test for each suspect, and the result that confirms or clears it.
What you will do
- Work through a six-layer audit: strategy, evidence, data, execution, risk and broker state, in the order that saves the most time
- Find look-ahead bias with broken and corrected code in Python and MQL5, and run a one-bar falsification test
- Check your data for survivorship, revised values, time-zone errors and gaps
- Size positions from risk, using contract size, tick value and volume step, and see why rounding can break a loss limit
- Separate gross edge from net edge after spread, slippage, commission and financing
- Stop duplicate orders after a crash or restart with broker-state reconciliation and a restart test
- Add kill switches and test them
- Compare MT5, Python and live results field by field
- Write prompts that make an AI state its assumptions, costs and limits
- Finish with a 30-minute pre-live audit and twelve printable worksheets
Who it is for
Traders who use ChatGPT, Claude or other AI tools to build MQL5 Expert Advisors or Python bots, and want to know what to check first. You do not need advanced mathematics. The formulas are in an optional appendix.
What it is not
It is not a strategy, a signal or a promise of profit, and it cannot make a weak strategy profitable. Sometimes the right result of the audit is to stop trading the bot, and the book shows you how to recognise that. The code samples are short teaching fragments, not a ready-to-run bot.
For education only. This is not financial advice. Trading involves substantial risk of loss.