The following is a short algo I created. There are two things I need help with.

 

class CreativeTanGoshawk(QCAlgorithm):

 

    def Initialize(self):

        self.SetStartDate(2020,5,14)  #Set Start Date

        self.SetEndDate(2021,5,14)    #Set End Date

        self.SetCash(100000)  # Set Strategy Cash

        self.spy = self.AddEquity("TQQQ", Resolution.Daily)

        self.window = RollingWindow[TradeBar](2)

        self.DefaultOrderProperties.TimeInForce = TimeInForce.Day

 

    def OnData(self, data):

        self.window.Add(data["TQQQ"])

        if not (self.window.IsReady): return

        low = self.window[0].Low

        high = self.window[0].High 

        close = self.window[0].Close

        Open = self.window[0].Open

        low1 = self.window[1].Low

        high1 = self.window[1].High 

        close1 = self.window[1].Close

        if not self.Portfolio.Invested:

            if (low < low1) and (high < high1) and (close < Open) and (close < close1):

                self.StopMarketOrder("TQQQ", 100, high)

        else:

            if self.Securities["TQQQ"].Price >= 1 + fill_price:

                self.Liquidate("TQQQ")

 

    

    def OnOrderEvent(self, orderevent):

        if orderevent.Status == OrderStatus.Filled:

            fill_price = orderevent.FillPrice

            self.Debug(fill_price)

 

1 . I need to change the fill_price (in bold) to actually get the fill price of the order. 

2. When I run a backtest, I keep getting order cancelled for every order. 

 

Could someone please help me with this?