Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
class VentralTransdimensionalCoil(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 10, 28)
        self.SetEndDate(2019, 10, 29)
        self.SetCash(100000) 
        
        # Subscribe to data feed
        self.sym = self.AddEquity("UBER", Resolution.Minute).Symbol

        # Setup rolling windows for candles
        self.rolling_window = RollingWindow[TradeBar](120) # 2 hour lookback
        self.first_candles = RollingWindow[TradeBar](120)  # First 2 hours in a trading day


    def OnData(self, data):
        if not data.ContainsKey("UBER"):
            return
        
        # Add new candle to rolling windows
        self.rolling_window.Add(data['UBER'])
        if not self.first_candles.IsReady:
            self.first_candles.Add(data['UBER'])
        
        # Ensure indicators are ready
        if not (self.first_candles.IsReady and self.rolling_window.IsReady):
            return
        
        # High/Low of the candle 2 hours ago
        max_2_hrs_ago = self.rolling_window[self.rolling_window.Count-1].High
        min_2_hrs_ago = self.rolling_window[self.rolling_window.Count-1].Low
        
        # High/Low of first 2 hours of trading day
        min_first_2_hrs = float("inf")
        max_first_2_hrs = 0
        for candle in self.first_candles:
            if candle.Low < min_first_2_hrs:
                min_first_2_hrs = candle.Low
            if candle.High > max_first_2_hrs:
                max_first_2_hrs = candle.High
        
        # Log values
        self.Log(f"Min 2 Hours Ago: {min_2_hrs_ago}")
        self.Log(f"Max 2 Hours Ago: {max_2_hrs_ago}")
        self.Log(f"Min First 2 hours: {min_first_2_hrs}")
        self.Log(f"Max First 2 hours: {max_first_2_hrs}\n")
    
    def OnEndOfDay(self):
        self.first_candles.Reset()