-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Plot indicators dynamically computed in next() #87
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
Comments
I understand you'd like to define and show an indicator whose values are computed in First of all, it's usually incomparably faster to precompute values in vector form in When the computation can't be simply or clearly vectorized, you can probably do something like: class SomeStrategy(Strategy):
def init(self):
# Pre-allocate and designate an indicator, fill with NaNs
self.indicator = self.I(lambda: np.repeat(np.nan, len(self.data.Close)))
def next(self):
# Compute indicator value at time t
values = myIndicator(self.data.Close, ...)
# If myIndicator returns a vector, we are only interested in its last value
value = values[-1]
self.indicator[-1] = value This is from top of the head. Let me know if it works. |
Thanks. I believe your answer has given me a better understanding of what you are attempting with the framework. I will try again to place the indicator in the init() and if that fails, then try your recommendation. Thanks for the help |
Hopefully you got it working. 🚀 |
First, great product. I've been looking for something like this for a while. What are your future plans/direction with the product?
Second, my question is an extension of issue #74. I understand how to add indicators. But, is there a way that their results are added to the
bt.plot()
? For example below; I would likeindicator1
andindicator2
plotted. Note: my indicators do not pass in any values created in theinit()
method.I thought of wrapping them in the
self.I()
, but as stated above, they are using data created from data generated in theinit()
. Is there a way to getc_var
ands_var
plotted usingbt.plot()
.Thanks
The text was updated successfully, but these errors were encountered: