AAPL $31,000,000 trading strategy, equity curve

AAPL $31,000,000 Algorithm

This AAPL trading strategy would have given a return of $31,712,009 for every dollar invested in December 1980. That's 123,000 times better than buy-hold, with nearly four times the annualized return (61.4% vs 16.7% for buy-hold) and roughly half the drawdown which  amounts to over six times better reward/risk than buy-hold.

AAPL $31,000,000 trading strategy: Table of results

AAPL $31,000,000 trading strategy: Table of results

This is a variation of the MASC BAO algorithm which I have published before,  except this time the buy point is related to a Bollinger Band instead of just the sell price. I found it using SignalSolver.

Here is the strategy:

Description of the AAPL $31,000,000 trading strategy

Description of the AAPL $31,000,000 trading strategy


In this case the Bollinger band is the 7 period StdDev of median prices (monthly (H+L)/2), and the band is built around the last sell price, not the usual method of building it around a moving average. A little unconventional but it worked wonderfully. Algorithms with buy signals based on sell price often get stuck, but this one didn't. Sell signals were based on a raw Percentage Band built around the monthly median (H+L)/2 prices, just like the original version of this.

Here is the equity curve:

AAPL $31,000,000 trading strategy, equity curve

We are looking at quite a bit of reinforcement on buy signals, but sell signals tend to come in ones or twos. There are some dual signal months but not too many. Dual signals will trigger a trade for this algorithm.

Moving onto the scans, you can see that there is a single area of profitability:

Annualized return vs. buy and sell point for the AAPL $31,000,000 trading strategy

Getting the buy or especially the sell point wrong would have led to a complete loss, as this algorithm was run Long and Short (you were either long or short at all times). Here's the entire parameter surface, for completeness:

AAPL $31,000,000 trading strategy, parameter surface

A bit of a steep sided mesa, but a reasonably large plateau.

Since I found it in June, the algorithm has added about 3%, but it hasn't traded and is still long.

Here are the trades: AAPL.M4 List of trades





AAPL MASC BAO Update Aug 4th 2017

The algorithm has added around 40% since publication in Dec 2016, return on $10K would now be $432,155,847,777 . There have been no signals or trades and the position remains long.

AAPL Monthly Trading Algorithm MASC BAO $432,155,847,777 return for $10K initial investment, update 8/4/2017

AAPL Monthly Trading Algorithm MASC BAO $432,155,847,777 return for $10K initial investment, update 8/4/2017


Multi-algorithm results for UWTI

Oil had a rocky year, lets look at how our multi-algorithm approach worked on an oil related stock, UWTI (VelocityShares 3x Long Crude Oil ETN). In this post, I'm just going to summarize the results:

Briefly, the method used is to run SignalSolver to find trading systems which worked for a 250 day period, then run these trading system against the data immediately following the 250 day period to see how they performed. This is known as out-of-sample testing as none of this following data is included in the optimizations.

The methodology is identical to my previous posts. If you need more details you can download the results spreadsheets, or download SignalSolver and run the optimizations yourself. I have omitted the result for the Return optimization on the PB band this time because I think we have established that the Figure of Merit optimizations usually work better. They do here.

The idea is behind multi-algorithms is that using a single algorithm is risky, but running multiple algorithms at once averages out your risk and leads to more consistent and more efficient (since you are sometimes out of the market) results. Here, we averaged over the top 4 algorithms for each period.

You can see that the multi-algorithmic approach gave very good results for the 25 day (5 weeks of trading) and 50 day runs. If you look at the buy-hold profile you can see that you would have had a rough time guessing long and short entry and exits to get the same results. Not saying it couldn't be done, but using the multi-algorithmic approach would have given nice returns for UWTI with absolutely zero guesswork. And its based on sound numerical analysis, not hunches and tweets. Is anybody listening? 🙂

Multi-algorithm tests for AMZN

Today I will be looking at some very interesting results of multi-algorithm testing on the stock AMZN (Amazon). The idea here is to use SignalSolver to find multiple trading systems which performed well in the past, then run those systems simultaneously on out-of-sample forward data to see what would have happened had you followed them in real life. We do this for up to 8 algorithms, for three timeframes.

AMZN: June 2015 to June 2016 Return Optimizations

Firstly lets look at the results of looking for trading systems which were optimized for data in the 6/19/2015 to 6/15/2016 time-frame (250 trading days), chosen only because it was 100 trading days prior to the date I pulled the price data, and I was looking at the subsequent 99 day performance. Here's how buy-hold did in that time-frame:

Initially, I simply optimized for Return, that is I looked for trading systems which gave the best return over the entire June '15 to '16 time period, then looked at how each of them did in the subsequent 10, 25, 50 and 99 days. Here's that result:

The "250 day AR" is the annualized return of each trading algorithm found, without a time machine these returns are purely academic and are just used for ranking. The "End State" is shown because it indicates whether the algorithm was bullish or bearish on the stock on the last day of the optimization. In this case 7 of the 8 top algorithms were bullish (L) so for all the out-of-sample results, the start state was long (see the methodology posting for more information on this voting system).

These numbers are all over the place, so lets average them to see if we could have run multiple algorithms at a profit:

The leftmost four bars shows the result of running just the top algorithm (BMO BCO). Moving right, we add more and more algorithms into the mix, until at the rightmost bars we are looking at the results of running 8 trading algorithms simultaneously. So averaging worked to our advantage in this case.

AMZN Figure of Merit Optimization on June '15-'16 data

Optimizing the trading algorithms simply for returns can give you trading systems which don't do very well moving forward, we've seen that over and over in these pages. Often these trading systems exploit price changes in a small timeframe, and quickly go sour as time advances. Accordingly, I revamped the optimization to look for algorithms which gave more consistent returns over time (again, see the methodology here). Here's that result:

You'll notice its a completely different set of algorithms, with a much lower 250 day AR than the Return optimized set and much higher FOMs (Figures of Merit--the optimization parameters). Notice these algorithms are quite closely related to each other, more so than the Return optimized set. Accordingly, when you set about averaging this lot, here's what you get:

AMZN FOM Optimization for Jan '15 to Jan '16

Subsequent to the Jan '15 to Jan '16 timeframe, AMZN prices changed such that a $10K investment had this Profit/Loss profile:

Would SignalSolver be able to find the correct exploits? Here's the results of the FOM optimization:

All of these algorithms were bullish at the end of the optimization period, but most went short at the end of January '16 when AMZN prices dropped suddenly. Then they went long around 2/9/16 to capture the partial recovery. And the averaging result:

Ugly if you had run the just the top ranking algorithm, but good if you had averaged over 2 or more algorithms. Unusual for the algorithms to stay profitable for the 99 day, but here we see it. Overall a good result.

AMZN Sept '14 to Sept '15 FOM Optimization Results

Finally, lets wind the clock back another 100 trading days and take a look at the Sept '14 - Sept '15 result. Here is the buy-hold:

Here are the results:

Again, quite a different set of algorithms. Vote was bullish, so they were all long to start the out-of-sample period. Most of the algorithms got it right and stayed long. Curious that the best FOM algorithm got it wrong again. Here's the averaging results:

More on this later. Going for a bike ride in the desert now 🙂

Summary of Signalgorithm trading strategy Oct 2016

Summary of Strategy Performance Oct 2016

This update covers 26 strategies published 2/10/15 through 9/18/15. For the analysis we measure the results of investing $10K in each strategy on the day of publication. 17 of the strategies made a loss over the entire period, however 5 of these were strategies that broke down after showing a profit.

Overall Results vs Hold

Total return on all the strategies as of Oct 2016 ($10K starting capital) was $4600 or 1.8% of capital. This compares with a loss of  $10,740 (-4.1% return) for buy-hold (or a gain of $10,740 for short-hold).

Successful Strategies

9 strategies ended the period with a profit, (BRK,GOOGL,TSLA,TQQQ,DUST,AAPL,PANW,MU,LRN). The combined profit was $36,280 or 40.3% of capital. We will continue to track these strategies.

Partially Successful Strategies

5 strategies (TQQQ,UWTI,NUGT,GILD,MSFT) made at least a 10% profit for a period (typically 100 days) then went on to make a loss over the entire period. Combined opportunity for profit was $28,377 (56%), final loss was $16,766 (33.5%), $10,000 of which was due to UWTI. These strategies will no longer be tracked.

Failed Strategies

