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