Price curve oversampling
Backtests become more accurate with more data and more trades. Since price data is always in short supply,
oversampling is a method to get more trades out of it. It requires price data in
higher resolution than a bar period, which is normally the case with M1 data and
bar periods of 1 or 4 hours. Oversampling generates several slightly different
price curves from the price data, any time with a different bar offset and thus
slightly different bars. The backtest or training is then executed with all
price curve variants, thus generating a multiple of the trades.
Oversampling factor of the simulation (default = 0 = no oversampling). When NumSampleCycles is set to a number n > 1, the simulation is repeated n times, and every time the bars are resampled 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. The performance result is then 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.
The number of the current cycle from 1 to NumSampleCycles.
Automatically set by NumSampleCycles.
- 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. 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 use daily or weekly bars or depend on opening and closing hours of a certain stock exchange.
- 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.
- When the ALLCYCLES flag is set, the statistics values inside the STATUS structs 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. The statistics values inside the PERFORMANCE struct are the average over all sample cycles.
- In the price chart, the trade symbols are taken from the last cycle. The equity curve is the average over all cycles.
- A description of oversampling with an example can be found on http://www.financial-hacker.com/better-tests-with-oversampling.
NumSampleCycles = 4; // 4 times oversampling
bar, BarOffset, NumWFOCycles, NumOptCycles, NumTotalCycles, ALLCYCLES
► latest version online