Backtests become more accurate when more data is available and more trades can be
opened. The problem: price data is normally in short supply. Oversampling the
bars is a method
to run multiple test cycles on slightly different price curves that are derived
from the original curve and contain the same inefficiencies. This produces more
trades, generates more realistic backtests, and allows to evaluate the effect of
price curve randomness on the system performance.
Oversampling can be applied to training or backtest, either per-bar
or per-cycle. Per-bar oversampling requires price data with
higher resolution than the bar period, f.i. M1 data with 1-hour bars. Oversampling
shifts the bar begin by a fraction of the bar period on any cycle. This
results in different bars and - dependent on the strategy - more or less different trades with the same price curve.
For per-cycle oversampling,
a time offset is added to the start of any cycle. It is normally used to detect start date/time dependences
of the trading system in backtests.
A description of per-bar oversampling with an example can be found on
http://www.financial-hacker.com/better-tests-with-oversampling. The following
variables activate and control oversampling:
Number of oversampling cycles (default = 0 = no oversampling).
When set to a number n >
1, the simulation is repeated n times. For per-bar oversampling,
the bars are resampled in any cycle with different BarOffset
values. This generates a slightly different price curve for every cycle, while
maintaining the trend, spectrum, and most other characteristics of the curve.
For per-cycle oversampling, the SampleOffset
is added to the start time of any test, training, or WFO run. The performance result
is calculated from the average of all cycles. This way more data for test and
training is generated and a more accurate result can be achieved.
Time offset in bars for per-cycle oversampling. The begin of a test or training cycle
is automatically shifted by that time at any cycle. If at 0 (default), per-bar oversampling is used
The number of the current cycle from 1 to NumSampleCycles.
Automatically set at the begin of any cycle.
- On bar periods of one or several hours, oversampling is often useful to
get enough trades for properly optimizing and testing a strategy. Good values
for NumSampleCycles are 2..6 for per-bar oversampling.
Even higher oversampling factors won't increase the accuracy much further.
- Oversampling starts with the highest offset and ends with offset 0. For
instance, on a 60 minutes bar period and NumSampleCycles = 4,
the 4 cycles get bar offset 45, 30, 15, and 0.
- Oversampling must be activated before the first
asset call. It cannot be used when BarOffset
is otherwise set or when the strategy is based on certain times or dates, f.i. strategies that always trade on the first
of any month or on market opening or closing time.
- For a histogram of the performance dependent on start time, SampleOffset
in combination with NumTotalCycles
can be used.
- Oversampling increases the memory footprint, similar to the
- The performance of the separate cycles is displayed in the
performance report under Cycle performance.
High performance differences between cycles normally indicates an unstable strategy.
The global statistics values are the average over
all sample cycles.
- When the ALLCYCLES flag is set, the component specific
statistics values and the
portfolio analysis are the sum over all bar cycles;
they keep their values from the last cycle when a new cycle is started. Otherwise
they are reset at the begin of every cycle and thus reflect the last cycle at
the end of the simulation. The log contains all cycles when
ALLCYCLES is set; otherwise it contains only the last
- In the price chart, the trade symbols are taken
from the last cycle. The equity curve is the average over all cycles.
NumSampleCycles = 4; // 4 cycles per-bar oversampling
latest version online