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 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. For per-bar oversampling, use price data with
higher resolution than a bar period, f.i. M1 data with 1-hour bars. Oversampling
shifts the timestamps are 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. This allows to detect and eliminate start date/time dependence
of training or 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 to be added to the begin of a test or training cycle for per-cycle
oversampling. 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 cannot be used when the strategy relies on entering and exiting
trades at a certain time or date, 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 dependence 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