-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Creating a Custom Indicator: The Big 4 #355
Comments
This was referenced Dec 13, 2021
Closed
Open
Repository owner
deleted a comment from
utpal4job
Nov 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In short, there are basically four steps to fully add an indicator to Pandas TA. For concrete examples, I recommend looking at @rengel8's RSX and @whubsch's MCG indicators. Essentially their indicator submission is some combination of steps outlined below.
Creating a Custom Indicator: The Big 4
This is a step by step guide to creating a Custom Indicator to provide both Standard and Pandas TA DataFrame Extensionable Indicators. So lets create a "hypothetical indicator" named
ni(close, length=10, **kwargs)
that belongs in the Trend Category. It's implementation is up to you, however at a minimum it should only rely on Pandas's dependencies (typically Pandas or NumPy calculations).Step One: Adding the Indicator to it's Category
For
ni(close, length=None, **kwargs)
to be evaluated the Standard way, we need to do two things:from .ni import ni
topandas_ta/trend/__init__.py
pandas_ta/trend/ni.py
.Now it should be callable the Standard way like a TA Lib indicator:
Step Two: Adding the Indicator to the Pandas TA DataFrame
The next two steps are required to link
ni(close, length=10, **kwargs)
with Pandas TA DataFrame. This allows you to call it from the ta extension or from the ta.strategy() extension method.pandas_ta/__init__.py
pandas_ta/core.py
.That should be it!
Now you can run
ni(close, length=10, **kwargs)
either the Standard way above or as a DataFrame Extension:Or via a Custom Strategy:
TLDR
Add and edit the file
pandas_ta/trend/ni.py
. Then modify the three files:pandas_ta/trend/__init__.py
,pandas_ta/__init__.py
, andpandas_ta/core.py
Hope this helps! Please let me know (good/bad)! Future contributions are greatly appreciated! 😎
Kind Regards,
KJ
The text was updated successfully, but these errors were encountered: