Powered by LangGraph — Autonomous Optimization Loop

AI Backtest Optimizer

Describe a strategy in plain English. The AI runs a backtest, checks Sharpe ratio, drawdown, and win rate against your targets, then automatically refines the strategy and re-runs — up to 5 times — until it passes.

Your Strategyrun_backtestevaluatepass → END|fail →refine_strategy→ loop
⚠️Research tool only — not financial advice. Optimization targets historical metrics only. Past performance does not guarantee future results.

What is an AI Backtest Optimizer?

A backtest optimizer goes beyond a single backtest run. It automatically evaluates your strategy against quality targets — Sharpe ratio, drawdown, win rate — and keeps refining it until it passes or the iteration limit is reached. No manual parameter tuning needed.

🔁

Autonomous Loop

Powered by LangGraph. The optimizer runs backtest → evaluate → refine in a loop — up to 10 iterations — without any manual intervention from you.

🎯

Quality Thresholds

Set your own Sharpe ratio, max drawdown, and win rate targets. The optimizer won't stop until all three are met — or it has exhausted all iterations.

📋

Full Audit Trail

Every iteration is logged — strategy text, Sharpe, drawdown, win rate. You see exactly what was tried and how each refinement improved the metrics.

Best Result Always Returned

Even if thresholds are never fully met, the optimizer returns the single best strategy found — ranked by a composite score of Sharpe, drawdown, and win rate.

How the Backtest Optimizer Works

1
💬

Describe Your Strategy

Type any strategy in plain English — SMA crossover, RSI mean reversion, MACD, or custom multi-indicator logic.

2
🔬

AI Runs Backtest

The AI parses your strategy, generates signal code, and runs a full vectorbt backtest on real historical data.

3
📊

Evaluate vs Thresholds

Sharpe ratio, max drawdown, and win rate are checked against your targets. If all pass, the loop ends.

4
🔧

Refine & Repeat

If any threshold fails, the AI refines the strategy — adjusting periods, adding filters or stop-losses — and re-runs.

What the Optimizer Refines

📐

Indicator Periods

Adjusts SMA/EMA/RSI/MACD periods to reduce noise and improve signal quality.

🔍

Entry Filters

Adds RSI, volume, or trend filters to the entry condition to improve win rate.

🛡️

Stop-Loss Rules

Introduces percentage or points-based stop-losses to control max drawdown.

🎯

Take-Profit Targets

Adds profit targets to lock in gains and improve the profit factor.

⏱️

Timeframe Tuning

Suggests slower timeframes when intraday noise is hurting performance.

📊

Position Sizing

Recommends risk-based or Kelly Criterion sizing to improve Sharpe ratio.

Backtest Optimizer FAQ

What is a backtest optimizer?

A backtest optimizer automatically runs multiple backtest iterations on variations of your strategy, evaluating each against quality thresholds like Sharpe ratio, max drawdown, and win rate. It keeps refining until the strategy passes all targets or the iteration limit is reached — saving you hours of manual parameter tuning.

How is this different from the AI Backtester?

The AI Backtester runs your strategy once and returns the result. The Backtest Optimizer runs it multiple times, automatically refining the strategy between iterations until it meets your quality targets. Use the Backtester to test a specific strategy; use the Optimizer when you want the AI to find the best version of a strategy concept.

Will the optimizer switch to a completely different strategy?

No. The optimizer refines your original strategy concept — adjusting periods, adding filters, or introducing stop-loss rules. It keeps the same ticker and capital. If you describe an SMA crossover, it will try variations of SMA crossovers, not switch to Camarilla pivots or a completely unrelated approach.

What if the strategy never meets all thresholds?

The optimizer always returns the best result found — even if no iteration fully passed. The iteration log shows every variation tried and its metrics, so you can see which threshold was hardest to meet. This is a signal that the strategy concept may not suit the asset or timeframe, and a different approach should be considered.

Can I customize the quality thresholds?

Yes. Click "Customize quality thresholds" before running to set your own Sharpe ratio minimum, max drawdown limit, win rate target, and maximum number of iterations (up to 10). The defaults are Sharpe ≥ 0.8, drawdown ≤ -20%, win rate ≥ 45%.

Is the Backtest Optimizer free?

Yes. MokshaGPT's AI Backtest Optimizer is completely free to use for educational and informational purposes. No sign-up, no credit card required.