While running "RSI Rotation" on S&P 100, I found it strange that no trades were generated.
When I looked at the bottom left-hand bar, I see a "Need update: BUD, LEH, WB,"...
Need an update, indeed - these stocks have gone bankrupt or have merged/been bought out - which makes me think seriously about survivorship bias? Who knows? In another year, maybe stocks like C and BAC will be kicked out of the S&P 100 and replaced with something else.
This makes me suspicious of the results from any strategy where I am "buy on the cheap" - stocks which die would certainly be kicked out of the S&P 100 making any set I pick, except the set from 10, 15, or 20 years ago (where-ever I start the backtest).
Size:
Color:
Sometimes stocks go to zero pretty quickly, but normally it's a gradual process. The RSI Rotation strategy takes advantage of this (and volatility), and you'll noticed that it did quite well (at least with the Dow 30) during the dot com bust. BUD, on the other hand, rose quickly when purchased by InBev, and it's unlikely to have caught that one with a "buy oversold" strategy.
Anyway, for sure, survivorship bias counts, and there are methods to use
dynamic watchlists. See
FAQ #5. The same idea can be applied in Version 5.
Size:
Color:
It occurred to me that if the system still holds a position in a stock gone for good (i.e. absense of exit signal), exit can be forced on the last bar - just for simplicity?
CODE:
Please log in to see this code.
Size:
Color:
Wow - both tips are EXCELLENT.
1. FAQ #5 for dynamic watchlists
2. Liquidating dead stocks
Now, I just have to find a source for historical components of S&P100, DJIA, etc...
Thanks for the tips!
Just a couple quick questions:
1. Will doing FAQ #5 get rid of the "Need update: BUD, LEH, WB," error so the strategy will run to completion? Or will the "more complete solution by kgo thread" be needed to get rid of this error?
2. Is something like a #include allowed for FAQ #5 so I can re-use the code for every strategy run?
BTW, the move to C# is >FANTASTIC< - with built-in Intellisense in the editor, the time needed from idea-to-implementation has dropped dramatically from version 4 to 5 - at least for those of us who are not experts in coding up the original Pascal-like language.
Examples like the RSI Rotation strategy are great for cross-sectional strategies (as opposed to standard technical indicators which are along one specific time-series).
Keep up the great work!
Size:
Color:
QUOTE:
2. Is something like a #include allowed for FAQ #5 so I can re-use the code for every strategy run?
Sure, what allowed in C# is allowed in WealthScript: the idea is to store reusable procedures/functions in a compiled library. Take the open-source Community.Components for instance.
Size:
Color:
Here's another example of a historical backtest with
Norgate Data. Since a rotation strategy runs in a DataSetSymbols loop, this one's slightly more complex to get the NorgateIndexConstituentTimeSeries for each symbol. Like the RSI series, it's accessed and stored in a Dictionary for a quick look up.
Notes!
1. You need Norgate Data and the
Norgate Data Provider for this script!
2. As coded, you must run this on the S&P 100 Past and Present symbol DataSet - click only 1 symbol to run (AAPL, for example).
3. Code for 5-symbol rotation, therefore choose a 20% position size and perhaps 1.1 : 1 margin for some leeway.
CODE:
Please log in to see this code.
Size:
Color: