TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.7k stars 1.76k forks source link

Spinning top result is wrong #178

Open yomoko opened 6 years ago

yomoko commented 6 years ago

image

Hi, as you see in the attached chart. The last 2 candles don't look like spinning top at all. Because they don't have a small body. But from ta-lib, it says they are both considered as spinning top. Can you fix that? Thanks.

pcawthron commented 6 years ago

A Spinning Top, White is described by Bulkowski as 'A small white body with shadows longer than the body'.

TA-Lib in ta_global.c says "real body is short when it's shorter than the average of the 10 previous candles' real bodies". This can be amended by editing the line:

{ TA_BodyShort, TA_RangeType_RealBody, 10, 1.0 }

Do your last two candles meet the TA-LIb conditions?

yomoko commented 6 years ago

@pcawthron I have no idea if that's the best way to define a small real body. But if I have to determine by naked eyes, the last one is 50/50, but the 2nd last doesn't look like a small real body at all.

pcawthron commented 6 years ago

'10' is the number of previous candles to compare with, obviously. My interpretation of '1.0' is that it denotes the average, '0.1' denotes 10% of the average, '3.0' denotes three times the average etc.

Issue https://github.com/mrjbq7/ta-lib/issues/113 seems to have exposed these parameters but I'm not sure.

I suppose the problem is that 'x % of the average real body of the previous y candles' doesn't define 'small' or 'short' but only defines 'relatively short'. I wonder what similar packages do?

yomoko commented 6 years ago

@pcawthron I have seen another library called 'pyti'. But I think it's not as comprehensive as talib, because it doesn't have pattern recognition feature. But the way how talib defines a spinning top is NOT sound for sure. If you have experience with T.A, you will see a lot of candles which are considered as spinning top (by talib) are not really spinning top at all.

By the way, I am using the unofficial talib d/led from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/. Since it doesn't come with 64bit version. So I can't amend the original line. It's such a pain...