I'm a newbie so forgive the mess, I am just stitching examples together to lean and no matter what I change trades always happen on ‘2024-08-23’ .  Ive changed the SetStartDate & SetStartDate, no change.  thought maybe there was no data for the ticker since im testing with the free account, so i tried tsla and spy, didnt work.  what am I doing wrong?

 

example:

677
|
12:20:27
:
2024-08-23 09:31:00: 0: Time: 08/23/2024 13:31:00 OrderID: 1 EventID: 2 Symbol: SPY Status: Filled Quantity: 20 FillQuantity: 20 FillPrice: $557.4705 OrderFee: 1 USD
678
|
12:20:27
:
2024-08-23 09:32:00: 0: Time: 08/23/2024 13:32:00 OrderID: 2 EventID: 2 Symbol: SPY Status: Filled Quantity: -20 FillQuantity: -20 FillPrice: $557.2313 OrderFee: 1 USD
679
|
12:20:27
:
2024-08-23 09:33:00: 0: Time: 08/23/2024 13:33:00 OrderID: 3 EventID: 2 Symbol: SPY Status: Filled Quantity: 20 FillQuantity: 20 FillPrice: $557.2612 OrderFee: 1 USD
680

 

from AlgorithmImports import *
import numpy as np
from collections import deque
class HKUSTIntradayMomentum(QCAlgorithm):

    def initialize(self):
        self.set_name("Intra-MOMO backtest")
        self.SetStartDate(2024, 11, 18)
        self.SetEndDate(2024, 11, 18)
        #start = self.SetStartDate(2024, 11, 18)
        #end = self.SetEndDate(2024, 11, 18)
        self.set_cash(25000)
        self.set_brokerage_model(BrokerageName.INTERACTIVE_BROKERS_BROKERAGE, AccountType.MARGIN)
 
        self._symbol = self.add_equity("SPY", Resolution.MINUTE).symbol
        self.symbol = "SPY"
        self.bar = RollingWindow[TradeBar](10)
        self.debug(f"symbol is: {self._symbol}")
        #self.debug(f"start date is: {start}")
        #self.debug(f"end date is: {end}")
        self._macd = self.macd(self._symbol, 3, 9, 5, MovingAverageType.Exponential)
        self.register_indicator(self._symbol, self._macd, Resolution.MINUTE)


    def on_data(self, data):
        open_orders = self.transactions.get_open_orders()
        holdings = self.portfolio[self.symbol]
        quantity = holdings.quantity
        bar_slice = data.bars.get(self.symbol)
        self.bar.Add(bar_slice)
        

        if self._macd.is_ready:
            # The current value of self._macd is represented by self._macd.current.value
            self.plot("MovingAverageConvergenceDivergence", "macd", self._macd.current.value)
            # Plot all attributes of self._macd
            self.plot("MovingAverageConvergenceDivergence", "fast", self._macd.fast.current.value)
            self.plot("MovingAverageConvergenceDivergence", "slow", self._macd.slow.current.value)
            self.plot("MovingAverageConvergenceDivergence", "signal", self._macd.signal.current.value)
            self.plot("MovingAverageConvergenceDivergence", "histogram", self._macd.histogram.current.value)

        if len(open_orders) != 0: return

        bar_pattern = ((self.bar[0].open > self.bar[0].close) or (self.bar[1].open > self.bar[1].close) or (self.bar[2].open > self.bar[2].close))

        
       
        if (self.time.day > 10 and quantity <= 0) and (self._macd.current.value >= self._macd.signal.current.value):
            self.market_order(self.symbol, 20, True)

        
        elif (self.time.day > 20 and quantity > 0) or ((self._macd.current.value <= self._macd.signal.current.value) and (quantity > 0)):
      
            self.market_order(self.symbol, -20, True)
            
            
    def on_order_event(self, order_event: OrderEvent) -> None:
        order = self.transactions.get_order_by_id(order_event.order_id)
        if order_event.status == OrderStatus.FILLED:
            self.debug(f"{self.time}: {order.type}: {order_event}")