Overall Statistics
Total Trades
101
Average Win
1.04%
Average Loss
-1.04%
Compounding Annual Return
9.593%
Drawdown
8.900%
Expectancy
0.400
Net Profit
20.226%
Sharpe Ratio
0.975
Probabilistic Sharpe Ratio
45.693%
Loss Rate
30%
Win Rate
70%
Profit-Loss Ratio
1.00
Alpha
0.047
Beta
0.131
Annual Standard Deviation
0.07
Annual Variance
0.005
Information Ratio
-0.498
Tracking Error
0.192
Treynor Ratio
0.52
Total Fees
$169.43
Estimated Strategy Capacity
$1500000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
# SwingLow Custom indicator 

from collections import deque
# ------------------------
STOCK = 'SPY'; PERIOD = 7;
# ------------------------

class CustomIndicator(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 3, 8)
        self.SetCash(100000) 
        RES = Resolution.Daily
        self.stock = self.AddEquity(STOCK, RES).Symbol
        self.sl = SwingLow(PERIOD)
        self.RegisterIndicator(self.stock, self.sl, RES)
        self.SetWarmUp(PERIOD, RES)
        

    def OnData(self, data):
        if self.IsWarmingUp or not self.sl.IsReady: return
        if self.sl.Current.Value == 1:
            self.SetHoldings(self.stock,1.0)
        else:
            self.SetHoldings(self.stock,0)
            
           
class SwingLow(PythonIndicator):   
    def __init__(self, period):
        self.Time = datetime.min
        self.Value = 0
        self.queue = deque(maxlen = period)
        

    def Update(self, input):
        self.queue.appendleft(input.Low)
        self.Time = input.EndTime
        count = len(self.queue)
        
        if count != self.queue.maxlen: return
        L = self.queue    
        if ((L[0] > L[2]) and (L[1] > L[2]) and (L[3] > L[2]) and (L[4] > L[2]) and (L[5] > L[2]) and (L[6] > L[2])):
            self.Value = 1
        else: 
            self.Value = 0
            
        return (count == self.queue.maxlen)