Research icon indicating copy to clipboard operation
Research copied to clipboard

Custom Indicator support

Open simonsonjack opened this issue 6 years ago • 3 comments

Enable support for custom indicators, similar to how one would be created for a QC Algorithm

class CustomSimpleMovingAverage:
    def __init__(self, name, period):
        self.Name = name
        self.Time = datetime.min
        self.Value = 0
        self.IsReady = False
        self.queue = deque(maxlen=period)

    def __repr__(self):
        return "{0} -> IsReady: {1}. Time: {2}. Value: {3}".format(self.Name, self.IsReady, self.Time, self.Value)

    # Update method is mandatory
    def Update(self, input):
        self.queue.appendleft(input.Close)
        count = len(self.queue)
        self.Time = input.EndTime
        self.Value = sum(self.queue) / count
        self.IsReady = count == self.queue.maxlen

custom = CustomSimpleMovingAverage('SPY', 21)
x = qb.Indicator(CustomSimpleMovingAverage, 'SPY', 360, Resolution.Daily)

simonsonjack avatar Apr 10 '19 22:04 simonsonjack

@AlexCatarino Hey do you know when this might be available? Thanks! :)

SherlockTT avatar Mar 17 '20 12:03 SherlockTT

+1 to this...

ikamanu avatar Jun 05 '21 02:06 ikamanu

+1

antoinedray avatar Apr 28 '22 15:04 antoinedray