Overall Statistics |
Total Trades 1872 Average Win 0.76% Average Loss -0.51% Compounding Annual Return 7.088% Drawdown 11.200% Expectancy 0.175 Net Profit 122.741% Sharpe Ratio 0.916 Probabilistic Sharpe Ratio 34.287% Loss Rate 53% Win Rate 47% Profit-Loss Ratio 1.48 Alpha 0.045 Beta 0.18 Annual Standard Deviation 0.081 Annual Variance 0.007 Information Ratio -0.576 Tracking Error 0.159 Treynor Ratio 0.414 Total Fees $2888.19 Estimated Strategy Capacity $79000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
class HmaIchimokuAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2010, 1, 1) self.SetCash(25000) self.qqq = self.AddEquity("QQQ", Resolution.Hour).Symbol self.hma = self.HMA(self.qqq, 12, Resolution.Hour) self.delayed_hma = IndicatorExtensions.Of(Delay(2), self.hma) # ==== System Inputs ==== TenkanPeriod = 9 KijunPeriod = 26 SenkouAPeriod = 26 SenkouBPeriod = 52 SenkouADelay = 26 SenkouBDelay = 26 self.ichimoku = self.ICHIMOKU(self.qqq, TenkanPeriod, KijunPeriod, SenkouAPeriod, SenkouBPeriod, SenkouADelay, SenkouBDelay, Resolution.Hour) closing_prices = self.History(self.qqq, 52, Resolution.Hour) for bar in closing_prices.itertuples(): tradeBar = TradeBar(bar.Index[1], bar.Index[0], bar.open, bar.high, bar.low, bar.close, bar.volume) self.hma.Update(bar.Index[1], bar.close) self.delayed_hma.Update(bar.Index[1], bar.close) self.ichimoku.Update(tradeBar) def OnData(self, data): if not (self.qqq in data.Bars and self.hma.IsReady and self.delayed_hma.IsReady and self.ichimoku.IsReady): return price = self.Securities["QQQ"].Price currentHma = self.hma.Current.Value previousHma = self.delayed_hma.Current.Value tenkan = self.ichimoku.Tenkan.Current.Value kijun = self.ichimoku.Kijun.Current.Value chikou = self.ichimoku.Chikou.Current.Value senkou_span_a = self.ichimoku.SenkouA.Current.Value senkou_span_b = self.ichimoku.SenkouB.Current.Value cloud_top = max(senkou_span_a, senkou_span_b) cloud_bottom = min(senkou_span_a, senkou_span_b) if not self.Portfolio.Invested and currentHma > previousHma and price > previousHma and price > chikou and price > cloud_top and (tenkan >= kijun or price > kijun): self.SetHoldings("QQQ",1) elif not self.Portfolio.Invested and currentHma < previousHma and price < previousHma and price < chikou and price < cloud_bottom and (tenkan <= kijun or price < kijun): self.SetHoldings("QQQ", 0) # Liquidate if self.Portfolio["QQQ"].IsLong and currentHma < previousHma and (price < previousHma or tenkan < kijun or price < tenkan or price < kijun or price < cloud_top or price < chikou): self.Liquidate() elif self.Portfolio["QQQ"].IsShort and currentHma > previousHma and (price > previousHma or tenkan > kijun or price > tenkan or price > kijun or price > cloud_bottom or price > chikou): self.Liquidate()