Overall Statistics
Total Trades
12
Average Win
0.93%
Average Loss
-0.57%
Compounding Annual Return
26.440%
Drawdown
1.100%
Expectancy
0.753
Net Profit
2.582%
Sharpe Ratio
3.295
Probabilistic Sharpe Ratio
80.933%
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
1.63
Alpha
0.172
Beta
-0.044
Annual Standard Deviation
0.055
Annual Variance
0.003
Information Ratio
2.226
Tracking Error
0.173
Treynor Ratio
-4.107
Total Fees
$39.16
Estimated Strategy Capacity
$2800000.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.Minute).Symbol
        self.Schedule.On(self.DateRules.EveryDay(self.stock), 
                 self.TimeRules.AfterMarketOpen(self.stock, 10),        
                 self.EveryDayAfterMarketOpen)
        
        

    def OnData(self,data):
        if not self.Portfolio.Invested:
            return
        if (self.UtcTime - self.ticket.Time).total_seconds()/3600 >= 1:
            self.Liquidate(STOCK)
    def EveryDayAfterMarketOpen(self):
        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:
            quantity  = self.CalculateOrderQuantity(self.stock, -1)
            self.ticket = self.MarketOrder(self.stock, quantity)
            
            
        if dnFractal:
            quantity  = self.CalculateOrderQuantity(self.stock, -1)
            self.ticket = self.MarketOrder(self.stock, quantity)
        
    
        self.Plot("Indicator", "bull", bull)
        self.Plot("Indicator", "bear", bear)