Overall Statistics
Total Trades
8
Average Win
2.18%
Average Loss
0%
Compounding Annual Return
25.911%
Drawdown
6.500%
Expectancy
0
Net Profit
9.007%
Sharpe Ratio
1.706
Probabilistic Sharpe Ratio
63.160%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.223
Beta
0.102
Annual Standard Deviation
0.158
Annual Variance
0.025
Information Ratio
-0.386
Tracking Error
0.481
Treynor Ratio
2.635
Total Fees
$14.57
class ResistanceMultidimensionalFlange(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 3, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.spy = self.AddEquity('SPY', Resolution.Minute).Symbol
        
        self.closeWindow = RollingWindow[float](19)
        self.Schedule.On(self.DateRules.EveryDay('SPY'), self.TimeRules.BeforeMarketClose('SPY'), self.UpdateWindow)

        self.Schedule.On(self.DateRules.EveryDay('SPY'), self.TimeRules.BeforeMarketClose('SPY', 10), self.ComputeSMA)

    def UpdateWindow(self):
        if self.CurrentSlice.ContainsKey(self.spy):
            self.closeWindow.Add(self.CurrentSlice[self.spy].Close)
    
    def ComputeSMA(self):
        if not self.closeWindow.IsReady:
            return
        if self.CurrentSlice.ContainsKey(self.spy):
            close =  self.CurrentSlice[self.spy].Close
            sma20 = (sum(list(self.closeWindow)) + close) / 20
            
            self.Plot('Custom', 'SMA20', sma20)
            if sma20 > self.CurrentSlice[self.spy].Close:
                self.SetHoldings(self.spy, 1.0)
            else:
                self.Liquidate()