Hi, 

  1. I have created an algorithm using tick resolution
  2. I consolidated the ticks into minute candles
  3. I created a rolling window of 3 with the consolidated candles (i.e. 3 x 1 min candles)
  4. I want to access the high/low of the rolling window

 

Code is as below - for some reason it won't let me attach backtest

# region imports
from AlgorithmImports import *
# endregion

# ------------------------------------------------------------
TICKER = "SPY"; OPENING_RANGE = 3; WAIT = 0; MULTIPLIER = 1
# ------------------------------------------------------------

class MeasuredMagentaDogfish(QCAlgorithm):

    def Initialize(self):
        self.SetSecurityInitializer(lambda x: x.SetDataNormalizationMode(DataNormalizationMode.Raw))
        self.SetStartDate(2023, 3, 9)  # Set Start Date
        self.SetCash(10000)  # Set Strategy Cash
        self.stock = self.AddEquity(TICKER, Resolution.Tick).Symbol
        self.high_window = RollingWindow[float](3)
        self.low_window = RollingWindow[float](3)
        self.min_value = 0
        self.max_value = 0

        consolidator = TickQuoteBarConsolidator(TimeSpan.FromMinutes(1)) ## force consolidator to produce 1 minute bars
        consolidator.DataConsolidated += self.OnCandle
        self.SubscriptionManager.AddConsolidator(self.stock, consolidator)

    def OnData(self, data):
        ## Any trading code in here will be at the tick level
        pass
        
    def OnCandle(self, sender, bar):
        ## Any trading code in here will be at the minute level
        self.high_window.Add(bar.High)
        self.low_window.Add(bar.Low)

        if self.high_window.IsReady and self.low_window.IsReady:
            self.max_value = max(list(self.high_window[0:2]))
            self.min_value = min(list(self.low_window[0:2]))

            self.Log("High: " + str(self.max_value))
            self.Log("Low: " + str(self.min_value))

I keep getting the below error - what am I doing wrong?

Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'slice'>) method. Please checkout the API documentation.
  at OnCandle
    self.max_value = max(list(self.high_window[0:2]))
   at Python.Runtime.PythonException.ThrowLastAsClrException()
   at Python.Runtime.PyObject.Invoke(PyTuple args in main.py: line 34