TulipCharts / tulipindicators

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

Reference Indicators #59

Closed codeplea closed 4 years ago

codeplea commented 5 years ago

I'm thinking of adding a new feature: reference indicators.

These would be alternative implementations for select indicators which calculate the function in the simplest way possible. No consideration would be given to speed.

For example, the Chandelier Exit indicator (https://github.com/TulipCharts/tulipindicators/pull/58) would be calculated by calling ti_atr(), ti_max(), ti_min(), and then doing some very simple math (maybe with ti_add(), or other utility functions). It would be slow as heck (it makes 4+ passes through the input), but we could look at it and know that's it's correct. It also shouldn't be pretty easy/fast to implement.

The idea is to make these indicators so simple that they can't be wrong.

Then we would add another testing program. This program would call ti_ce() and compare it's outputs to ti_ce_ref() for a bunch of random data and parameters. The same program can also test against streaming indicators, once they are implemented (https://github.com/TulipCharts/tulipindicators/issues/57).

rdbuf commented 5 years ago

Awesome idea!

We will get rid of a number of headaches this way. No need to rely on third-party implementations to check against anymore (which can too be wrong or absent at all).

codeplea commented 5 years ago

The basic groundwork is merged in.

It would be nice to see benchmark expanded now to compare old indicators vs reference indicators vs streaming indicators. benchmark could probably use a good refactoring too. Perhaps it and smoke should share some of the test and compare code.