How to Optimize Your Trading Algorithm for Maximum ROI
To optimize a trading algorithm for better ROI, improve return per unit of risk and capital, not raw profit on past data. In practice: cut costs and slippage first, size positions to a fixed risk, add filters that skip conditions the strategy handles badly, and tune settings only within ranges that work, confirming every change on data you didn't use to choose it.

What ROI really means for an algo strategy
ROI is profit divided by the capital it needs. That gives you three levers, not one:
| Lever | What you change | Example |
|---|---|---|
| Increase net profit | Better entries and exits, fewer bad trades | A filter that skips trend days for a short straddle |
| Reduce costs | Slippage, charges, unnecessary trades | Fewer entries, more liquid strikes |
| Reduce capital needed | Margin required for the same exposure | Hedged option positions often need less margin than naked ones |
And one constraint: the drawdown has to stay at a level you can sit through. A change that adds 5% to annual return but doubles the worst drawdown is usually not an improvement.
The optimization order that works
Work from the changes least likely to overfit to the ones most likely to:
- Fix costs and execution. No overfitting risk; pure gain.
- Fix position sizing. Changes risk, not the signal.
- Add or refine risk rules (stops, daily limits, trailing stops) that have a clear reason to exist.
- Add market filters with a clear logic behind them.
- Tune numeric settings last, within ranges, and only a few of them.
1. Reduce costs and slippage
Every rupee of slippage saved is a rupee of profit, with no change to the strategy's logic.
- Trade fewer, better entries. A strategy that enters ten times a day pays costs ten times.
- Trade liquid instruments. Near-the-money index options have tighter spreads than far strikes.
- Use sensible order pricing. On Tradetron, Advanced Settings let live orders start at a chosen price (for example, the average of bid and ask), revise by a set number of ticks, and fall back after a timeout, rather than always crossing the spread.
- Split large orders with tranching so one big order doesn't move the price against you.
Measure the effect: apply your real slippage in the backtest report's cost section and find the break-even level. More in understanding slippage.
2. Size positions to a fixed risk
Position size changes ROI and drawdown together. Two common approaches:
Fixed-risk sizing. Decide the rupee loss per trade you accept (say 1% of capital) and set size so a stop-out costs exactly that. It keeps risk constant when volatility changes.
Kelly-based sizing (with caution). The Kelly fraction is the share of capital that maximises long-run growth for a given edge:
On Tradetron, size is set by the lots on each position, and the multiplier at deployment scales the whole strategy up or down.
3. Refine risk rules that have a reason
Risk rules can raise ROI by cutting the worst losses, but only if they are grounded in how the strategy behaves:
- Per-leg stop loss through each position's SL trigger.
- Daily loss limit through a Universal Exit on the strategy's P&L.
- Trailing stop to protect open profit; see how TSL works on Tradetron.
- Time exit for strategies whose edge fades later in the day.
Test each rule on its own against the baseline. A stop that cuts the worst days but stops you out of many good ones may lower ROI; the backtest will show which.
4. Add market filters with a clear logic
Most strategies have conditions they handle badly. A filter keeps the strategy out of them:
| Strategy type | Struggles when | Possible filter |
|---|---|---|
| Option selling | Volatility jumps, big trend days | Skip entry if the day's range is already wide by entry time |
| Trend following | Sideways, choppy markets | Trade only when price is above or below a long moving average |
| Mean reversion | Strong trends | Skip when an ADX-style trend measure is high |
A good filter is one you could explain before seeing the results. If you only found it by trying twenty filters, treat it with suspicion.
5. Tune numbers last, and pick the plateau
Now adjust numeric settings such as stop-loss percentage, entry time or indicator length. The rule: don't pick the single best value; pick a value from the middle of a range where results are consistently good.
Illustration: a stable range is evidence of a real effect; a lone peak usually isn't
Tradetron's backtest form has a sweep option that runs several values of one number in the strategy side by side, which makes the plateau easy to see. Keep the number of settings you tune small: two or three, not ten.
How to check that an optimization is real
- Compare with the baseline, run on the same period and settings.
- Check held-back data. With a sweep you can keep part of the period aside; compare the chosen version there. If it falls apart, it was a curve fit.
- Look at each year separately. An improvement that came from one year only is fragile.
- Re-check after costs. Some "improvements" add trades and vanish once costs are applied.
- Test forward. Run the new version Live Offline, where the strategy runs and records every trade but nothing is sent to the exchange, and compare it with the old version on the same days.
Read the ten most common backtesting mistakes for more on overfitting.
How often should you re-optimize?
Less often than you think. Re-tuning every time a strategy has a bad week is just overfitting in slow motion. A sensible routine:
- Monthly: review live results against the backtest; don't change settings unless something is clearly broken.
- Quarterly or half-yearly: re-run the backtest including recent data and check the chosen settings are still inside the stable range.
- Immediately: only when something structural changes, such as a lot size or expiry-day change, or a rule the strategy depends on.
If performance has faded for a long stretch, read strategy fatigue before deciding whether to tune or retire it.
Frequently asked questions
How do I optimize a trading algorithm?
Start with a baseline backtest. Then improve costs and execution, position sizing and risk rules, add filters with a clear reason, and tune a few numeric settings last, choosing values from a stable range. Confirm each change on held-back data and in Live Offline testing.
What is overfitting in algorithmic trading?
Overfitting is tuning a strategy so closely to past data that it captures noise instead of a real pattern. It shows up as excellent backtest results that don't carry over to new data or live trading.
Which metric should I optimize for?
A risk-adjusted one, such as return relative to maximum drawdown (Calmar) or the Sharpe ratio, after costs. Optimizing for raw profit tends to pick the riskiest, most overfitted version.
How often should I re-optimize my strategy?
Review monthly, re-test with new data every few months, and change settings rarely. Change immediately only when something structural changes, such as lot sizes or expiry days.
Does Tradetron have an optimization tool?
Tradetron's backtest form includes a sweep that tests several values of one number in your strategy side by side and can hold back part of the period to check the chosen value on unseen data.
How do I know if my algorithm needs optimizing or replacing?
If the strategy still shows a positive edge after costs but has drifted, a small, tested adjustment may help. If the market pattern it relies on has gone, for example because of a change in how contracts trade, it's usually better to replace it than to keep tuning.