Log in to see Cloud of Tags

Wealth-Lab Wiki

Backtesting with Dynamic (Evolving) WatchLists



public class symbolList : List<object>

public IndexHelper(string folder, string index, Bars bars)

public DateTime FirstIndexDate(int bar) public DateTime LastIndexDate(int bar) public symbolList WatchList(int bar)

Parameter Description

folder Location of files containing historical watchlist data
index Index name
bars Current Bars object


As a protection from survivorship bias, traders can use historical data on index components, when they entered, exited or even re-entered an index. The IndexHelper class scans a folder of text files that have an index name and date in their names (e.g. DAX_20010702.txt = DAX Index components for 2001/07/02).

Each of those files holds a list of symbols that were in the index at this date. The list is one symbol at each line. The assumption is, that each symbol in the list is active until the next file. If it still appears it was still in the index, if not it was dropped.

The IndexHelper returns the index composition (WatchList) on any given date (bar) within the first and last available dates (which are exposed as FirstIndexDate and LastIndexDate, respectively.) The WatchList is an object of type symbolList which is simply a generic list of type string.


To run this sample code, you need a collection of files placed in C:\Data and named like below, containing a history of index components:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { IndexHelper ih = new IndexHelper( @"C:\Data\", "DAX", Bars ); DateTime firstDateAvailable = ih.FirstIndexDate(); for(int bar = 1; bar < Bars.Count; bar++) { if (IsLastPositionActive) { //code your exit rules here } else { // Test it if( Bars.Date[bar] >= firstDateAvailable ) { symbolList sl = ih.WatchList( bar ); if( sl != null ) { foreach (string s in sl.symbols ) PrintDebug (s); } } } } } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

ScrewTurn Wiki. Some of the icons created by FamFamFam.