-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Plot SL / TP levels #56
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
You can think of the SL/TP levels as regular overlay indicators. If you can precompute them in class MyStrategy(Strategy):
def init(self):
# Initialize an empty SL/TP-level indicator (filled with NaNs)
self.sl_level = self.I(lambda: np.repeat(np.nan, len(self.data)),
name='SL level', scatter=True)
def next(self):
# Determine actual SL/TP level
sl_level = ...
# Enter position with a contingent SL/TP order attached
self.buy(sl=sl_level)
# And mark the computed SL/TP level on the SL indicator plot
self.sl_level[-1] = sl_level Above code is untested, but something to the like should work. |
Brilliant! Thanks Kernc. I was going along those sort of lines but couldn't quite implement the indicator correctly. I guessed it would have to be some sort of logging or custom indicator. |
BTW, if anyone else is interested. The NP array needs to be made none immutable by adding the code: self.sl_level.flags.writeable = True Many thanks to the dev for pointing me on the right track! |
Is there a way to plot Stop loss and Take profit points? or indeed add any such additional plot points for specified data in scatter or line format. Useful for ensuring strategy is operating as per
The text was updated successfully, but these errors were encountered: