Overall Statistics |
Total Trades 4292 Average Win 0.42% Average Loss -0.28% Compounding Annual Return 22.325% Drawdown 10.900% Expectancy 0.143 Net Profit 126.471% Sharpe Ratio 1.274 Probabilistic Sharpe Ratio 66.984% Loss Rate 55% Win Rate 45% Profit-Loss Ratio 1.53 Alpha 0.106 Beta 0.433 Annual Standard Deviation 0.124 Annual Variance 0.015 Information Ratio 0.266 Tracking Error 0.139 Treynor Ratio 0.365 Total Fees $13599.06 Estimated Strategy Capacity $13000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
class MultidimensionalVentralCoil(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 1, 1) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.QQQ = self.AddEquity("QQQ", Resolution.Minute).Symbol self.rsi = RelativeStrengthIndex(14) self.RegisterIndicator("QQQ", self.rsi, timedelta(minutes=30)) self.rsiSMA = IndicatorExtensions.SMA(self.rsi, 14) thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=30)) self.SubscriptionManager.AddConsolidator(self.QQQ, thirtyMinuteConsolidator) thirtyMinuteConsolidator.DataConsolidated += self.OnThirtyMinuteBar self.barWindow = RollingWindow[TradeBar](2) self.rsiWindow = RollingWindow[IndicatorDataPoint](2) self.rsi.Updated += self.rsiUpdated self.entryPrice = 0 self.profit = self.GetParameter("profit") self.profit = float(self.profit) if self.profit else 0.07 self.loss = self.GetParameter("loss") self.loss = float(self.loss) if self.loss else -0.05 def rsiUpdated(self, sender, updated): self.rsiWindow.Add(updated) def OnThirtyMinuteBar(self, sender, bar): self.barWindow.Add(bar) if not self.barWindow.IsReady: return holdings = self.Portfolio["QQQ"].Quantity currentBar = self.barWindow[0] previousBar = self.barWindow[1] currentHigh = currentBar.High currentLow = currentBar.Low currentRsi = self.rsiWindow[0] previousRsi = self.rsiWindow[1] # currentRsisma = # previousRsisma = previousHigh = previousBar.High previousLow = previousBar.Low if holdings == 0: if self.rsi.Current.Value > self.rsiSMA.Current.Value: self.SetHoldings("QQQ", 1) # else: # self.SetHoldings("QQQ", 0) if holdings < 0 and currentLow > previousLow or self.Portfolio["QQQ"].UnrealizedProfitPercent > self.profit or self.Portfolio["QQQ"].UnrealizedProfitPercent < self.loss: self.Liquidate("QQQ") if holdings > 0 and currentHigh < previousHigh or self.Portfolio["QQQ"].UnrealizedProfitPercent > self.profit or self.Portfolio["QQQ"].UnrealizedProfitPercent < self.loss: self.Liquidate("QQQ") self.Plot("My Custom Chart", "RSI", self.rsi.Current.Value) self.Plot("My Custom Chart", "RSI SMA", self.rsiSMA.Current.Value) # class IndicatorTests(QCAlgorithm): # def Initialize(self): # # In addition to other initialize logic: # self.SetStartDate(2022, 1, 10) # #self.SetEndDate(2019, 1, 1) # self.SetWarmUp(14) # self.AddEquity("XMB", Resolution.Hour) # #self.vix = self.AddIndex("VIX", Resolution.Minute).Symbol # self.rsi = self.RSI("XMB", 14, Resolution.Minute) # Creating a RSI # self.rsiSMA = IndicatorExtensions.SMA(self.rsi, 14) # Creating the SMA on the RSI # # Creates a Rolling Window indicator to keep the 2 TradeBar # self.window = RollingWindow[TradeBar](2) # For other security types, use QuoteBar # def OnData(self, data): # if self.IsWarmingUp: return # if data.ContainsKey("XMB"): # self.window.Add(data.Bars["XMB"]) # currentHigh = self.window[0].High # previousHigh = self.window[1].High # self.Debug(self.window[0].High) # self.Plot("RSI SMA", "RSI", self.rsi.Current.Value) # self.Plot("RSI SMA", "SMA of RSI", self.rsiSMA.Current.Value) # if self.rsi.Current.Value > self.rsiSMA.Current.Value and self.rsi.Current.Value < 50 and not self.Securities[self.vix].Price > 40 and currentVol.Value > previousVol.Value*2: # self.SetHoldings("XMB", 1) # elif self.rsi.Current.Value > 70 and self.rsi.Current.Value < self.rsiSMA.Current.Value or self.Securities[self.vix].Price > 40 : # self.Liquidate() # # self.Plot("RSI SMA", "SMA of RSI 2", self.rsiSMA2.Current.Value) # def OnEndOfDay(self): # if self.Portfolio["XMB"].UnrealizedProfitPercent < -0.02: # self.Liquidate() # #self.AllowTrades = False