Overall Statistics
Total Trades
11
Average Win
0.12%
Average Loss
0.00%
Compounding Annual Return
52.069%
Drawdown
0.100%
Expectancy
39.935
Net Profit
0.345%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
57%
Win Rate
43%
Profit-Loss Ratio
94.52
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
2.244
Tracking Error
0.089
Treynor Ratio
0
Total Fees
$12.83
class ResistanceTachyonCoreWave(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 11, 18)  # Set Start Date
        self.SetEndDate(2020, 11, 20)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        
        # Number of symbols returned by Coarse Universe
        self.__numberOfSymbols = 20
        
        # Call coarse and fine universe
        self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)

        # Initialze list for selected symbols from universe
        self.selectedSymbols = []
        
        
        self.ema_nine_win = RollingWindow[IndicatorDataPoint](2)
        self.ema_eighteen_win = RollingWindow[IndicatorDataPoint](2)
        self.ema_thirtysix_win = RollingWindow[IndicatorDataPoint](2)
        
        self.five_min_check = False
        
    # When data is received  
    def OnData(self, data):
        
        # Make a list of the symbols from the universe
        symbols = self.selectedSymbols
        
        # Get 36 minutes of history for all symbols
        history = self.History(symbols, 36, Resolution.Minute)
        
        # Variable for what percent will be invested in each stock
        percent_invested = 1 / len(symbols)
        
        # Loop through for each symbol in our list
        for symbol in symbols:
            
            # Get local history
            symbolhistory = history.loc[str(symbol)]
            
            # Initialize all current moving averages
            symbolEMAnine = self.EMA(symbol, 9, Resolution.Minute)
            symbolEMAeighteen = self.EMA(symbol, 18, Resolution.Minute)
            symbolEMAthirtysix = self.EMA(symbol, 36, Resolution.Minute)
            symbolMINvolume = self.SMA(symbol, 3, Resolution.Minute)
            
            # Initialize high, low, close
            symbol_high = symbolhistory.high[35]
            symbol_prev_high = symbolhistory.high[34]
            symbol_low = symbolhistory.low[35]
            symbol_close = symbolhistory.close[35]
            
            # Update Moving Averages
            for tuple in symbolhistory.itertuples():
                symbolEMAnine.Update(tuple.Index, tuple.close)
                symbolEMAeighteen.Update(tuple.Index, tuple.close)
                symbolEMAthirtysix.Update(tuple.Index, tuple.close)
                symbolMINvolume.Update(tuple.Index, tuple.volume)
            
            # Initialize the EMAs for past values
            self.ema_nine = self.EMA(symbol, 9, Resolution.Minute)
            self.ema_nine.Updated += self.ema_one
            self.ema_eighteen = self.EMA(symbol, 18, Resolution.Minute)
            self.ema_eighteen.Updated += self.ema_two
            self.ema_thirtysix = self.EMA(symbol, 36, Resolution.Minute)
            self.ema_thirtysix.Updated += self.ema_three
            
            # Consolidate to five minute data
            #self.Consolidate(symbol, timedelta(minutes=5), self.FiveMinuteBarHandler)
            
            # If the window for the EMAs is ready
            if self.ema_nine_win.IsReady:
                
                # Get the slope of each EMA and make sure all are greater
                ema_nine_increasing = self.ema_nine_win[0] > self.ema_nine_win[1]
                ema_eighteen_increasing = self.ema_eighteen_win[0] > self.ema_eighteen_win[1]
                ema_thirtysix_increasing = self.ema_thirtysix_win[0] > self.ema_thirtysix_win[1]
                all_emas_increasing = ema_nine_increasing and ema_eighteen_increasing and ema_thirtysix_increasing
            
            # EMA9 > EMA18 * 1.05
                nine_prct_greater_eighteen = float(str(symbolEMAnine)) > (float(str(symbolEMAeighteen)) * 1.005)
                
                # If the 3 minute volume > 80000
                if float(str(symbolMINvolume)) > 80000:
                    # EMA9 > EMA18 > EMA36
                    if float(str(symbolEMAnine)) > float(str(symbolEMAeighteen)) and float(str(symbolEMAeighteen)) > float(str(symbolEMAthirtysix)):
                        # Current high > Last high
                        if symbol_high > symbol_prev_high:
                            # Low > EMA9
                            if float(symbol_low) > float(str(symbolEMAnine)):
                                # EMA9 is at least 5% greater than EMA18
                                if nine_prct_greater_eighteen:
                                    # Checks if the EMAs are increasing
                                    if all_emas_increasing:
                                        # Makes sure on the five minute EMA9 > EMA18 > EMA36
                                        #if self.five_min_check:
                                            # If the symbol has not been invested, invest
                                        #if not self.Portfolio[symbol].Invested:
                                        self.SetHoldings(symbol, percent_invested)
                                            #self.StopMarketOrder(symbol, (percent_invested * -1), (0.995 * symbol_close))
                                        
                if float(str(symbolEMAnine)) < float(str(symbolEMAeighteen)) or float(str(symbolEMAeighteen)) < float(str(symbolEMAthirtysix)):
                    #if self.Portfolio[symbol].Invested:
                    self.Liquidate(symbol)
            
            
            
    def CoarseSelectionFunction(self, coarse):
        
        # Sort descending by daily dollar volume
        sortedByDollarVolume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)
        pricefilter = [x for x in sortedByDollarVolume if x.Price > 1 and x.Price < 700 and x.Volume > 1000000]
        # Return the symbol objects of the top entries from our sorted collection
        return [ x.Symbol for x in pricefilter[:self.__numberOfSymbols] ]

    def FineSelectionFunction(self, fine):
        
        # Retrieve 10 days of historical data for each symbol
        symbols = [x.Symbol for x in fine]
        history = self.History(symbols, 10, Resolution.Daily)
        
        # Iterate through symbols
        for symbol in symbols:
            
            # Find hsitory for specific symbol
            symbolVolumeHistory = history.loc[str(symbol)]

            # Create SMA for symbol and register it with algorithm
            symbolSMA = SimpleMovingAverage(10)

            # Iterate through historical data
            for tuple in symbolVolumeHistory.itertuples():
                # Update SMA with data time and volume
                symbolSMA.Update(tuple.Index, tuple.volume)
                
            # If the SMA Volume > 3,500,000, add to selected symbols
            if float(str(symbolSMA)) > float(3500000):
                self.selectedSymbols.append(symbol)
    
        # Return selected symbols
        return self.selectedSymbols

    # Updates the rolling window for the EMA9
    def ema_one(self, sender, updated):
       self.ema_nine_win.Add(updated)
       
    # Updates the rolling window for the EMA18
    def ema_two(self, sender, updated):
       self.ema_eighteen_win.Add(updated)
       
    # Updates the rolling window for the EMA36
    def ema_three(self, sender, updated):
       self.ema_thirtysix_win.Add(updated)
       
    #def FiveMinuteBarHandler(self, consolidated):
    #    symbolEMAnine = self.EMA(consolidated.Symbol, 9, Resolution.Minute)
    #    symbolEMAnine.Update(self.Time, consolidated.Close) 
        
     #   symbolEMAeighteen = self.EMA(consolidated.Symbol, 18, Resolution.Minute)
     #   symbolEMAeighteen.Update(self.Time, consolidated.Close) 
        
     #   if symbolEMAnine > symbolEMAeighteen:
     #       self.five_min_check = True
     #   else:
     #       self.five_min_check = False
        #self.Log(f"{consolidated.EndTime} >> FortyFiveMinuteBarHandler >> {symbolEMAnine}")