Currently I am experimenting with a top down approach that starts with checking if the SPY is above a 10 month moving average (which can be handled easily using "foreign"). If it is then I look at the sectors and select the top x number based on their relative performance and if their performance is also greater than the SPY. A portion of equity is placed on trades in the sector ETFs. Then industry group ETFs within the winning sectors are checked for relative performance and an additional portion of equity is traded on these. An optional final step would be to trade the remaining equity on individual stocks selected in a similar way.
Currently looking at re-balancing between sectors and industry groups on a monthly (maybe quarterly) basis. If individual trades get stopped out between re-balance periods, new trades would be placed after code reevaluates selections.
It would be really great to be able to automate the whole process. Then it would possible to test changes and see the resulting complete equity curve including gains, losses, and draw downs.
The steps involved would be.
- Check for up trending SPY (SPY > MA(10 months)
- Get the top X sectors based on relative strength to the SPY and trade 20% of equity divided equally.
--- This far can be handled by selecting a watch list of sector ETFs and running code against it. - Using the top X sectors selected above, select the top Y number of industry groups for each selected sector and trade 30% of total equity split equally between them using industry group ETFs.
- Repeat step 3 for the final 50% of equity replacing sectors with industry groups and industry groups with individual stocks.
--- This is where I don't know how to automate the process.
I think the amount of equity allocated to sector ETFs, then industry group ETFs, and finally individual stocks could be handled using static variables.
But don't see a way to select different symbol filters to handle branching based on sector and industry groups. Thought batch processing might be helpful, but did not see a way to select different symbol filters there either.
After a periodic analysis and re-balancing the results might something like this.
SPY is greater than MA(10 months)
Top sectors: XLK, XLF, XLC, XLI but limited to XLK and XLF and XLC because max is 3.
Top industries in XLK: CIBR, SOXX, IGN, FDN but limied to CIBR and SOXX because max is 2.
Top industries in XLF: KBE, KIE, PGF but limited to KBE and KIE because max is 2.
Top industries in XLC: none because no industry ETFs with adequate volume
Sector Trades 20% of equity: XLK 6.7%, XLF, 6.7%, XLC 6.6%
Industry Trades 30% of equity: CIBR 7.5%, SOXX 7.5%, KBE 7.5%, KIE 7.5%
Company Trades 50% of equity: (similar allocations as above but at individual stocks level)
To complicate things further, I would ultimately would like to explore trading other assets via ETFs such as bonds using a similar process if the SPY failed the MA(10 months) test.
Does anyone have a suggestion how to implement the whole process in an automated way? I can do it manually by looking at the results of each step and branching accordingly, but evaluating the overall results manually is cumbersome and time consuming. Looking for a better way.