Diagnose Why Your Trading Strategy Lost Money With AI Agents

Use the Diagnostician agent to forensically analyze losing trades on NSE/BSE — indicator context, MAE/MFE curves, stop-loss simulation, and filter suggestions.

trade doctortrade forensicsai agentslosing tradesstop lossdiagnose strategy

When a backtest comes back with a poor Sharpe or a drawdown spike, the wrong move is to re-tune parameters by gut feel. The right move is to ask alphabench's Diagnostician agent (internally called trade doctor) to perform a per-trade forensic review and tell you why the losing trades lost.

This guide shows how to invoke the Diagnostician on any backtest, what evidence it returns, and how to feed those findings back to the Quant agent for a refined strategy.

1. Run a backtest first

The Diagnostician operates on a completed trade log. Start with any backtest — equity, options spread, futures, or pairs:

  • "Backtest 15-minute Opening Range Breakout on NIFTY 5m candles for the last 2 years."
  • "Backtest an ATM straddle sell at 9:30 with exit at 15:15 on BANKNIFTY weekly options."

Once the Quant agent finishes, you'll see the equity curve, trade table, and metrics.

2. Ask the Diagnostician to investigate

In the same chat, send:

"Diagnose the losing trades. Why are we losing money?"

The Planner agent routes this to the Diagnostician, which calls the diagnose_trades tool against the most recent trade log (it falls back to your prior iteration's log automatically when the current iteration has no trades).

3. What the Diagnostician returns

A compact forensic report with up to five worst trades and these layers of evidence:

  • Indicator panel at entry: RSI, ADX, +DI/-DI, Stochastic, CCI, ATR, Bollinger Band width, volume ratio, EMA/SMA slopes — twelve indicators recomputed at each entry bar so you can see the market context the entry fired into.
  • MAE / MFE: Maximum Adverse Excursion and Maximum Favourable Excursion per trade. Tells you whether the trade was right but stopped early, or wrong from bar one.
  • Stop-loss simulation: A grid of alternative stops (0.5%, 1%, ATR-based) showing the P&L impact across the whole portfolio — not just one trade.
  • Filter suggestions: Up to two ranked suggestions like "add ADX > 20 filter" or "avoid trades when volume ratio < 0.7", with the win-rate delta they would produce. The agent caps suggestions at two to avoid overfitting.
  • Time-of-day, day-of-week, and regime correlation when relevant.

4. Feed findings back into a refined strategy

Once you've read the diagnosis, ask the Quant agent for a refined version:

"Re-run the backtest with the ADX > 20 filter and 1.5x ATR stop the doctor suggested."

The agents share message history, so the Quant agent already has the original strategy DSL and only changes what you asked for.

5. Iterate with discipline

Two filters per iteration is a healthy ceiling. Beyond that you're curve-fitting. After two iterations, run a walk_forward_test and a monte_carlo_test to confirm the improvements are robust, not artefacts of the in-sample window.