PDA

View Full Version : A starting point...



ChemEng
12-06-2006, 06:42 AM
As a place to start discussion, I think fabijo has a pretty good one--thanks again for posting it! (His spreadsheet can be found here: http://mircats.com/fabio/Fab.TSP.Trading.beta.xls) It takes the TSP share prices and then computes the MACD (References at http://stockcharts.com/education/IndicatorAnalysis/indic_MACD1.html) for each day. Then decides which fund has the greatest positive %age change and recommends a 100% move into that fund.

There have been several recommendations and comments made about this system on the boards that may be worth incorporating. These certainly arent criticisms, just a point for us to launch from.
1. The can suffer from the inherent lag built into MACD.
2. It does not incorporate any penny g-fund strategy.
3. Instead of looking at magnitude of MACD %age changes, look at direction of MACD.
4. It does not include any effects from the $ index.
5. Fabijo had this insightful comment: the MACD automatically transition to using faster EMAs as the current price gets closer to longer term moving averages.
6. It uses TSP share prices, instead of market prices.
7. It doest not consider VIX.

These are areas that are ripe for exploring, but I think a better starting point is with the simple MACD spreadsheet as its listed above. Are there places for improving this decision metric? Are there places where the decision rule recommended a poor transfer? Can we improve on that?

I have several thoughts about it that I will post later today--probably tonight. But I wanted to get everyone who wants to work on this pointed in the right direction... Look forward to your thoughts!

fabijo
12-06-2006, 06:58 AM
I'm gonna have to give you another link for the spreadsheet, because I've made plenty of changes since then. Instead of one set of EMAs, I made it possible to change the EMAs for each fund. I also changed the % of MACD change to a slope:


current MACD Histogram - average MACD Histogram for past three days

Also, I added the Bollinger Bands to the spreadsheet. For the Bollinger Bands, I made it so you could choose the moving average for each fund. Then, I made a columns for each bollinger band to calculate the width of the band. I then have another column for each fund that calculates:

current width - average of past three widths

Using that number (positive if bollinger is widening), I added it to the formula for the MACD so that it changes the multiplier for the EMA. It seems to be working, but I think I need to do something else so that I can be specific about how to change that multiplier.

More later.... I'm already late for work..

ChemEng
12-06-2006, 11:35 AM
Have you had a change to backtest the new changes?

We need to work out a system for making sure we set a common link for the latest version of the spreadsheet. As it is, its too big to put up here as an attachment and its only going to get larger as it develops. Can you post a link to where you are at currently with it?

ayla
12-06-2006, 11:50 AM
I think it is great of fabijo to provide his system with precise details about the logic. But I never got an answer to my question about his gain since January 2006. When I calculated it last week, seemed like it was 13.8% (or something like that.)

Since the TSP tracker tracks since January, I think it would be useful for new strategies to do the same. Of course, probably a date for long term tracking (which I think Fabijo used 2003 or something like that) is also useful, don't want to neglect that but I would like to compare apples to apples and having a gain since January 2006 would do that for me (especially considering the downturn we had starting in May/June which the VIX 200 day criteria helps very nicely circumvent.).

If you ever decide to use VIX data, I can help by providing VIX data that is date matched to TSP, let me know. Once the VIX data is collected for the right period, it is a fairly simple "INDEX" formula to bring in only the VIX numbers that correspond to a TSP date. Let me know. Or I guess we can go the other direction as well if there turns out to be more market data we want to bring in, just match TSP to market dates.

The problem that makes market dates more complicated is the Asian markets. They have a huge number of holidays(apparently) so there now becomes holidays on both sides to consider, both TSP and N300 (..etc.). Not impossible to do but just more data to manipulate.

Thanks ChemEng for getting this going and also for being willing to make all the nitpicky little decisions that need to be made, that is probably the hardest part. I don't expect a consensus on everything, would take too much time and would delay end-products IMO.

fabijo
12-06-2006, 12:38 PM
I apologize for the delay in responding. The working spreadsheet is much smaller. I deleted all the extra sheets I had where I was testing what would have happened in all the different fund choice scenarios. Here is a link to the file:

http://mircats.com/fabio/Fab.TSP.Trading.beta.xls

A few things to note. You can now choose the EMA s for each fund individually. It still does not consider the F Fund a choice, because it kept choosing that when stocks went up faster. I updated the fund decision making to use the slope of the MACD histogram (using the current value - average of past 3 values), instead of the % change. I also added the bollinger calculations, but updated them to give you the choice of SMA. I didn't update it to choose how many standard deviations you want the bands to be. They are always set to 2.

Ayla, I'm sorry I never really responded to your question. I keep changing the values of the EMAs to see how I could have avoided a loss in June and July. I did have some that worked, but I can't remember what that was. I still need to get a better variable going to measure how close to long term Simple Moving Averages we are. The bollinger band is only being used for its width. I can probably get better at using the band's distance from the current price.

To add up percentages for any time period, where one percentage is the percentage of the previous percentage (like February % change is a percentage of January's) you do this:

(100*((1+%a)*(1+%b)*(1+%c)....) - 100) / 100

If it comes up with something like .223, then you have 22.3%

fabijo
12-06-2006, 12:42 PM
Have you had a change to backtest the new changes?



I haven't. I've been using May - July as my bear testing. I'm still not satisfied because I have to adjust the EMAs manually to get good returns during that timeframe. I'm looking into some logarithmic functions and might be able to implement them by next week. Tonight, I've got to make a program for my C++ programming homework. Then I'll be travelling this week.

fabijo
12-06-2006, 02:15 PM
Something I just thought I might try tonight. During longer term uptrends (like when 50 SMA is above 100 SMA, or whatever numbers you want), I could make sure the choice is only between stocks. But during downtrends, I can add G and F to the choices.

ayla
12-06-2006, 08:14 PM
Related to what I've posted elsewhere (in the form of a summary),
I've attached a spread sheet here which shows backtesting that shows gains for S fund from January thru Nov totalling 25% and gains for I Fund for same period totaling 28%. The totals are in the final rows.

Strategy here is very very simple. If VIX is below it's 200 day average, results show staying in the market at fund of your choice being held long. If VIX is above its 200 day average, position is changed to no position (G fund if you will though I haven't counted any extra pennies that might have been gained). Summary: percent gains simply go static if VIX is above and become dynamic based on selected fund.

I added an extra day delay (different from my summary info posted earlier) knowing the problem we have with IFT deadlines so I believe these results are somewhat pessimistic.

Note all the static entries for May 9th thru Aug 16th. In a year where there isn't a serious downturn such as this year, I'm not sure results would be as impressive but I'm thinking I could do a whole lot worse.

fabijo
12-06-2006, 11:09 PM
ayla -

Thanks for sharing this. I'm tinkering with it now, but I should really be doing homework! :nuts:
Yes, it looks like this would have worked great for this year. I put in VIX data into the trading algorithms from 2003 to now, and used the 200-day sma as the reference. I did figure out a way to include the F fund as a choice without it ruining the returns. I now have two sheets on the workbook. One includes the VIX as part of the decision making process and the other does not.

http://mircats.com/fabio/Fab.TSP.Trading.beta.xls

One thing I was trying to play around with was differences between the moving averages of the VIX. If you do not care about using two moving averages, just change the first VIX SMA (lower in value) to zero. If you play around with the SMAs for the VIX or if you play around with the EMAs for each of the funds' MACD, you'll get all different kinds of results.

fabijo
12-07-2006, 01:06 AM
Here's a newer version that has tests of 1998 to 2003 in it. It gives you a 137.83% return from December 1, 1998 to December 31, 2003! Check out my account talk thread for a little info:

http://mircats.com/fabio/Fab.TSP.Trading.alpha.xls