Hi - I'm looking for some help consolidating 1 minute bars into 5 minute bars (i.e. I want to run my existing strategy based off 5 min chart rather than the 1 minute chart). I'm new to coding, apologies if this is a bit basic.

I have tried looking up simialr discussions similar questions and tried the code suggested in multiple posts but nothing works and I'm very lost.

I've attached a backtest of a working algo with 1 min bars. How can I make this trade based on 5 min bars rather than one minute bars?

Based on my understanding, I need to add the below;

Add to Initialize

self.Consolidate("SPY", timedelta(minutes=5), self.OnDataConsolidated)

Add new function

def OnDataConsolidated(self, bar):

pass

What else would I need to do to get my algo to trade based of 5 minute bars?

Thanks

 

Author