Overall Statistics |
Total Trades 12 Average Win 14.88% Average Loss -0.22% Compounding Annual Return 213.679% Drawdown 33.700% Expectancy 55.664 Net Profit 214.663% Sharpe Ratio 3.004 Probabilistic Sharpe Ratio 84.870% Loss Rate 17% Win Rate 83% Profit-Loss Ratio 67.00 Alpha 1.465 Beta 0.435 Annual Standard Deviation 0.497 Annual Variance 0.247 Information Ratio 2.867 Tracking Error 0.499 Treynor Ratio 3.426 Total Fees $348.49 Estimated Strategy Capacity $6400000.00 Lowest Capacity Asset UNG TRW1K1OYJ7TX |
# N Day Breakout UNG # ----------------------- ETF = "UNG"; PERIOD = 20; # ----------------------- class N_DayBreakout(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 4, 12) self.SetEndDate(2022, 4, 12) self.SetCash(100000) res = Resolution.Daily self.etf = self.AddEquity(ETF, res).Symbol self.HH = self.MAX(self.etf, PERIOD, res, Field.High) self.HHD = IndicatorExtensions.Of(Delay(1), self.HH) self.LL = self.MIN(self.etf, PERIOD, res, Field.Low) self.LLD = IndicatorExtensions.Of(Delay(1), self.LL) self.SetWarmUp(PERIOD + 2, res) def OnData(self, data: Slice): if self.IsWarmingUp or not (self.HHD.IsReady and self.LLD.IsReady): return price = self.Securities[self.etf].Close self.Plot(self.etf, 'HHD', self.HHD.Current.Value) self.Plot(self.etf, 'LLD', self.LLD.Current.Value) self.Plot(self.etf, 'price', price) if price >= self.HHD.Current.Value: self.SetHoldings(self.etf, 1.0) elif price <= self.LLD.Current.Value: self.SetHoldings(self.etf, -1.0)