19th Ave New York, NY 95822, USA

8 Amibroker Rotational Trading Ideas

LOREM IPSUM DOLOR SIT AMET

One of the most powerful functions in Amibroker is the ability to easily program rotational trading strategies. In this article I present 8 ideas that may inspire you to create a new rotational trading system.

What is rotational trading?

Rotational trading is a straightforward concept to understand. You simply rank a list of securities then go long or short the best or worst securities from that list. You can hold these stocks for a set period of time or until the securities drop in or out of said list.

There are many benefits of using a rotational approach.

• First of all, rotational trading can reduce the chance of curve-fitting. Ranking systems by their nature rely on very few parameters. They can remove the need for market timing or signals from technical indicators.This is one of the main reasons why I like the rotational concept. You can design powerful systems that are virtually parameter-free. So long as you avoid over-optimizing and adding in unnecessary rules you can increase the likelihood that your system is not curve-fit.

• Second, rotational trading is the perfect vehicle for momentum or trend following strategies. You can rotate into the best performing stocks and out of the worst performing stocks with ease. Crucially, you don’t necessarily have to wait for a certain condition to happen (such as a new 52-week high, or a moving average crossover).This means you can enter into stocks that are showing relative strength and this can be much more powerful than waiting for a particular signal which could potentially be a crowded trade if everyone jumps on it.

• Third, rotational trading keeps you in the market. As mentioned above, rotational systems do not need to wait for precise signals, they are based on ranking/ relative strength therefore you can have a portfolio that is always invested.

• Fourth, rotational trading is excellent for diversification purposes. It can be used to rotate out of poor performing strategies and into better ones. It can be used to move between various mutual funds and it can be used to rotate out of poorly performing stocks and into trending stocks.

• Lastly, rotational trading is simple. It does not require too many fast trades and it can be set up daily, weekly, or monthly in order to avoid any over-trading. With Amibroker, back-testing rotational strategies is also very simple and requires only a couple of lines of code.

Setting-up rotational trading in Amibroker

To set up rotational trading in Amibroker is simple.

All you have to do is call the EnableRotationalTrading() function then use PositionScore to rank the securities in your watch-list. There is no need for any specific buy or sell variables.

Following is a very simple rotational trading formula from the Amibroker tutorial pages. Here stocks with high RSI are best candidates for shorting while stocks with low RSI are best candidates for long positions:

EnableRotationalTrading();
SetOption("WorstRankHeld",5);

PositionSize = –25; // invest 25% of equity in single security
PositionScore = 50 – RSI();

Running this very simple rotational trading system on the S&P 100 universe of stocks between 1/1/2000 and 1/1/2015 returned the below results:

Annual return (CAR): 22.17%
Maximum system drawdown (MDD): -74.34%
CAR/MDD: 0.30

Each day the strategy either goes long the or goes short stocks that are either oversold of overbought according to RSI 14. These results are based on commissions of 0.1% per trade in line with my spread bettor IG Index and they show (even though the drawdown is huge) that there is potential for great results.

To see more details about this rotational trading system in Amibroker see here.

8 Amibroker Rotational Trading Ideas

The above example is a simple one and the maximum drawdown is far too high for most investors. So here are some more ideas for developing a rotational trading system.

#1. Momentum

An obvious choice for a rotational system is as the basis of a momentum strategy. Rotating into the strongest stocks and out of those stocks that are slowing is the easiest way to take advantage of the momentum effect.

Following is a strategy that rotates into the top 20 best performing stocks every six months. As you can see the performance was OK but nothing to write home about.

Annual return (CAR): 7.35%
Maximum system drawdown (MDD): -35.98%
CAR/MDD: 0.20

amibroker rotational trading equity curve

#2. Mutual fund rotation

As I mentioned earlier, rotation can be a good way to trade mutual funds and there are many options available. You could rotate out of the worst performing funds and into the best performing funds (momentum) or you could do the opposite. You could rotate into funds based on technical signals, correlation or some outside condition.

For example, you could rotate into bonds and out of stocks, whenever the stock market drops below the 200 day moving average.

Or you could rotate out of stocks and into gold whenever the gold/US dollar ratio moves away from it’s long term average.

Or you could rotate out of the VIX and into XIV as part of a hedge that goes short the VIX ETF.

#3. Short-term reversals

It may also be a good idea to buy the worst performing stocks as part of a mean reversion strategy.

According to one academic paper, ‘reversal strategies [buying the weakest stocks] generates 30 to 50 basis points per week net of trading costs’.

I talk about this strategy in depth in this article called a short-term reversal strategy and I find that buying the 10 poorest performers in the S&P 100 universe and holding them until they drop out of the worst 50 performers produced a compounded annual return of 18.28% between 2000 and 2015.

amibroker rotational trading strategies ideas looking at some system results

#4. Rotating based on correlation

Another idea might be to rotate out of certain ETFs, mutual funds, or stocks based on changes in correlation. For example, the US dollar is highly correlated to the price of oil, so whenever that correlation gets out of whack, that might be an opportunity to rotate into USDX or WTI.

Or, you could set up a rotation system that rotates into stocks that are the least correlated to the overall market (such as the S&P 500).

Rotating into stocks that are the least correlated to the index will ensure that your returns are different to the market as a whole (this strategy in itself could be a good compliment to a buy/hold or momentum strategy which will typically follow the market).

Indicators such as BETA or ROC (rate of change) might be good ways to take advantage of this idea. High beta stocks are normally more volatile than the market and low beta stocks are less volatile.

#5. Rotate into different strategies

As mentioned already, rotation is also ideal for shifting in and out of different strategies, though doing so is much harder to simulate in platforms such as Amibroker.

The success of certain investment strategies tends to move in cycles. Sometimes growth investing performs best, other times value investing leads and other times momentum is in front.

As a strategy generates alpha it becomes more popular which means people jump on board and then performance often deteriorates as a result. Then as people declare the strategy dead, it comes back again.

Trend following or managed futures for example, did poorly between 2011 and 2014 but has come back strongly in the last couple of years.

Therefore, a rotation strategy could be set up to move out of trend following and into mean reversion at certain times, and vice versa. Or out of growth investing and into value investing for example.

#6. Technical indicators

Of course, an easy way to set up a rotational strategy is to rank stocks by a technical indicator.

Oscillators work well because they generate numbers within a range which means ranking is a piece of cake. Following is a list of indicators that might be used:

  • RSI – Use low values to find oversold stocks and high values to find over bought stocks. Can be used for momentum or mean reversion.
  • MACD – Rank stocks based on the divergence of two moving averages. Can be used to find reversals.
  • ATR or Chaikin Volatility – Rank stocks based on volatility. Low volatility stocks might offer smoother trends.
  • Momentum oscillator – Use high values to find upward trending stocks and low values to find downward trending stocks
  • Stochastic oscillator – Use high values to find overbought stocks and low values to find oversold stocks.

Etc.

The following strategy rotates into the five least volatile stocks in the S&P 100 as measured by the 10-week ATR (normalised as a percentage). The results and details are shown below:

Annual return (CAR): 12.19%
Maximum system drawdown (MDD): -37.44%
CAR/MDD: 0.33

rotational volatility trading system in amibroker

#7. Build your own indicator

Of course, it’s not difficult to build your own indicator. That way you can come up with something unique, based on your own observations of the market.

For example, what about ranking securities according to the difference between a 5-period stochastic and a 15-period stochastic? (Similar to the idea behind the MACD which looks at the difference between two moving averages).

Or what about ranking securities according to how many times they have gapped higher (or lower) on the open? Stocks that seem to often gap higher on the open might continue to do so.

Or you could rank securities based on the number of times in the last n periods that they have touched a critical moving average. Such stocks might make predictable trade set-ups.

Or by how many times the stock has closed in a bullish candle pattern over the last three months.

Perhaps you could rank stocks in such a way and use other criteria in which to confirm trades.

There are lots of possibilities out there. You are limited only by your own imagination.

#8. Fundamental ratios

Lastly, you could move away from technical indicators altogether and look at fundamental ratios such as PE ratios, PEG ratios, current ratios etc.

By rotating into stocks with the lowest PE ratios you’ll end up with a strategy built up of lowly rated companies. That could be a problem if you’re looking at a wide universe of stocks such as the Russell 3000 but if you concentrate on larger stocks, it might have some use.

For example, using that strategy right now would keep you away from tech companies like Amazon (PE of 395) and into cheaper entities like General Motors (PE of  4.62).

Or, it might make sense to do the opposite, i.e. rotate out of the low PE stocks and into the high PE stocks in order to move into high growth companies that are riding trends.

historical PE ratios chart and stock market performance

Amibroker can show many of these fundamental values as they are but it’s not possible to use them in a back-test. For doing so, you can use Portfolio123 which has offers all sorts of ranking possibilities.

I have ranked stocks in the past with P123 and I’ve found that low PEs and low PEGs work well when choosing between stocks, much more so than high PEs/PEGs. In fact, one of the trading systems I created (called Trend Following With A Twist) finds trending stocks then ranks them by PE.

Whatever you choose to do, make sure you investigate rotational trading as it’s a powerful form of investing that is often overlooked by retail traders.

Simulations created with Amibroker using survivorship-bias free data from Norgate Premium Data. Sign up with Norgate for a free trial using this link.


Comments (11)

Thanks for the article, some interesting ideas here

Have you ever used EasyLanguage / Tradestation / Multicharts – I assume you did considering your background.

How do you compare the two (AFL vs EasyLanguage)?

Just babystepping into AFL, and one thing I cannot get my head around is lookahead bias – it seems very easy to access bar 10 while processing bar 1 in an AFL Backtest …
Some other differences:

Easylanguage:

If BarNumber = 10 then begin
buy next bar at market;
end else
If Close[10] > 100 and MarketPosition = 0 then begin
sell short next bar at market;
end;

If MarketPosition 0 then begin
sell next bar at open;
buy to cover next bar at open;
end;

These are very, very simple EL concepts. What’s their equivalent in AFL?

No, I haven’t spent much time with EasyLanguage.
In AB we usually don’t reference any future bar as it can cause lookahead leak as you say. To refer back we use ref(c,-10)
This gives us the close price 10 bars ago. I don’t believe there is any function for MarketPosition in AB but there is InTrade.

Actually Amibroker leaves the Aux1 and Aux2 fields open. I’m doing research utilizing historical CAPE values from Global Financial Data and then using Excel to add them to the Aux1 field in the price series for several international ETF’s, then importing back into Amibroker. The result is international ETFs with their historical CAPE values. We’re using this for a global rotational trading system.
Thanks
Tony

Thanks Tony, I like it. Do you update the CAPE values manually?

Yes I do, an excellent shop over in Germany updates their global CAPE ratios and I manually update them quarterly (which is close enough for our purposes, at least for now). Happy Thanksgiving!
http://www.starcapital.de/research/stockmarketvaluation
Tony

Dear Marwood,

What should be the CAR/MAXDD. As I can see it is around 0.33.

I have developed few systems in AmiBroker which has CAR/MAXDD of > 2.5 to 4 on the Portfolio of 50 Stocks of NSE Futures, it is Positional Long Short strategy.

BRgds,
Rama Reddy

CAR/MDD of 2.5 is quite high. Might suggest curve fitting. Or you could have a great system. Good luck.

Dear Marwood,

I never use optimimize. It’s a random parameters we use. We have multiple Trading Strategies.

We have designed it on 2015 Jan, Paper Traded for 18months Till Nov’2016. Live Since last 11months.

BRgds,
Rama Reddy

Hi there – is it possible to get the code for each of the scenarios above that you used. Is it available to readers?

Sorry I wrote this 3 years ago and don’t have the code anymore.

Leave a comment