Skip to content

Conditional Percentile Channels

February 20, 2015

Ilya Kipnis at Quantstrat recently posted some R code attempting to replicate the ever-popular Percentile Channel Tactical Strategy. The results are similar but not exactly in line- which may have to do with the percentile function as Ilya has pointed out in the comments. In either case, the general spirit remains the same and readers are encouraged to take a look at his analysis of the strategy.

In quantitative finance there is the concept of “Conditional Value at Risk” (CVaR) which is a calculation frequently used in risk management. The general idea is that you are trying to capture the expectation beyond a certain tail of the distribution. The CVaR is preferred to the value at risk because it more comprehensive than looking a just one value. Likewise, Percentile Channels are similar to value at risk in that context as well as traditional Donchian Channels which only look at one reference price. Perhaps a logical improvement would be like CVaR to use the average of the prices above a certain percentile threshold. This is more like calculating the expected upper or lower bound for prices. Furthermore to account for the fact that recent data is progressively more important than older data, we can weight such prices accordingly.In theory, the most important prices are at the extremes and should also be weighted as such. So Conditional Percentile Channels is simply a twist on Percentile Channels incorporating these two ideas. Here is how it would be calculated:

conditional percentile channels

Basically you select a threshold like .75 and .25, and then you weight the prices that are above those thresholds according to both position in time (like a weighted moving average) and distance to max or min. This gives you a more accurate expected upper or lower bound for support and resistance (at least in theory). I know I am going to regret this, but using the same strategy ie- Percentile Channel Tactical Strategy in the last few posts- I substituted in the Conditional Percentile Channels using the same threshold of .75 and .25. All other parameters are identical. Here is how that looks:

conditional percentile strategy

Looks like a slight improvement over the original strategy in both returns and risk-adjusted returns. In general, I just like the concept better since it condenses more information about support/resistance than either Donchian Channels or Percentile Channels. It also represents a good complement to moving averages which capture central tendency rather than price movement at the extremes. So there you have it- yet another twist on using channels.

26 Comments leave one →
  1. Javier permalink
    February 20, 2015 6:20 am

    Nice idea David.

    One question: have you tried with DownsideDeviation(DD) as volatility calculator? I get better number DD instead of StdDev….


    • david varadi permalink*
      February 26, 2015 8:41 pm

      Hi Javier, I have tried that in other systems with mixed success– i think the concept is definitely useful but there are nuances to using the DD since it has fewer observations. Good suggestion though- i think in this specific system would be worthwhile trying.

  2. RaviC UK permalink
    February 20, 2015 8:48 am

    Another fantastic idea to get the juices flowing. I just can’t keep! I utilise my own home-grown Java based backtesting and trading framework (I’m a professional software developer) so it takes me a little longer to develop and incorporate your ideas than say an R implementation. I must say your thoughts and ideas are a true inspiration and I congratulate you on your fantastic blog. Long may it continue!

    • david varadi permalink*
      February 26, 2015 8:43 pm

      Hi RaviC, thank you. Much appreciated- Java is widely adopted in high frequency based on my understanding so while it takes longer to develop in, it is very scalable. thanks again for the kind words- indeed i hope to keep things up.

  3. Pete permalink
    February 20, 2015 3:58 pm

    Very nice addition to the strategy; fantastic really. Just to confirm I’ve got this right, can you confirm the low channel price for the example is 117.65?

    • david varadi permalink*
      February 26, 2015 8:44 pm

      Hi Pete, thank you- just another twist to make it unique. I will have to check that one out- will get back to you on that one.

  4. February 22, 2015 7:49 pm

    So I’m pretty technical and find inspiration in your blog precisely because of the way you take complex bits of theory and extract the essential idea into something intuitive and easy to work with. Usually I have no trouble writing my own code to implement your ideas, but in this case I cannot figure out what the “coefficient” column is in your calculation. Any hints?

    • RaviC UK permalink
      February 23, 2015 4:25 am

      drenerbas – the coefficient column is the “Rank x position” divided by the sum of all the “Rank x position”s, so for the first row the coefficent is 25/53 = 0.4716

    • david varadi permalink*
      February 26, 2015 8:45 pm

      hi drenerbas, thank you- much appreciated. RaviC answered that correctly– they are just weighting terms generated by the rank and position in time.

  5. Victor permalink
    February 22, 2015 10:33 pm

    David, I really like the concept. It’s a fair bit more complex though, as it would appear the new method requires a full recalculation for each day. The original concept was fairly easy to implement as a rolling “percent rank,” but now each day’s price has to be compared to the “conditional” values for that day. For example, the calculation you demonstrate would have to be done twice (upper and lower values) for each day and then the close would be checked to see if it exceeded either extreme. Do I have that right?

    On a different note… have you given any thought to using range-based volatility estimators for the “risk parity” allocation method? There seems to be a fair bit of theoretical and empirical evidence they provide better results.



    • February 24, 2015 7:43 pm


      You definitely have the double-pass for each day correct, meaning that the way to do it in R would be to only compute this as of the portfolio rebalancing periods. On your different note, what range-based vol estimators for risk-parity are you talking about? Things like ATR? Can you provide a link to some of your ideas?


    • david varadi permalink*
      February 26, 2015 8:52 pm

      Hi Victor, thank you. the conditional channels are kind of messy to compute in the presented form and also computationally inefficient as you indicated. There are a lot of ways to address that aspect.However, both channel types require that you compare the price to the channels every day. Thank you Ilya for confirming that. In terms of range based volatility indicators- i have heard that certain GARCH methods employ those, and that they can be expressed as a linear function transform of traditional historical volatility. i have also read that they perform quite well. i will take your suggestion and will try to post some ideas in the future.

  6. david varadi permalink*
    March 2, 2015 1:20 am

    Thank you Victor, some very good links there. I will see what I can draw from for a subsequent post. Excellent work!

  7. Nikos Papasavvas permalink
    March 2, 2015 8:53 am

    David thank you for sharing these strategies! The line I know I am going to regret this was very funny! I want to ask you if the percentile channels could be combined with the minimum correlation algorithm and if using only the 12 month channel would provide higher sharpe ratios. Thanks

  8. Nick Papasavvas permalink
    March 2, 2015 1:55 pm

    David, to complete my previous message, what I am thinking is to substitute the inverse volatility weight at the minimum correlation spreadsheet with the channel score*inverse volatility product from the percentile channels model. Is this correct?

    • david varadi permalink*
      March 11, 2015 12:12 am

      Hi Nick, thank you- I try to have a sense of humor once in a while 🙂 You can simply apply the minimum correlation weights in the same manner as risk parity. Im sure it might boost performance or the sharpe ratio slightly–i haven’t tried it yet but it seems like a good idea. perhaps I will post on that in the future.


  9. James permalink
    March 5, 2015 2:15 pm

    David, that’s for your great work on percentile channels, it was pretty straightforward after your example. However, I’m having much more trouble understanding the conditional percentile channel calculations. My understanding is that for the channel high, you start with the 75th percentile channel for a set time frame, rank ONLY the data within that time frame that is above the 75th percentile channel by position in time and magnitude. Calculate the channel high for that one day using only the coefficient and prices that are above the percentile channel, repeat process for every new day of data. If the current price is above the channel high, is this considered a +1 in the calculation for channel score, and -1 if below the channel low? Wouldn’t the channel high always be above the 75th percentile channel since you are calculating the channel high from prices which are only above the 75th percentile channel, and the channel low always below the 25th percentile channel? One commenter attempted to calculate the channel low from your example data, wouldn’t this be impossible without knowing what the 25th percentile channel was to start? Any help would be appreciated.


    • david varadi permalink*
      March 11, 2015 12:14 am

      Hi James, thank you. i think you are confusing the channel high for the price. You would compare the price to the conditional channel high and low to take positions instead of the 75th or 25th percentile. The conditional channel high and low calculate off of the chosen percentile, not the channel level implied by the chosen percentile. hope that helps!

  10. March 7, 2015 2:23 pm

    Dear David, I really like the concept and it seems there is an extra alpha in it. Have you ever tried using this on Futures? Regards

    • david varadi permalink*
      March 11, 2015 12:15 am

      hi Mo, thank you. I have never tried it on futures- but would be interesting to test for sure.

  11. PaulO permalink
    April 2, 2015 8:58 pm

    Hi David

    I just wanted to clarify what you said to James above.

    The conditional channel high&low level are calculated by price rank and time rank weighting (as per your spreadsheet example) prices above/below the percentile channel in the respective say 60day period. For any given day you will calculate one conditional channel high price and one low price.

    With these price levels you can apply the same methodology used in the pure percentile channel strategy replacing the respective calculated percentile stock levels with the conditional ones.

    Is that correct?

    • david varadi permalink*
      April 3, 2015 1:32 pm

      hi Paul, yes that is exactly correct–same strategy just different channel upper and lower band calculation.

  12. April 20, 2015 9:11 am

    Hi David – new reader to your blog here
    Which software / plugin do you use to create your graphics?
    Imagine you have coded in r / python / matlab etc but I am wondering what has produced the charts… they are very intuitive and contain a lot of information in a small space

  13. April 22, 2015 10:39 am

    David – would it be possible to get a reply to the above?
    Thanks and sorry to bug!


  1. Conditional Percentile Channel “R” Code | CSSA

Leave a Reply

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

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

Google photo

You are commenting using your Google 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

%d bloggers like this: