Custom index on-the-fly
Author: asurapan
Creation Date: 10/20/2008 10:16 PM
profile picture

asurapan

#1
is there a basic script that I can run that can create an index from a watchlistbased on specific percent allocations. For example:
25% large cap
15% small cap
10% emerging markets
50% bonds

ideally something where I can play around with the percentages as variables.
profile picture

Eugene

#2
Looks like that an existing tutorial for WL4 needs a C# facelift...

Create an Index based on a group of Stock
profile picture

Cone

#3
Assuming use of a fundamental data, you could identify large and small caps, but how would you identify the properties of a symbol so that you knew it was "emerging market" or other? It seems that you'll need to read in that data from an external source, which means you'll need to create that data for each symbol in the WatchList. Creating the index is the more or less the easy part since it's only programming.
profile picture

asurapan

#4
Cone, I was being too general in my original post. Basically I want to try to replicate various fund asset allocations. Essentially through the use of ETFs or Index Funds is my intention. So, using the original example:
25% SPY
15% IWM
10% EEM
50% SHY
profile picture

Cone

#5
If it's just 4 symbols, use GetExternalSymbol for each one and create the index series with a little series math. Example -

CODE:
Please log in to see this code.
profile picture

Eugene

#6
Here's a more convoluted way for asurapan to place the created index in Wealth-Lab's global memory to be easily accessible in other strategies:

CODE:
Please log in to see this code.
profile picture

asurapan

#7
is there a way to then add some Buy code so that I can see the results in the EquityCurve, Drawdown, and ByPeriod?
for example, how would I be able to run the follwing code on the "My Index"?

CODE:
Please log in to see this code.
profile picture

Eugene

#8
Not sure I understand: myIndex is just a data series. How can you buy a SMA (for instance) at market?
profile picture

asurapan

#9
strictly hypothetical. i just want to see what performance and risk metics would look like for certain asset allocations. Perhaps myIndex isn't the best way to go about it. I'm just trying to play around with different asset classes and different weightings.

let me be more specific. Lets say I had 10 different ETFs in a dataset. Lets say I want to run a strategy where I only buy an ETF when an EMA Crosssover occurs.

Normally this would be very simple as I could just run the strategy on the entire dataset. But this assumes that each ETF will be allocated 10% of my capital. But what if I want 5% for ETFa and 20% for ETFb, 15% for ETFc, etc.?
profile picture

Eugene

#10
QUOTE:
Normally this would be very simple as I could just run the strategy on the entire dataset. But this assumes that each ETF will be allocated 10% of my capital. But what if I want 5% for ETFa and 20% for ETFb, 15% for ETFc, etc.?

You'll easily handle it once advanced position sizing support is back again in 5.4 or later build.
QUOTE:
strictly hypothetical. i just want to see what performance and risk metics would look like for certain asset allocations. Perhaps myIndex isn't the best way to go about it. I

On a second thought, you could create a Bars object using myIndex (even saving the resulting object for later use; see Bars.SaveToFile and Bars.LoadFromFile in the QuickRef) and use SetContext to trade the virtual symbol.

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).