Count high to low in CBT

There is a way to retrieve the historical number of "high to low > x%" throght CBT ?
Thank you for any input....
NE

What value are you referring to when counting "high to low > x%" ? Portfolio equity? Stock price while in a trade? Something else?

Please see: How to ask a good question

Sorry for that.

I mean stock price, not while in a trade.
The number of times that a stock register a "rolling drawdown" > x%.
RollingDrawdown = (c / ref(c,-x)-1);

Thank you
NE

First, you don't need the CBT for that kind of analysis. A simple exploration will do.

Second, you have called this a "Rolling Drawdown" but in fact you're using something more like ROC, except that you have used X twice: once for a percentage, and once for a lookback. If you really want something more akin to drawdown, perhaps something like this would work for you:

pctDD = 100 * (C / Highest(C) - 1);

Keep in mind that this will produce an array with the % Drawdown for each bar until a new high is created, for example:
C = 100, pctDD = 0
C = 90, pctDD = -10
C = 80, pctDD = -20
C = 85, pctDD = -15
C = 105, pctDD = 0

If you want the maximum drawdown between two new equity highs, you'll need to do some additional work.

2 Likes

Thank you very much mradtke for response.
What i would like to do, is to put the average pctdd of every stock of a certain watchlist, in the backtest report, that's why i need CBT.

You can certainly do that as well, it will just be more work to get the same result.