Overall Statistics |
Total Orders 364 Average Win 8.76% Average Loss -2.48% Compounding Annual Return 78.165% Drawdown 39.500% Expectancy 0.619 Start Equity 100000 End Equity 1010799.04 Net Profit 910.799% Sharpe Ratio 1.514 Sortino Ratio 1.916 Probabilistic Sharpe Ratio 70.991% Loss Rate 64% Win Rate 36% Profit-Loss Ratio 3.53 Alpha 0.568 Beta 0.175 Annual Standard Deviation 0.389 Annual Variance 0.151 Information Ratio 1.135 Tracking Error 0.413 Treynor Ratio 3.371 Total Fees $0.00 Estimated Strategy Capacity $2200000.00 Lowest Capacity Asset BTCUSD 2XR Portfolio Turnover 24.82% |
from AlgorithmImports import * class TechnicalIndicatorsAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 1, 1) # Set Start Date self.SetEndDate(2022, 1, 1) # Set End Date self.SetCash(100000) # Set Strategy Cash # Add the cryptocurrency pair self.symbol = self.AddCrypto("BTCUSD", Resolution.Hour).Symbol # Define indicators self.hammer = self.CandlestickPatterns.Hammer(self.symbol) self.hanging_man = self.CandlestickPatterns.HangingMan(self.symbol) self.doji = self.CandlestickPatterns.Doji(self.symbol) self.spinning_top = self.CandlestickPatterns.spinning_top(self.symbol) self.engulfing = self.CandlestickPatterns.engulfing(self.symbol) self.rsi = self.RSI(self.symbol, 14, MovingAverageType.Wilders, Resolution.Hour) # Moving averages self.sma10 = self.SMA(self.symbol, 10, Resolution.Hour) self.sma05 = self.SMA(self.symbol, 5, Resolution.Hour) self.ema20 = self.EMA(self.symbol, 20, Resolution.Hour) self.sma30 = self.SMA(self.symbol, 30, Resolution.Hour) self.sma50 = self.SMA(self.symbol, 50, Resolution.Hour) self.sma200 = self.SMA(self.symbol, 200, Resolution.Hour) self.sma600 = self.SMA(self.symbol, 600, Resolution.Hour) self.sma40 = self.SMA(self.symbol, 40, Resolution.Hour) self.sma120 = self.SMA(self.symbol, 120, Resolution.Hour) self.ema05 = self.EMA(self.symbol, 5, Resolution.Hour) self.ema10 = self.EMA(self.symbol, 10, Resolution.Hour) self.ema30 = self.EMA(self.symbol, 30, Resolution.Hour) self.ema65 = self.EMA(self.symbol, 65, Resolution.Hour) self.ema100 = self.EMA(self.symbol, 100, Resolution.Hour) self.ema150 = self.EMA(self.symbol, 150, Resolution.Hour) self.ema500 = self.EMA(self.symbol, 500, Resolution.Hour) self.ema600 = self.EMA(self.symbol, 600, Resolution.Hour) # Schedule plot updates # self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.AfterMarketOpen(self.symbol, 1), self.PlotIndicators) def OnData(self, data): if not data.ContainsKey(self.symbol): return # Example trading logic #buying if (self.rsi.Current.Value > 55) and (self.ema10.Current.Value > self.ema20.Current.Value > self.ema65.Current.Value > self.ema150.Current.Value): if not self.Portfolio[self.symbol].Invested: self.SetHoldings(self.symbol, 1) elif self.rsi.Current.Value < 40 and ((self.ema10.Current.Value < self.ema65.Current.Value) or (self.ema20.Current.Value < self.ema65.Current.Value)): if self.Portfolio[self.symbol].Invested: self.Liquidate(self.symbol) #selling #if self.rsi.Current.Value < 60 and self.ema10.Current.Value < self.ema20.Current.Value < self.ema65.Current.Value < self.ema150.Current.Value: # if not self.Portfolio[self.symbol].Invested: # self.SetHoldings(self.symbol, 1) #elif self.rsi.Current.Value < 60 and ((self.sma10.Current.Value > self.ema65.Current.Value) or (self.ema20.Current.Value > self.ema65.Current.Value)): # if self.Portfolio[self.symbol].Invested: # self.Liquidate(self.symbol) def PlotIndicators(self): self.Plot("RSI", "RSI", self.rsi.Current.Value) self.Plot("SMA", "SMA10", self.sma10.Current.Value) self.Plot("SMA", "SMA20", self.sma20.Current.Value)