Number of stocks above their moving average for N periods
Author: RainManRam
Creation Date: 11/16/2009 12:10 PM
profile picture

RainManRam

#1

I'm just starting out with WealthLab and am having a hard time getting started. I'd like to be able to create a strategy based on multiple symbols, for example the Dow 30. The idea being to look at what the individual components are doing and then trade the DIA.

Can someone point me in the right direction or point me at an example of to do something like this?

Thanks,
Ray
profile picture

Eugene

#2
Ray,

Welcome aboard. Is this going to be a rule-based or code-based strategy? Can you decipher what "the individual components are doing"?
profile picture

RainManRam

#3

At this point I'm assuming code based since I think the complexity will be more than the drag and drop rules can handle (can I create new drag and drop rules?). I'll take either as an example though since you can convert the rules to code. I can write code so even a conversion of a rule based example to code would shed some light on it for me.

Thanks!
Ray
profile picture

Eugene

#4
There are numerous examples, but the phrase above isn't clear. The other components used as a custom index? Or something else?
profile picture

RainManRam

#5

Perhaps a simplified concrete example might help. Let's say I want to open a DIA position if 20 of the 30 dow components are above their 20 period moving average and have been so for 2 periods.
profile picture

Eugene

#6
Here's the example. However, note: you need to put DIA inside the Dow 30 dataset. Setting the context to a symbol in another dataset to create trades isn't supported, because we still miss the WatchList methods of the old WL4. But don't worry, DIA won't be included when calculating the number of stocks above the moving average:
CODE:
Please log in to see this code.
profile picture

RainManRam

#7


Thanks Eugene! That should get me going.

- Ray
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).