Overall Statistics
Total Trades
12
Average Win
1.16%
Average Loss
-1.55%
Compounding Annual Return
54.802%
Drawdown
1.600%
Expectancy
0.457
Net Profit
4.279%
Sharpe Ratio
4.089
Probabilistic Sharpe Ratio
84.212%
Loss Rate
17%
Win Rate
83%
Profit-Loss Ratio
0.75
Alpha
0.381
Beta
0.033
Annual Standard Deviation
0.09
Annual Variance
0.008
Information Ratio
3.919
Tracking Error
0.18
Treynor Ratio
11.167
Total Fees
$39.27
Estimated Strategy Capacity
$41000000.00
Lowest Capacity Asset
CMB R735QTJ8XC9X
# Bill Williams Fractal Indicator

STOCK = 'JPM';

class BillWilliamsFractal(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2022, 1, 1)
        #self.SetEndDate(2021, 11, 11) 
        self.stock = self.AddEquity(STOCK, Resolution.Daily).Symbol
        

    def OnEndOfDay(self, symbol):

        H = self.History(self.stock, 5, Resolution.Daily)['high']
        L = self.History(self.stock, 5, Resolution.Daily)['low'] 
        
        upFractal = (L[-5] > L[-3] < L[-4]) and (L[-2] > L[-3] < L[-1])
        dnFractal = (H[-5] < H[-3] > H[-4]) and (H[-2] < H[-3] > H[-1])
        
        bull = 1 if upFractal else 0
        bear = -1 if dnFractal else 0
        
        if upFractal:
            self.SetHoldings(STOCK, -1)
            self.current = self.Time
        if dnFractal:
            self.SetHoldings(STOCK, 1)
            self.current = self.Time
        
            
        if self.Portfolio[STOCK].Quantity != 0 and (self.Time - self.current).days == 1:
            self.Liquidate()
        
       # if self.Portfolio[STOCK].AveragePrice * .99 > self.Securities[STOCK].Close :
        #    self.SetHoldings(STOCK, 0.0)
        
        self.Plot("Indicator", "bull", bull)
        self.Plot("Indicator", "bear", bear)