| Overall Statistics |
|
Total Trades 11 Average Win 5.58% Average Loss -4.79% Compounding Annual Return 238.223% Drawdown 7.200% Expectancy 0.443 Net Profit 12.395% Sharpe Ratio 3.732 Probabilistic Sharpe Ratio 68.518% Loss Rate 33% Win Rate 67% Profit-Loss Ratio 1.16 Alpha 1.829 Beta 0.708 Annual Standard Deviation 0.426 Annual Variance 0.182 Information Ratio 4.66 Tracking Error 0.413 Treynor Ratio 2.247 Total Fees $97.97 Estimated Strategy Capacity $140000000.00 Lowest Capacity Asset TQQQ UK280CGTCB51 |
# Bill Williams Fractal Indicator
STOCK = 'TQQQ';
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)