Oversampling

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:

NumSampleCycles

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.

SampleOffset

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 instead.

SampleCycle

The number of the current cycle from 1 to NumSampleCycles. Automatically set at the begin of any cycle.

Type:

int

Remarks:

Examples:

function run() {
  NumSampleCycles = 4; // 4 cycles per-bar oversampling
  ...

function run() {
  NumSampleCycles = 3; // 3 cycles per-cycle oversampling
  SampleOffset = 10;   // with 10 bars start difference 
  ...

See also:

bar, BarOffset, NumWFOCycles, NumOptCycles, NumTotalCycles, ALLCYCLES

 

► latest version online