There were 12 failed strategies (DIS,GLD,GLD,AAPL,TNA,TNA,FAS,IBM,GOOGL,SPY,WMT,MSFT) losing a combined $14,914 or 12.4%. Losses ranged between $109 through to $3786 for GOOGL. These strategies will no longer be tracked.

Best profits and worst losses

If a single exit for each strategy was timed perfectly, the best case profit for the strategies would have been $92,407 (35.5%). Worst case loss for the strategies was $73,490 (28.3%). Best case gain or loss for buy-hold/short-hold was $115,319--achieving this would have required correctly picking long or short and exiting each at the optimum time.

Strategies vs. 50 day MA crossover strategy

Strategies are sometimes compared with the results of a benchmark SMA crossover algorithm which buys when the price goes above a SMA and sells when the price crosses below an SMA.  We compared the strategies with the performance of SignalSolver algorithm AMC 0% BMC 0% using 50 day, 10 week or 3 month (H+L)/2 averaging. AMC BMC gave a loss of $73,490, compared with a gain of $4600 for the strategies presented here. 16 strategies beat the SMA crossover strategy.




DUST Daily Trading Strategy

This trading strategy is for stock symbol DUST the Direxion Daily Gold Miners Bear 3X ETF. It is the complementary stock to NUGT which I analyzed last week. Its not hard to find strategies which would have exploited the intense volatility of this kind of security, if you have access to an optimizing backtester. The strategy presented here gave good returns and reward-risk. Most of the returns were in the period Feb 2013 to Nov 2013, in which period $10K would have turned into $750,000. By Nov 2014, the investment compounded would have been worth $5m and since then until now (Mar 2015) it would have turned into $13m (list of trades). It will be interesting to see if the growth continues. I wouldn't expect it to, given the inconsistent performance, but you never know. In contrast, buy and hold lost 20% over the same period.

The strategy itself can be read off from the table below, its a daily trading strategy which means that you would have had to attend to it on a daily basis. It would have taken a few minutes a day to work out the signals and enter the orders. Note that you would have to short the stock if you were long and a sell signal showed up. Using NUGT as the shorting vehicle would have given different results.

Just a reminder; don't expect to implement this kind of algorithm and get similar results. I'll be tracking it on paper and give updates, so watch this space.

This strategy was corrected 1/1/16 to account for an error in the short-side returns.



Update 1/1/16

This strategy did OK after publication. For the period 3/24/15 to 12/29/15 the equity and stats are shown below:


DUST-D Equity 1-1-16

DUST-D Table 1-1-16

The optimum buy and sell points for this period would have been 4.13% and 8.45% (returning $66,246).

Update 6/23/2016


Since the original posting in March 2016, this strategy has returned 183% annual return, but in an extremely choppy fashion:

DUST-D Update 6-23-16 TimeDUST-D Update 6-23-16 Table

The optimum buy point over this period was 4.12%, with a sell point of 8.32%. The results for this optimization are shown in the table below. Its odd how the optimum buy point was almost exactly twice that of the original optimization, not the first time I have seen this happen.

DUST-D Update 6-23-16 Table Opt

DUST-D Update 6-23-16 Time Opt

Update 10/20/2016


Performance has deteriorated somewhat:

DUST Trading Strategy (Daily) Update 10-20-2016

DUST Trading Strategy (Daily) Update 10-20-2016





IBM Trading Strategy (Weekly)

This IBM trading strategy made 11x the total returns (4x the annualized return) of the underlying stock with half the drawdown. The backtest period was 10years. The strategy itself (see table below) was straightforward with both buy and sell signals triggered by falling prices. The buy signal keyed off the 52 week high while the sell signal keyed off the closing price of the previous week. All buying and selling was done at the weekly open. It turns out that 225 out of 528 weeks were dual signal days, this often led to periods where a buy weeks alternated with sell weeks (see list of trades in excel format). Ignoring dual signal days would have led to very low gains, so the alternating strategy must have worked somehow.

The strategy had a buy bias, there were 141 days with just a buy signal and 55 days with just a sell signal. Since the underlying stock seems to be downwardly trending, this bias may work negatively if the downtrend continues. We shall see.

The backtest assumes a commission of $7 per trade.


Update 1-3-16

This this strategy turned out to be a dramatic failure. Here are the updated table and equity curves:

IBM-W Equity1-3-16

IBM-W Table 1-3-16

Update 1-3-16

Still a dramatic failure, but less so:

IBM Trading Strategy (Weekly) Update 10-20-2016

IBM Trading Strategy (Weekly) Update 10-20-2016



GILD Trading Strategy (Weekly intervention)

This is a GILD trading strategy with weekly intervention required. I found algorithms with better returns, but they were less consistent over time and had more parameter sensitivity. I chose this one because of many favorable characteristics:-

  • Buy low, sell high type of algorithm, biased towards buying as befitting an upward trending stock like GILD.
  • Buy and sell at the weekly open was easy and convenient to implement
  • Buy and sell signals were well differentiated (only 4 dual signals) with good reinforcement on the buy side.
  • Good lifetime characteristics with each 2.5 year  period beating buy-hold.
  • 87% successful trades and a Sharpe Ratio of 2.03 vs 1.05 for buy-hold.
  • Gentle slopes on the parameter surface.

Note that charts were corrected 1-2-16 for an error in short-side return


Update 1-2-2016

GILD-W1 1-2-16 Update Table

Update 10/20/2016

GILD Weekly Trading Strategy Update Oct 20th 2016

GILD Weekly Trading Strategy Update Oct 20th 2016

SPY Trading Strategy (Weekly)

Shows the results of backtesting a trading strategy for the stock SPY (SPDR S&P 500 ETF) over the 10 year period 1/18/05 to 2/23/15. This was a weekly strategy meaning that it needed setting up once a week, and it traded once a week or less. I chose this strategy because it gave the best total return (1020% vs 120% for buy-hold), not because of its longevity characteristics which are not superlative. That said, it was reasonably well behaved, staying long in the run up to the 2009 crisis, going mostly short then essentially staying long since 2011. It also displayed a good tolerance to changes in the buy and sell points.

Note that this was a buy high, sell high strategy; a sell signal was (with one exception) always accompanied by a buy signal in the same week, but since each week you were following either the buy or the sell strategy, there was never two trades in a week. There were a total of 118 buy signals and 43 sell signals.

Please note, this post was edited Jan 6th 2016 to correct an error in the short-side calculations.

Trading strategy for SPY with a weekly setup. The strategy (yellow line) returned $102,005 over a 10 year period for a $10K initial investment. Buy and hold returned $11,846. Trading signals were reinforcing--note that every week with a sell signal also had a buy signal.

SPY Weekly, tabular view of the backtest. Trading strategy gave 27% annualized return vs. 8% for buy-hold. Reward/risk was around 7x better for the strategy. Note that the "user defined" referred to in the buy signal is the average of the current weeks open price, the previous week's high and the previous week's low. Also of note, drawdown was only 21.3% (Sept '08) vs. 55.3% for buy-hold (March '09).

Charts show how annualized return varies with buy/sell point (for a fixed sell/buy point). For a sell point of 7.15% all buy points 0-6.5% were profitable. For a buy point of 2.41%, all sell points in the range 4.1%-9.6% were profitable.

This chart shows return of the algorithm for different time periods, and how they change with buy and sell point. The green line (1/05 to 7/07) shows little improvement over buy-hold. The white line (8/12 to present) is distinctly lower showing a tailing off in performance in recent times. In fact, the algorithm has sub-performed buy-hold for the last 3 years, by a small margin. You can see from the time chart that the algorithm has stayed mostly long for 3 years. Some may like this behavior; an algorithm that stays largely out of the way in the good times. Others may argue that the algorithm fails to exploit recent price fluctuations.

SPY weekly, surface plot. Shows how return varies with changing buy and sell point percentages. The area of interest is the plateau. It is wide with few cliffs which is what you want to see.

Update Jan 6th 2016

This algorithm began to break down around Aug 10th. Since publication it has lost around 16%.

SPY-W Table Update 1-6-2016

SPY-W Equity Update 1-6-2016

Update Oct 19th 2016

Still unspectacular performance from this:

SPY Trading Strategy (Weekly), Update 10-19-2016

SPY Trading Strategy (Weekly), Update 10-19-2016

SPY Trading Strategy (Weekly) Update Oct 19 2016 Equity

SPY Trading Strategy (Weekly) Update Oct 19 2016 Equity