Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.58 Tracking Error 0.346 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
# region imports from AlgorithmImports import * # endregion class DonchianChannelBreakoutAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetEndDate(2022, 8, 1) self.SetCash(100000) self.symbol = self.AddEquity("XOM", Resolution.Daily).Symbol self.EnableAutomaticIndicatorWarmUp = True self.indicator = self.DCH(self.symbol, 20, 20) self.SetBenchmark(self.symbol) self.can_short = False def OnData(self, data: Slice): if self.symbol not in data.Bars: return bar = data.Bars[self.symbol] if bar.Close > self.indicator.UpperBand.Current.Value and not self.Portfolio[self.symbol].IsLong: self.SetHoldings(self.symbol, 1) elif bar.Close < self.indicator.LowerBand.Current.Value: if self.can_short and not self.Portfolio[self.symbol].IsShort: self.SetHoldings(self.symbol, -1) if not self.can_short and self.Portfolio[self.symbol].IsLong: self.SetHoldings(self.symbol, 0) # Plot indicator and prices self.Plot("Custom", "Donchian Channel High", self.indicator.UpperBand.Current.Value) self.Plot("Custom", "High Price", bar.High) self.Plot("Custom", "Close Price", bar.Close) self.Plot("Custom", "Low Price", bar.Low) self.Plot("Custom", "Donchian Channel Low", self.indicator.LowerBand.Current.Value)