Back

Comparing a value to percentiles within a Rolling Window

Hi there,

I am trying to find a way in C# to – as an example - store the Bollinger Bands values of a given security in a 100-period Rolling Window and then check if the current BollingerBands.StandardDeviation value is higher than the 80% percentiles within that Rolling Window.

I found this article which let me think this is possible to do in Python, but I am new to programming and I am struggling to make something that works in C#. I hope this will be an easy one for some of you!

Best

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Pi..R

There is no ready-to-use "percentile" method in C#. Here is my attempt to implement it with the feature you described, with simply comparing current StandardDeviation with all values stored in rolling windows.

You could also find more information about usage of rolling window and indicators. Hope it helps!

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Link,

Thank you very much for your help, this is a nice and efficent work around! This will perfectly make the trick for now, and I will try to expand that later to also be able to retrieve the [X] percentile value as well. I will share my solution here if I manage.

Thanks again!

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed