Backtesting and Optimization Workflow#

Writing a strategy is only the first step. Backtesting verifies whether the strategy has a historical edge, and Optimization identifies robust parameter ranges and assesses the feasibility of going live. This chapter walks through the complete validation workflow in MultiCharts, and highlights the settings most likely to cause large gaps between backtest and live performance.

WorkflowPurposeMultiCharts Feature
BacktestingSimulate strategy orders on historical data and produce a performance reportStrategy Performance Report
Backtest SettingsConfigure fill assumptions, commissions, slippage, Look-Inside-BarStrategy Properties → Properties / Backtesting tab
OptimizationSearch for the best parameter combinationsOptimize → Exhaustive / Genetic
Walk-ForwardVerify robustness of optimized parameters and avoid overfittingWalk-Forward Optimization

Backtesting#

Backtesting means “applying a strategy to historical data and simulating the orders it would have produced.” In MultiCharts, the steps are:

  1. Open a Chart Window and load the instrument and resolution to test
  2. Compile the Signal script in Power Editor
  3. Add the signal to the chart with Insert → Signal
  4. Open View → Strategy Performance Report to inspect the results

Backtesting treats every bar as an established fact and re-runs the strategy’s decisions. All fill behavior is governed by the Backtest Settings.

Key Strategy Performance Report Metrics#

After opening the Strategy Performance Report, the metrics to inspect first:

MetricDescriptionReading
Net ProfitTotal P&L (after commissions and slippage)Must be positive and meaningfully above Buy & Hold
Profit FactorGross profit / Gross loss> 1.5 is good; < 1.2 has too thin a margin
Max Intraday DrawdownLargest intraday peak-to-trough equity drop (actual field name in the Strategy Performance Report)Compare to capital — drawdowns above 30% are usually impossible to live-trade
Total TradesNumber of trades (may also appear as Total # of Trades)< 30 trades is statistically meaningless; aim for > 100
Avg Trade Net ProfitAverage P&L per tradeMust be clearly larger than commission + expected slippage
Percent Profitable (also shown as % Profitable)Win rateMeaningful only when paired with the Ratio Avg Win:Avg Loss
Ratio Avg Win:Avg LossAverage winning / losing tradeTrend strategies usually > 2; mean-reversion strategies may be < 1

Pitfall: Looking only at Net Profit is the most common beginner mistake. A pretty Net Profit number with only 12 trades and an Avg Trade close to the slippage amount will almost never reproduce live.

Backtest Settings (Avoiding Overstated Results)#

The single biggest source of backtest-to-live discrepancy is overly optimistic fill assumptions. In the Chart Window, right-click the signal → Format Signals, then on the Signals tab click Properties to open Strategy Properties (this applies to all signals), and walk through the settings below.

Commissions and Slippage#

In the Strategy Properties window, on the Properties tab, locate the Costs/Capitalization section:

FieldRecommendation
Commission RuleConfigured via the rule table — set your broker’s actual round-trip cost (including fees and exchange fees). E.g. ES is roughly $4–5 per contract round-trip
SlippageAt least 1 tick; 2–3 ticks for thin markets

The Commission field is defined through a Rule table (allowing tiered calculation by contract count or notional), not a single fixed number.

Even if the strategy looks great with zero costs, adding realistic commissions and slippage often crushes the edge to near zero. Always configure costs before evaluating a strategy.

Bar Magnifier and Look-Inside-Bar#

In the Strategy Properties window, on the Backtesting tab:

SettingDescriptionWhen to Enable
Use Bar MagnifierUses a finer resolution to simulate intra-bar price movement on the main resolutionAny strategy using Stop / Limit orders, or where multiple stops could trigger within a single bar
Bar Magnifier ResolutionTypically 1 minute or tickThe larger the main resolution, the more important this becomes

Without Bar Magnifier — assumed fill order

MultiCharts decides the intra-bar movement order based on whether Open is closer to High or to Low (independent of long/short direction):

  • If Open is closer to Low → assumed path Open → High → Low → Close
  • If Open is closer to High → assumed path Open → Low → High → Close

Reality may be the exact opposite, causing stops that “didn’t hit” in the backtest to actually trigger live.

Pricetime →HighLowOpenClose1234OpenHighLowClose
Case A: Open near Low
assumed path Open → High → Low → Close (High hit first → target triggers)
Pricetime →HighLowOpenClose1234OpenLowHighClose
Case B: Open near High
assumed path Open → Low → High → Close (Low hit first → stop triggers)

Actual live movement may be the exact opposite — within the same bar, an Open near the Low does NOT guarantee the price will rally first then fall. This is exactly why Stop/Limit strategies tend to backtest “too well” without Bar Magnifier enabled.

Stop vs Limit fill: MultiCharts assumes a Stop order fills as soon as the price is touched, but a Limit order must be crossed (penetrated) to be considered filled (just touching the limit price is not a fill). Live queue priority can cause Limit orders to remain unfilled.

Example: a daily strategy with SetStopLoss(10 * BigPointValue) and SetProfitTarget(20 * BigPointValue):

  • Without Bar Magnifier: which of stop / target triggers first depends on Open’s position relative to High/Low
  • With Bar Magnifier (1-minute): actual 1-minute movement determines which threshold is hit first

A common observation after enabling Bar Magnifier: a previously profitable strategy’s Net Profit gets cut in half — but this is the more honest number.

Intra-Bar Order Generation (IOG)#

In the Strategy Properties window, on the Properties tab (the same tab as Max Bars Back):

SettingDescription
Enable Intra-Bar Order GenerationAllows the strategy to place orders before the bar closes; the logic re-runs on every tick
ModeWhen to UseCaveat
IOG Off (default)Strategy decisions only at bar closeMatches live Bar Close mode — easiest to align
IOG OnFor tick-by-tick reactions or intraday chasingBacktests are much slower; live trading needs OnBrokerData handling, otherwise live and backtest diverge

Common pitfall: IOG is on, but the code doesn’t guard against repeated triggering on the same bar (e.g. If Close > X Then Buy), so the backtest fires multiple orders on a single bar. Pair entries with MarketPosition or EntriesToday(Date) checks to avoid duplicate entries.

Maximum Bars Back#

In the Strategy Properties window, on the Properties tab:

SettingDescription
Maximum number of bars study will referenceThe maximum lookback the strategy needs (e.g. Average(Close, 200) requires at least 200)

Set it too low and the strategy doesn’t execute on early bars; too high and you waste memory. Recommendation: the largest lookback used + a 50-bar buffer.

Optimization#

Optimization tests many parameter combinations and finds the best-performing set. Right-click the signal → Format Signals → select the signal → Optimize.

Two Optimization Algorithms#

AlgorithmApproachWhen to Use
ExhaustiveTests every combinationFirst choice when combinations < 10,000; fully reproducible
GeneticEvolutionary approximationUse when the search space is too large for exhaustive; result is approximate

Example: a 3-parameter strategy with 10 values each = 1,000 combinations → use Exhaustive. A 5-parameter strategy with 20 values each = 3,200,000 combinations → must use Genetic.

Optimization Target Function#

Do not use Net Profit as the optimization target — it overfits aggressively to a few outsized winners. Better choices:

TargetDescription
Profit FactorBalances profitability and stability
Custom Fitness ValueBuild your own, e.g. NetProfit / MaxDrawdown or a Sharpe-like measure

Result Analysis#

When the run completes, don’t simply pick the highest Net Profit row. Open the 3D chart (Optimization Report → 3D Chart) and look for:

  • Parameter Plateau: ideally several adjacent parameter sets all perform well, forming a stable plateau. A single sharp peak surrounded by cliff-like drops is almost certainly overfit
  • Parameter Stability: prefer a setting in the middle of the plateau, not at the very peak

Example: if MA lengths from 18 to 22 all retain at least 80% of the maximum Net Profit, picking 20 is more robust than picking the absolute peak at 19.

Walk-Forward Optimization#

Walk-Forward Optimization (WFO) is the standard tool for verifying that optimized parameters generalize to unseen data. The workflow:

[IS Training] → find best params → [OOS Validation with those params] → record OOS metrics
       ↓ window rolls forward
[IS Training] → find best params → [OOS Validation] → record
       ↓
... repeat for several runs ...
  • IS (In-Sample): training segment, used for parameter optimization
  • OOS (Out-of-Sample): validation segment using the IS-selected parameters; this is the honest performance estimate

To launch in MultiCharts: right-click the signal → Optimize, then in the Optimization dialog locate the dedicated Walk-Forward Optimization section (a full panel with IS/OOS ratio, Anchored/Rolling, Number of Runs, etc., not just a single checkbox) and configure it there.

Key WFO Settings#

SettingRecommendation
IS / OOS RatioCommon ratios are 4:1 or 3:1 (e.g. 12 months IS + 3 months OOS)
Number of RunsAt least 5 to be statistically meaningful
Anchored vs RollingRolling is the common default; Anchored is better when the market regime is stable

Reading the WFO Report#

The headline metric is WFE (Walk-Forward Efficiency):

WFE = (OOS annualized return) / (IS annualized return)
WFE RangeInterpretation
> 0.6The strategy may have a real edge (the industry-standard threshold is 0.5–0.6; using 0.6 is recommended)
0.3 – 0.6Marginal — proceed with caution
< 0.3Severe overfitting; do not trade live

WFE close to 1.0 isn’t automatically better. WFE > 0.7 should make you double-check that the IS performance isn’t itself terrible (if both segments are bad, WFE can still be near 1.0). Always read it together with the absolute returns.

Common Pitfalls#

Look-Ahead Bias#

The strategy uses information that wasn’t available at decision time. Common sources:

1
2
3
4
5
6
// BAD: decides on close and enters on the same bar's close
//      (with IOG off MultiCharts delays to Next Bar, but This Bar Close is unsafe)
If Close > Highest(High, 20)[1] Then Buy This Bar Close;

// GOOD: signal evaluated at bar close, executed on next bar's open
If Close > Highest(High, 20)[1] Then Buy Next Bar Market;

[1] references the previous bar’s value. Compare Highest(High, 20) and Highest(High, 20)[1] — the first includes the current bar’s high (future information), the second does not.

Overfitting#

Symptoms of overfitting:

  • Optimized equity curve looks unnaturally smooth
  • Parameter plateau is very narrow
  • Large gap between IS and OOS performance (WFE < 0.3)
  • More than 4 tunable parameters

Mitigations:

  1. Reduce the number of parameters (< 4 is best)
  2. Validate with Walk-Forward
  3. Verify the same parameters across multiple instruments
  4. Hold out a final OOS segment (the most recent 1–2 years) that never participates in optimization

Survivorship Bias#

When backtesting equities, if the data source contains only “currently listed” stocks, delisted stocks are excluded and the strategy performance is overstated. Less of an issue for futures, but stock-selection strategies must handle it explicitly.

Order Fill Assumptions#

MultiCharts assumes by default that a Stop order fills as soon as it is touched, while a Limit order must be crossed (penetrated) to fill. In reality:

  • Large Limit orders may only partially fill
  • Gap opens may jump entirely past Limit prices
  • Stop orders in low-liquidity conditions can slip far beyond the configured amount

Mitigation: increase Slippage and enable Bar Magnifier for tick-level simulation.

Insufficient Sample Size#

Total Trades < 30 produces statistically meaningless results. Mitigations:

  • Lengthen the backtest window (cover at least 2 full bull/bear cycles, ideally 5–10 years)
  • Run the same strategy on multiple instruments
  • Use a finer resolution (e.g. switch from daily to 60-minute)

Complete Workflow Example#

Walking through the full validation flow with a simple MA crossover strategy:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Inputs:
  fastLength(10),
  slowLength(30),
  stopPoints(10);

Variables: maFast(0), maSlow(0);

maFast = Average(Close, fastLength);
maSlow = Average(Close, slowLength);

// Decide on close, execute on next bar's open (avoids look-ahead)
If MarketPosition = 0 and maFast crosses above maSlow Then
  Buy("LE") 1 Contract Next Bar Market;

If MarketPosition = 1 and maFast crosses below maSlow Then
  Sell("LX") Next Bar Market;

SetStopLoss(stopPoints * BigPointValue);

Validation steps:

  1. Backtest settings: $5 commission, 1-tick slippage, Bar Magnifier on (1-minute), Maximum Bars Back = 100
  2. Single backtest: run once with default parameters; verify Total Trades > 100 and Avg Trade > slippage
  3. Optimize: fastLength 5–20, slowLength 20–60, stopPoints 5–20, target = Profit Factor
  4. Inspect 3D chart: locate a parameter plateau, choose a center-of-plateau combination
  5. Walk-Forward: 12-month IS + 3-month OOS, 6 runs, require WFE > 0.6
  6. Multi-instrument validation: apply the same parameters to at least 2 other instruments — performance must not collapse
  7. Held-out OOS: the most recent 6–12 months of data must never participate in optimization; run a final validation

Only after passing every step should you consider paper trading for a period.

Notes#

Backtest and Live Will Always Differ#

Even after every check, a backtest only approximates live performance — it never equals it. Reasons include: order queue dynamics, market impact, exchange limits, network latency, and feed differences. Always validate with paper trading before going live.

Recompile and Recalculate After Changes#

After modifying a strategy, recompile in Power Editor (Compile) and right-click the signal on the chart → Recalculate, otherwise the performance report still reflects the previous version.

Optimized Parameters Decay Over Time#

Market regimes change. Re-running the optimization and WFO every 6–12 months is reasonable, but re-optimizing weekly is itself a form of overfitting.

Saving Optimization Results#

The Optimization Report can be exported as CSV for further analysis in Excel or Python (e.g. computing Sharpe, Sortino, Calmar ratios).

Reference#

https://www.multicharts.com/trading-software/index.php?title=Strategy_Performance_Report

https://www.multicharts.com/trading-software/index.php?title=Bar_Magnifier

https://www.multicharts.com/trading-software/index.php?title=Intra-Bar_Order_Generation

https://www.multicharts.com/trading-software/index.php?title=Optimization

https://www.multicharts.com/trading-software/index.php?title=Walk-Forward_Optimization