Back

Efficient calculation of Indicator

Hi guys

I am trying to calculate an indicator using a rolling window whereby I basically take a range, and see if a datapoint corresponds to the minimum or maximum of that range. Over a period of time, this gives you the tradebars which correspond to the 'highs' and the 'lows' of an equity. I then calculate the average pct fall and the average pct rise between the highs and the lows (technical analysis yes....not very scientific) and use these as indicators to trade on.

Only thing is, when I calculate my rollingwindow in a given period, my code recalculates it every period. i.e. it goes like:

--> calculate min and max from today to (e.g.) 365 days ago
--> get technical indicators
-->end of day
--> calculate min and max from today to 365 days ago.

Ideally I would like the Rolling Window to get bigger as time goes on. And for the indicators to update without losing data (which I currently am).

This will A) make my code more how I want it and B) improve the efficiency of backtesting.

Code attached. Any pointers (related or unrelated) more than welcome. I am not a cs programmer by trade so would not be surprised if the steps are very counter intuitive.

 

Also I would have expected more trades to be honest so bonus points if anyone can tell my why only one order got placed!
 

 

Thanks!!

Hugo

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 Jack,

 

Thanks very much for writing this through - super helpful! Love your work!

Best

Hugo

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