This month in Stocks and Commodities magazine (The title of the article is Playing with Numbers by Domenico D'Errico) an algorithm for trading was presented that:
1. On a weekly basis
2. If a red candle forms (close - open < 0), buy security
3. Sell after 12 weeks
I made one very minor changes:
1. If leverage > desired_leverage sell to bring to desired_leverage
Because QT doesn't have GTC orders there is a lot of code that pollutes meaning that needs to be written.
1. If partial fill reissue order for remaining shares
2. If failed order try to reissue it
Enhancements
1. More than one stock is allowed to be traded. Statically allocated to 1/number_of_stocks as a percentage of portfolio.
This algorithm for SPY from 2002 thru 3/21/2017 outperforms the SPY. The drawdown is still too high to be useful but it is an interesting concept.