Overall Statistics |
Total Trades 115 Average Win 1.53% Average Loss -0.91% Compounding Annual Return 47.488% Drawdown 13.900% Expectancy 0.178 Net Profit 20.431% Sharpe Ratio 1.751 Probabilistic Sharpe Ratio 66.445% Loss Rate 56% Win Rate 44% Profit-Loss Ratio 1.69 Alpha 0.293 Beta -0.178 Annual Standard Deviation 0.19 Annual Variance 0.036 Information Ratio 1.785 Tracking Error 0.311 Treynor Ratio -1.867 Total Fees $3153.16 Estimated Strategy Capacity $35000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# Trading Consolidated HeikinAshi 6-24 from AlgorithmImports import * BAR = 120; STOCK = "SPY" class ConsolidatedHeikinAshi(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 1, 1) self.SetEndDate(2022, 6, 24) self.SetCash(1000000) res = Resolution.Minute self.symbol = self.AddEquity(STOCK, res).Symbol consolidator = TradeBarConsolidator(timedelta(minutes = BAR)) self.Consolidate(self.symbol, timedelta(minutes = BAR), self.BarHandler) self.ha = HeikinAshi() self.RegisterIndicator(self.symbol, self.ha, consolidator) self.SetWarmUp(BAR, res) def BarHandler(self, consolidated): if self.IsWarmingUp or not self.ha.IsReady: return HA_O = self.ha.Open.Current.Value HA_H = self.ha.High.Current.Value HA_L = self.ha.Low.Current.Value HA_C = self.ha.Close.Current.Value self.Plot(self.symbol, "HA_O", HA_O) self.Plot(self.symbol, "HA_H", HA_H) self.Plot(self.symbol, "HA_L", HA_L) self.Plot(self.symbol, "HA_C", HA_C) if not self.Portfolio[self.symbol].IsLong: if HA_C > HA_O: self.SetHoldings(self.symbol, 1, True, "Long Signal") elif not self.Portfolio[self.symbol].IsShort: if HA_C < HA_O: self.SetHoldings(self.symbol, -1, True, "Short Signal")