Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
WaveTrend Based Algorithm Results

I want to share this algorithm because it is largely based on code that another user shared https://www.quantopian.com/posts/wavetrend-oscillator and thought it would be a good idea to give back what I did with it.

I attempted to make it less volatile and not as leveraged as the original implementation. I added randomization and randomly selected a group of stocks based on the performance of the SPY. This really helped during times of high volatility.

I also changed up the percent of allocations over time depending on a buffer to keep the leverage within a target range. I've been live testing algorithm much like this since November 24th and it's currently at 4.54% returns and a Sharp of 3.88 as of January 6th 2017.

Any feedback would be much appreciated. I'm still learning and experimenting because it is still mathematically unclear to me why this algorithm would would work using this indicator. Part of this algorithm was me testing the indicator to see if there was even any promise in it. There does appear to be some promise in such a simple price based approach based on the tests that I have done.

Note that because of the randomization different runs will give different results but the properties of low volatility and low beta and positive returns remains for each run.

4 responses

Here is a more recent version with more comments. Notice the properties of the algorithm's returns are not exactly the same as the test above. But the results do maintain the characteristics of a low beta and positive returns.

This trading strategy could be considered as a variation of the Simple Moving Average Crossover theme found here.

I used the same testing interval as the strategy above.

My attraction to this strategy was it had a contraption switching regimes all the time.

A wave-type definition is used. And as shown in the first presented algo, it does produce positive results.

But, when compared to APPL, it does not get that much: about 2.3% of what holding APPL would have generated. Again a scenario showing that the sum of the parts did not produce more than the whole: Σ(q∙Δp) < B&H = q_0∙[p(T) – p_0].

We should classify it as an also ran, with no prize.

You have this trading strategy switching from long to short for some reason or other. Sorry, I have not look at the trading logic, only identified the two numbers that controls the thing. As if the switching method was not important.

Since this is a one stock scenario. Whatever you did trading would have to produce more that the 2.3% of the buy & hold of the initial iteration. The first two lines on the chart below compare the strategy using SPY or APPL as benchmarks. Evidently, based on those two lines, the buy & hold scenario is the obvious choice, and by far.

Who, at any time over the past 15 years, would have declared: APPL is going bankrupt? If you were ready to say that, then give us a glimpse why with a probability measure. I understand if you would have said something like this in the early 90's. But, over the past 15 years, we could all see that this stock was going up. It is not alone in this category.

The experiment below is saying that you have this switcheroo strategy where for some reason or other the entire portfolio is going long or short.

Evidently, not outperforming APPL, it was not worth that much even if it made a profit over the trading interval. It was a 10.28% CAGR compared to APPL's 41.98% over those same 14.8 years and no work to be done.

This is like saying: the switching method is wrong a lot of times, and it happens a lot of times. From such an observation, we should simply delete the strategy and search for something better.

There is a difference between a switcheroo thingy and a betting strategy. The how much, or how you bet, has its importance too. The switcheroo had no respect for what its market was, and certainly, the wave trend had little predictability, if not none at all. It was only catching part of the upside drift as a consolation prize.

My point is: it was sufficient to have “something” providing a switcheroo that happened often to be able to transform the trading strategy to do more than what holding APPL could have provided.

Using the same techniques as in the above cited strategy, simply applying a little pressure on the bet size was sufficient to outperform APPL (see test #3). It had other advantages: higher alpha, higher Sharpe, higher Sortino, lower volatility, and lower drawdowns. It went even as far as reducing the gross leverage while providing a 45.33% CAGR. There would still be leveraging fees to pay even if the gross leverage was at 0.91.

The small change in test #3 (1.20 / 0.20), transformed the strategy into one that had a core portfolio position over which trading took place due to the switcheroo thing.

Even if the switching itself had no value, the betting system gave it one.

In tests # 5, 6, 7, 8, 9, and 10, more and more pressure is applied to the bet size. Sure, there are higher leveraging fees. But, in each case, there will be more than enough to cover those fees and then some.

What we can observe in those 6 tests, is that the more pressure is added, the higher the performance level, the higher the CAGR. Doing this, evidently, required higher and higher gross leverage, higher betas, higher volatility, higher drawdowns, but also, higher alpha, higher returns, and a whole lot more cash.

The Sharpe and Sortino ratios should be considered as having stayed about the same.

Test # 11 shows that you could still go short, lower the gross leverage a bit, but at a cost. Is the 6.35% less in drawdown worth $1.62 billion? That is the question we all have to answer in some way.

In the end, it is always the same thing. It is a matter of choice, of resources, of time, and determination. But whatever, if you want more, you will have to do more than the other guy. You will need to take a little bit more risk and put in the time.

Now, regardless of the switcheroo trading method used here, one should nonetheless find a better strategy where you could gain some control over it, accentuate its strengths when needed while minimizing its weaknesses.

Of note, even Mr. Buffett over his 50+ year career has sustained four times drawdowns in excess of 50%!

Wave Trend Tests

Hi Guy Fleury,

I cleaned up the code a lot in the attached version. It should be easier to follow the logic. There is a tension between out performing the benchmark and the volatility. The methods I implemented were designed to decrease volatility and correlation to the market overall not to maximize returns only.

You are right that just holding APPL back in the day would have been better, but this was my first trading algorithm and I am actually quite surprised that simply using price data alone (not even log returns or returns) and no outside information about the fundamental data of companies would lead to anything but random returns or just loosing money over ten years. These EMAs are picking up on some structure in the price time series that I thought were random when I first started out on Quantopian. I am still trying to figure out exactly this "Wavetrend" indicator is mathematically doing to the time series that would make this remotely useful. It's not clear at all... at least to me that these experiments I am sharing would even work out to give positive returns.

Just for fun I tried a random buy and short signal (coin flip). Attached are the results. I ran it a few times and it is consistently gives poor results.