Overall Statistics
Total Trades
41
Average Win
0%
Average Loss
-0.19%
Compounding Annual Return
529.607%
Drawdown
85.100%
Expectancy
-1
Net Profit
632.397%
Sharpe Ratio
15.563
Probabilistic Sharpe Ratio
83.353%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
31.763
Beta
-1.023
Annual Standard Deviation
1.996
Annual Variance
3.984
Information Ratio
14.998
Tracking Error
2.026
Treynor Ratio
-30.363
Total Fees
$70.21
Estimated Strategy Capacity
$22000.00
Lowest Capacity Asset
GME SC72NCBXXAHX
import numpy as np
import talib

class EMACrossover(QCAlgorithm):
    
  
    def Initialize(self):
        
        
        self.SetStartDate(2020, 4, 1)  # Set Start Date
        self.SetEndDate(2021, 4, 30)
        self.SetCash(10000)  # Set Strategy Cash
        self.SetWarmUp(150)
        
 
        self.AddEquity("GME", Resolution.Minute)
        self.sym ="GME"
        
        self.windowOpen = RollingWindow[float](15)
        self.windowClose = RollingWindow[float](15)
        self.windowHigh = RollingWindow[float](15)
        self.windowLow = RollingWindow[float](15)
      

    def OnData(self, data):
        close = data[self.sym].Close
        open = data[self.sym].Open
        high = data[self.sym].High
        low = data[self.sym].Close
        if self.IsWarmingUp:
            self.windowOpen.Add(open)
            self.windowClose.Add(close)
            self.windowHigh.Add(high)
            self.windowLow.Add(low)
            return
            

        
        if not self.windowClose.IsReady:
            return

        #talib values
        self.windowOpen.Add(open)
        self.windowClose.Add(close)
        self.windowHigh.Add(high)
        self.windowLow.Add(low)
        open1 = np.array([self.windowOpen[i] for i in range(15)])
        close = np.array([self.windowClose[i] for i in range(15)])
        high = np.array([self.windowHigh[i] for i in range(15)])
        low = np.array([self.windowLow[i] for i in range(15)])

       # buyquantity = self.CalculateOrderQuantity(self.sym, .1)

        if not self.windowClose.IsReady :
            return
        pattern = []
        pattern.append(talib.CDL3LINESTRIKE(open1, high, low, close))
        pattern.append(talib.CDL3BLACKCROWS(open1, high, low, close))
        pattern.append(talib.CDL2CROWS(open1, high, low, close))
        pattern.append(talib.CDLBREAKAWAY(open1, high, low, close))
        pattern.append(talib.CDLBELTHOLD(open1, high, low, close))
        pattern.append(talib.CDLADVANCEBLOCK(open1, high, low, close))
        pattern.append(talib.CDL3WHITESOLDIERS(open1, high, low, close))
        pattern.append(talib.CDL3STARSINSOUTH(open1, high, low, close))
        pattern.append(talib.CDL3INSIDE(open1, high, low, close))
        pattern.append(talib.CDL3OUTSIDE(open1, high, low, close))
        
        holdings = self.Portfolio[self.sym].Quantity   
        price = self.Securities[self.sym].Price
        buyquantity = self.CalculateOrderQuantity(self.sym, .1)

        isPattern = False
        for l in pattern:
            if l.any():
                self.Debug('Pattern found')
                isPattern = True
                break
            
        
        if holdings <= 0:
              
             if isPattern:
                self.Buy(self.sym, buyquantity)
                self.StopMarketOrder(self.sym, -buyquantity, price * (1 - 0.01))
                return