Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Indicator support #16

Open
simonsonjack opened this issue Apr 10, 2019 · 3 comments
Open

Custom Indicator support #16

simonsonjack opened this issue Apr 10, 2019 · 3 comments
Assignees

Comments

@simonsonjack
Copy link
Contributor

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)
@SherlockTT
Copy link

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

@ikamanu
Copy link

ikamanu commented Jun 5, 2021

+1 to this...

@antoinedray
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants