Dynamic Position Ranking

A widely overlooked issue of trading stocks is how to rank multiple opportunities (entries) and select among the best ones. Woodshedder at iBankCoin analyzed various ways (link).

With this post I want to introduce a dynamic approach to position ranking.

.

.

Test system

Let’s define a simple swing trading system that will be used to present various ways for position ranking:

  • Long only
  • Entry when RSI2 is bellow 30
  • Exit when RSI2 is above 70
  • 10 Positions, each 10% equity
  • Survivorship bias free SP500, incl. delisted stocks
  • No commission / slippage
  • Explanation of the key performance indicators being used (link)
  • Test  period January 1990 until  November 2010

Portfolio ranking

These are the initial ways of ranking multiple concurrent entries.

  • A: lowest RSI2
  • B: lowest ROC1
  • C: lowest (RSI2 + RSI3 + RSI4 + RSI5)
  • D: lowest (ROC1 + ROC2 + ROC3 + ROC4 + ROC5)

Initial results to benchmark

Looking at these results, you can see that ROC based ranking is superior to RSI based rankings. Ranking B, C and D deliver about the same results. Something you need to consider defining your stocks ranking, all of presented ways don’t account for a stocks inherit volatility. However, that’s not the main point about this post. So, how can you further improve these results: either by finding a better combination of ROC/RSI parameters through optimization or by thinking in new terms.

Dynamic position ranking

Essentially the system presented is a mean-reversion system. It buys into oversold stocks and sells after mean reversion has taken place (buy low, sell high).  Talking to Chart-Trader they often tell you about stocks that mean-revert better than others. Furthermore we know that mean-reversion behavior of a given stock is changing over it’s lifetime. The rankings above assume all stocks mean-revert alike and it’s just a matter of buying the ones being oversold the most.

Let’s add a small improvement: rank the stocks according to their past mean-reversion performance. Stocks with a high return will rank higher than other stocks.

The simple system improved on all metrics!

AmiBroker AFL – Code

SetOption("CommissionAmount",0.00);
SetBacktestMode( backtestRegular);
SetPositionSize( 10, spsPercentOfEquity );
SetOption("MaxOpenPositions",10);
SetOption("MaxOpenShort", 0);
SetOption("MaxOpenLong", 10);
SetTradeDelays( 0, 0, 0, 0 );
SetOption("AllowSamebarExit",False);
Member        = SP500member(Name(),DateNum());
RoundLotSize  = 0;
Short = Cover = False;
//PositionScore = 100 - RSI(2);   //A
//PositionScore = ROC(Close,1) * -1;     //B
//PositionScore = 400 - (RSI(2)+ RSI(3) + RSI(4) + RSI(5)); // C
//PositionScore = (ROC(Close,1) + ROC(Close,2) + ROC(Close,3) + ROC(Close,4) + ROC(Close,5)) * -1;   //D
Entry         = Cross(30 ,RSI(2));
Exit          = Cross(RSI(2),70 );
Entry         = ExRem(Entry,Exit);
Exit          = ExRem(Exit,Entry);
Entryp        = Ref(Close,- BarsSince(entry));
RealRet       = IIf(Exit,(((Close-entryp) / entryp)*100),0 );
Tot_Sum       = Sum(RealRet,252) ;
PositionScore = ( 100 + tot_sum);
Buy = Year() >= 1990 AND RSI(2)<30 AND member;
Sell = RSI(2)>70 OR BarIndex() == LastValue( BarIndex() );

Comments

  1. Gonzaga says:

    Brilliant!
    I have to test with my own mean-reversion systems!
    I’ll post if I have improvements..
    very good!

  2. Bgpl says:

    hi Frank,
    can you not just use
    Eq = Equity();
    Last_n_equity = Eq – ref(Eq,-lookback);

    this gives the equity curve on this strategy for the last n days only for this ticker (before custom backtest).
    regards
    bgpl

  3. Woodshedder says:

    Well done Frank. I love the simplicity.

  4. t. says:

    Thank you, Frank! Very valuable blog.

  5. Burger says:

    Very nice Frank. Correct me if I’m wrong but this would not be possible to trade as is. It is only meant to confirm the ranking advantage.

  6. Justin says:

    Hi Frank. What test was used to determine a stock’s ability to mean-revert? TSI?

    Thanks.

    • Hello Justin,

      as written in the post:

      Entry when RSI2 is bellow 30
      Exit when RSI2 is above 70

      Does that answer your question?

      Frank

      • Justin says:

        Hi Frank

        I was actually referring to this paragraph: “Let’s add a small improvement: rank the stocks according to their past mean-reversion performance. Stocks with a high return will rank higher than other stocks.”

        In this paragraph, how were the stocks ranked?

        • Hi Justin,

          the stocks were ranked according to their past mean reversion performance. I basically took the performance over the last couple of days (252) to rank them.

          Frank

  7. genkumag says:

    Just came across this post and I think it’s fantastic! Alternatively, while not in the same league as the test criteria you set for ranking, Perry Kaufman’s efficiency ratio is also quite useful for identifying strong issues. Again, great post and more power!

Trackbacks

  1. [...] Dynamic Position Ranking [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 226 other followers