TulipCharts / tulipindicators

Technical Analysis Indicator Function Library in C
https://tulipindicators.org/
GNU Lesser General Public License v3.0
818 stars 154 forks source link

Default options for indicators? #119

Open mctb32 opened 1 year ago

mctb32 commented 1 year ago

Can you please consider adding default option values to indicator descriptors? I'm making a charting application where the user can add any indicators to the charts and now it's up to the user to set the initial options as the library cannot provide any sensible defaults. Many indicators have standard or customary options (for example 20 periods, 2 standard deviations for Bollinger bands) and even if they don't the library could provide safe defaults.

Anyway, thanks for making a great library!

codeplea commented 1 year ago

I feel that is out of scope for this library. I would think there is only a few indicators with "standard" values anyway. For 95% of them, a default doesn't make sense at all.

What might make more sense is if the library interface showed minimum, maximum, and type info for each option parameter. However, that's not currently planned either.

You could, obviously, program in your own defaults to your charting library.

mctb32 commented 1 year ago

Thanks for your answer. You are right, having access to min, max and type info would be great. I’ll probably end up having to keep a parallel database with defaults, maybe I will parse them from the online indicator documentation? I see most of the indicators have example calculations with sensible defaults listed.

Anyway, I don’t think such features would feel out of scope for the library, as you are already providing some frontend features, such as human readable full indicator name and input/output names that are not essential to the core computations.

KIC commented 1 year ago

It would still be nice to provide a reasonable set of default values such that we don't have to search investopedia for each and every indicator individually. Maybe as a simple json file might be good enough. In the meanwhile, I have tried to get the default values from talib.

def get_info(indicator):
    try:
        import talib.abstract as ta
        default_values = list(getattr(ta, indicator.__name__.upper(), None).parameters.values())
    except:
        default_values = []