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.854
Tracking Error
0.152
Treynor Ratio
0
Total Fees
$0.00
# I schedule signal Before trade - Say 8AM
# I schedule trade after market open - Say 10AM
# I need daily indicators updated for signal before trade

class IndicatorsTest(QCAlgorithm):

    def Initialize(self):
        
        
        self.SetStartDate(2021,1,1)
        self.SetEndDate(2021,2,28)
        self.SetCash(100000)
        
        self.QQQ = self.AddEquity("QQQ", Resolution.Minute).Symbol   
        self.TickerTable = {}
       
        rsi = self.RSI(self.QQQ, 14, MovingAverageType.DoubleExponential, Resolution.Daily)
        rsiSMA = IndicatorExtensions.SMA(rsi,14)
        macd = self.MACD(self.QQQ,  12,26,9,MovingAverageType.Exponential, Resolution.Daily)
        macdSMA = IndicatorExtensions.SMA(macd,9)
        rc = self.RC(self.QQQ,12, 2, Resolution.Daily)
        ppo = self.PPO(self.QQQ, 10,12, MovingAverageType.Exponential, Resolution.Daily)
        ppoSMA = IndicatorExtensions.SMA(ppo,10)
        sma = self.SMA(self.QQQ,50,Resolution.Daily)
        
        symbolData = SymbolData(self.QQQ, rsi, rsiSMA, macd, macdSMA, rc, ppo, ppoSMA,sma)
        self.TickerTable[self.QQQ] = symbolData

        self.Log(f"{self.Time}, Price, RSI, RSI_SMA, PPO, PPO_SMA, SLOPE, MACD, MACD_SMA, HIST, SMA")

        self.SetWarmUp(timedelta(days=120)) # Minimum should be RSI period X 2 + 1
        
        # --------------------------------------------------- Schedules --------------------------------------------
       
        self.Schedule.On(self.DateRules.EveryDay("QQQ"),self.TimeRules.At(8,0), self.LogIndicator)
        self.Schedule.On(self.DateRules.EveryDay("QQQ"),self.TimeRules.AfterMarketOpen("QQQ",30), self.Trade)
       

    # ------------------------------------------------- On Data -----------------------------------------------------
    
    def OnData(self, data):
        
        if self.IsWarmingUp:
            return
   
        
    # ----------------------------------------- Trade After Market open------------------------------------------
    def Trade(self):
        
        self.QQQ_RSI = self.TickerTable[self.QQQ].Rsi.Current.Value
        self.QQQ_RSI_SMA = self.TickerTable[self.QQQ].RsiSMA.Current.Value
        self.QQQ_PPO = self.TickerTable[self.QQQ].Ppo.Current.Value
        self.QQQ_PPO_SMA = self.TickerTable[self.QQQ].PpoSMA.Current.Value
        self.QQQ_MACD = self.TickerTable[self.QQQ].Macd.Current.Value
        self.QQQ_MACD_SMA = self.TickerTable[self.QQQ].MacdSMA.Current.Value
        self.QQQ_MACD_Signal = self.TickerTable[self.QQQ].Macd.Signal.Current.Value
        self.QQQ_MACD_Histogram = self.TickerTable[self.QQQ].Macd.Histogram.Current.Value
        self.QQQ_SLOPE = self.TickerTable[self.QQQ].Rc.Slope.Current.Value
        self.QQQ_SMA = self.TickerTable[self.QQQ].Sma.Current.Value
        
        self.Log(f"Trade open:   {self.Time}, {self.Securities[self.QQQ].Price}, {self.QQQ_RSI}, {self.QQQ_RSI_SMA}, {self.QQQ_PPO}, {self.QQQ_PPO_SMA}, {self.QQQ_SLOPE}, {self.QQQ_MACD}, {self.QQQ_MACD_SMA}, {self.QQQ_MACD_Histogram}, {self.QQQ_SMA}")

   
    # ----------------------------------------- Log Indicators Before Market Open--------------------------------
    
    def LogIndicator(self):   
        
        
        # I NEED TO UPDATE INDICATORS HERE - Before trade
        
        self.QQQ_RSI = self.TickerTable[self.QQQ].Rsi.Current.Value
        self.QQQ_RSI_SMA = self.TickerTable[self.QQQ].RsiSMA.Current.Value
        self.QQQ_PPO = self.TickerTable[self.QQQ].Ppo.Current.Value
        self.QQQ_PPO_SMA = self.TickerTable[self.QQQ].PpoSMA.Current.Value
        self.QQQ_MACD = self.TickerTable[self.QQQ].Macd.Current.Value
        self.QQQ_MACD_SMA = self.TickerTable[self.QQQ].MacdSMA.Current.Value
        self.QQQ_MACD_Signal = self.TickerTable[self.QQQ].Macd.Signal.Current.Value
        self.QQQ_MACD_Histogram = self.TickerTable[self.QQQ].Macd.Histogram.Current.Value
        self.QQQ_SLOPE = self.TickerTable[self.QQQ].Rc.Slope.Current.Value
        self.QQQ_SMA = self.TickerTable[self.QQQ].Sma.Current.Value
        
        self.Log(f"Before Trade: {self.Time}, {self.Securities[self.QQQ].Price}, {self.QQQ_RSI}, {self.QQQ_RSI_SMA}, {self.QQQ_PPO}, {self.QQQ_PPO_SMA}, {self.QQQ_SLOPE}, {self.QQQ_MACD}, {self.QQQ_MACD_SMA}, {self.QQQ_MACD_Histogram}, {self.QQQ_SMA}")


# ---------------------------------------------- SymbolData --------------------------------------------------
         
class SymbolData:
    def __init__(self, symbol, rsi, rsiSMA, macd, macdSMA, rc, ppo, ppoSMA, sma):
        self.Symbol = symbol
        self.Rsi = rsi
        self.RsiSMA =rsiSMA
        self.Macd = macd
        self.MacdSMA = macdSMA
        self.Rc = rc
        self.Ppo = ppo
        self.PpoSMA = ppoSMA
        self.Sma = sma