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 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 5.443 Tracking Error 0.169 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
# Your New Python File
# Displaced Awesome Oscillator Custom Indicator class CustomIndicatorAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2021,5,10) self.SetEndDate(2021, 5, 12) self.stock = self.AddCrypto('ETHUSD', Resolution.Hour).Symbol self.AwesomeOsc = CustomIndicator('Awesome Osc', 5, 34) self.RegisterIndicator(self.stock, self.AwesomeOsc, Resolution.Hour) history = self.History(self.stock, self.AwesomeOsc.Period, Resolution.Hour) if history.empty or 'close' not in history.columns: return for time, row in history.loc[self.stock].iterrows(): tradebar = TradeBar(time, self.stock, row.open, row.high, row.low, row.close, row.volume) self.AwesomeOsc.Update(tradebar) offset = 1 self.AwesomeOscDisplaced = IndicatorExtensions.Of(Delay(offset), self.AwesomeOsc) def OnData(self, data): if not (self.AwesomeOscDisplaced.IsReady and self.AwesomeOsc.IsReady): return self.Plot("Awesome Osc", "AwesomeOsc", self.AwesomeOsc.Value) self.Plot("Awesome Osc", "AwesomeOscDisplaced", self.AwesomeOscDisplaced.Current.Value) self.Plot("Awesome Osc", "Zero", 0) class CustomIndicator(PythonIndicator): def __init__(self, name, fast, slow): self.Name = name self.Time = datetime.min self.Value = 0 self.fast = SimpleMovingAverage(fast) self.slow = SimpleMovingAverage(slow) self.Period = 2*slow def Update(self, input): self.Time = input.EndTime self.Value = 0 mp = (input.High + input.Low ) / 2 if not self.fast.Update(input.Time, mp): return False if not self.slow.Update(input.Time, mp): return False self.diff = (self.fast.Current.Value - self.slow.Current.Value) self.Value = self.diff return True