- ago
Example: I set the period of the backtest as follows: 01.01.2000 to 29.12.2023

The benchmark S&P 500 (^GSPC) has achieved 200.26% in exactly this period. With my strategy I am therefore fighting against 200.26% of the benchmark in the same period. However, my strategy only entered the market on 08.03.2002.

Wouldn't it make sense to calculate the performance of the benchmark from the date of the first entry of the strategy instead of using the date range?

0
231
Solved
7 Replies

Reply

Bookmark

Sort
Glitch8
 ( 13.17% )
- ago
#1
I think it's unfair to the benchmark to arbitrarily start it when your strategy happens to make its first trade. Instead, it should start at the first bar that your strategy might possibly be able to make its first trade.

Assign a value to StartIndex in the Initialize method to get this working. For example, if you use a 200-bar moving average, assign StartIndex = 200.

This is handled automatically in a Building Block strategy.
0
Best Answer
- ago
#2
If I have a strategy where I simply want to buy the Spy at Close > SMA 200*1.03%, and I start the strategy on 01.01.2001, it is simply the case that the first entry takes place on 08.03.2002. So it makes no sense to compare the performance strategy with start on 08.03.2002 with B&H from 01.01.2001.
0
Glitch8
 ( 13.17% )
- ago
#3
I obviously disagree. It makes perfect sense not to penalize the benchmark in this way.

What if your trade exits in October, do you want to stop the benchmark there too? What’s the point of the benchmark then??
1
Cone8
 ( 24.02% )
- ago
#4
QUOTE:
So it makes no sense to compare the performance strategy with start on 08.03.2002 with B&H from 01.01.2001.
Jacques, the part that you're missing is that the Benchmark period does not start on 01.01.2001... it's starts on the 200th bar (the StartIndex as Glitch pointed out in #1), which would be 22 Oct 2001. If you look at the chart, that's where your SMA 200 plot starts.

Consequently, the benchmark trade begins from the open of 23 Oct 2001. This includes dividends paid to the benchmark symbol if you have "Collect Dividends" enabled Backtest Preferences.

Aside -
With a C# Coded strategy there's a way to start an indicator like an SMA 200 right from the beginning of the loaded data range. It's mostly useful to do it for intraday strategies that use daily indicators with long periods.

Run this code and look where indicator starts -

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript123 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) {          // Load all there is          BarHistory allBars = WLHost.Instance.GetHistory(bars.Symbol, HistoryScale.Daily, DateTime.MinValue, DateTime.Now, 0, null);                    // create the indicator          sma = new SMA(allBars.Close, 200);          // now, sync the indicator with the chart and plot it          sma = new TimeSeriesIndicatorWrapper(TimeSeriesSynchronizer.Synchronize(sma, bars));                   PlotIndicator(sma, new WLColor(0, 0, 0));          // Now you can start from bar #1          StartIndex = 1; } public override void Execute(BarHistory bars, int idx) { }              IndicatorBase sma; } }


1
- ago
#5
@ Cone

That with the beginning after the 200 bars would have been my next question anyway because I noticed it very well.

This means that in a building block strategy you cannot set the data range to start directly with the first bar (in this example on 01.01.2001)?
0
Cone8
 ( 24.02% )
- ago
#6
Sure it can start there if you don't use indicators, which usually require more than 1 bar of data to be valid. But I'm afraid your missing the point.

If you want the benchmark to start at 01.01.2001, and you have an indicator that requires 200-bars to calculate, then find the date that is 200 bars before 01.01.2001 and configure the data loading control to start there (about 15 March 2000).
0
- ago
#7
thank you
0

Reply

Bookmark

Sort