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

KVO gives NaN value when close = low = high #92

Open magicjase11 opened 4 years ago

magicjase11 commented 4 years ago

Hi, when using KVO,

if the close = low = high, it throws a NaN value (I'm using the Node version of this) and then never recovers. i.e. all proceeding values also become NaN.

example is: { "symbol": "vxx", "timestamp": "2020-02-19T12:18:00-05:00", "tradingDay": "2020-02-19", "open": 13.565, "high": 13.565, "low": 13.565, "close": 13.565, "volume": 400 }

changing it to { "symbol": "vxx", "timestamp": "2020-02-19T12:18:00-05:00", "tradingDay": "2020-02-19", "open": 13.565, "high": 13.566, "low": 13.565, "close": 13.565, "volume": 400 }

fixes it.

codeplea commented 4 years ago

If you look at the formula for KVO here https://tulipindicators.org/kvo you'll notice that there is a divide by zero in the case where high = low, hence the NAN. I'll need to study the code and change it so the behavior matches what happens in the limit.

Thanks for bringing this to my attention.

cdohotaru commented 3 years ago

I noticed this behaviour as well. Any updates on this @codeplea ? On a different note, I am seeing different values calculated by the indicator when I compare them to, for example, tradingview.com. I don't know if the issues are related and that's why I didn't open a new issue. Do you know why the values could be different (I'm using the same symbol and the same data source and settings)?

codeplea commented 3 years ago

@cdohotaru Tradingview differs an a lot of stuff. It really just depends on the indicator.

I don't consider TV to be an authoritative source. All of the indicators in TI are implement from their original descriptions, whenever possible.

cdohotaru commented 3 years ago

@codeplea OK, thanks for the reply. As it happens, this is the only indicator from quite I few that I used that has very different values. All the others I used match to the second decimal so I figured that maybe there's an issue with this indicator.