Skip to content

Using Probability Density as an Adaptive Mechanism

May 14, 2010

I will take a pause of the Time Machine series for now while I work on it some more and prepare future posts. Today I will follow up on my post on return distributions and show a simplistic way to include it in an adaptive strategy.

It has been discussed quite a lot on the blogosphere that a strategies with fixed parameters are inferior to adaptive strategies. For example the simplest daily MR strategy I can think of is probably RSI 2 50/50, but this strategy did not always worked and I certainly don’t expect it to keep working forever. Furthermore, the most profitable lookback parameter for RSI also varies in time. This is where return distribution is useful. From it, we can derive the probability density function and use that to create an adaptive mechanism.

Just a little background on probability density function; from wiki: “density of a continuous random variable is a function that describes the relative likelihood for this random variable to occur at a given point in the observation space.” In plain language; the probability of a certain event happening. I recommend using your favorite statistical software to do so, unless you want to be doing integrals for a long time!

For this test, I took SPY data, computed RSI values for different lookback periods (2 to 30), and then looked at the results for each strategy. For a rolling period of 1 year and 6 months I looked at the probability densities of returns for every strategy looking specifically at the probability of returns greater than zero (this can be changed to a higher threshold, just want to keep it basic for this). I then traded the strategy that had the highest combination of 1 year and 6 months values. That way, the capital is allocated to the strategy with the parameter generating the highest probability of positive returns as measured by the probability density function. I compared the strategy, RSI 2 50/50 and buy and hold.


The results are not particularly impressive, the point of the article was to illustrate the concept as simply as possible. I believe that there is ways to make this particular strategy more robust; as a starter to take a shorter time frame for the lookback period to make it more sensitive to recent market data or introducing a weighting scheme to weight more recent data. I will let the reader experiment with it, I would be happy to post results if you care to share. Even though the results are not spectacular, the strategy seems to adapt to the different waves in the market and allocate the capital to a more appropriate parameter length for the RSI depending on the current market paradigm.


  1. May 15, 2010 09:38

    Would you share the code you used in this post? That would make it easier for others to experiment with it.

  2. Paolo permalink
    May 17, 2010 05:46

    There is always a very thin limit between adaptive and curve fitting. I agree with you that when statistical tests are used we tend to play more on the safe side but my trader-oriented brain is often very scary when it comes to trade them.

    • May 21, 2010 10:46

      Very good example of cognitive dissonance. No statistical test is the holy grail per se, they are just tool to help us make decision and are better used with aggregated with other measures. In other words, whatever makes us sleep well at night when invested.

  3. May 18, 2010 15:53

    Let me see if I understand your test process … You calculate the RSI(2) through RSI(30) for the entire chart. At each bar in the chart you evaluate the results of 29 different strategies (one for each RSI) over the most recent 6 month and 12 month periods. You use the RSI that gave the best combination of results to determine if there are any trades for this bar.

    To clarify: Are you using a cross over 50 for long and short decisions (so you are always in the market)?

    I am really curious as to the big-picture behavior of this approach … did you find the optimum RSI length to move smoothly ip and down the scale (4-5-6-7-6-5-6-7-8) or was it chaotic (5-17-16-17-25-24-7)? Did you experience situations where the optimum RSI changed to a value that had already signalled a change in position, so your current position was at odds with your current signal? How did you handle that?

    Interesting stuff.

    • May 21, 2010 10:52

      Thanky you for the comment Eventhorizon,

      You are correct on the test process. Regarding the behavior, I found it to be very chaotic in periods of low volatility while the opposite was true during high volatility.


      • Freeman permalink
        June 20, 2010 21:30

        QF-For clarification, “…the results of the 29 different strategies…” is going long when RSI>50 and short when RSI<50. You then analyze each strategy over the most recent 6 months and 12 month periods to develop the probability densities. Right?


        • June 20, 2010 22:02

          Hello Freeman,

          Thank you for your question. The strategies are actually traded on a MR bias. That is long if < 50, short otherwise. You are correct in the rest of your reasoning.


  4. pinner permalink
    May 20, 2010 09:32

    Alternatively you could regress the returns against the set of 6mo & 1yr RSI points as a means to determine the best decision. While this approach probably requires more historical data, it also affords more detailed metrics from which to make each decision.

  5. pinner permalink
    May 20, 2010 12:24

    To be precise, I meant to say regress the 6mo & 1yr RSI points against the returns…

  6. eber terandst permalink
    May 23, 2010 12:28

    I might be confused, but how is this different from the well known walk forward technique ?

    • May 23, 2010 12:47

      Hello eb,
      It is indeed a walk-forward test. However it is not a traditional walk-forward optimization in the sense that it doesn’t look at the same thing. Using probability density we look at the probability of favorable returns, while in traditional walk-forward we often look at total return. When using this post’s method we look at the distribution of returns rather than just the return series.

  7. Freeman permalink
    May 23, 2010 21:56

    QF-You’re truly looking at the CDF of the return distribution and not the PDF, right?

    Also, are you looking at the equity curve of the non-adaptive strategy prior to adjusting the constraints to generate a new adaptive strategy?


    • May 23, 2010 22:28

      Hi Freeman,
      For this test, I used the PDF, however one could also use the CDF for a similar mechanism. And no, I did not look at the equity curve since I wanted to keep to post oriented towards the use of PDF, it would probably improve results though.

      Thanks for the question


  1. Percentrank SMA « CSS Analytics

Comments are closed.

%d bloggers like this: