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
-0.748
Tracking Error
0.2
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
# Awesome Oscillator Custom Indicator

class CustomIndicatorAlgorithm(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2018,1,1)   
        self.SetEndDate(2021, 5, 13)     
        self.stock = self.AddEquity('SPY', Resolution.Daily).Symbol
        self.AwesomeOsc = CustomIndicator('Awesome Osc', 5, 34)
        self.RegisterIndicator(self.stock, self. AwesomeOsc, Resolution.Daily)
        history = self.History(self.stock, self. AwesomeOsc.Period, Resolution.Daily)
        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)


    def OnData(self, data):
        if self.AwesomeOsc.IsReady:
            self.Plot("Awesome Osc", "AwesomeOsc", self.AwesomeOsc.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 = 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