ta-lib-python
ta-lib-python copied to clipboard
Semantics of slowk_matype and slowd_matype are unclear
The docs for STOCH() do not document slowk_matype
or slowd_matype
. The official docs on this function do not mention these arguments at all.
Something like this should work:
from talib import MA_Type
slowk, slowd = STOCH(high, low, close, fastk_period=5, slowk_period=3, slowk_matype=MA_Type.SMA, slowd_period=3, slowd_matype=MA_Type.EMA)
All of the available types are listed here and should work for any function that allows controlling the type of moving average used to generate its output.
Thank you for your rapid response. However you do see the documentation
issue don't you? The STOCH()
docs refer to you tadoc.com, and they have
no information on the correct calling conventions. And there is nothing is
the python talib docs which says what you are saying.
So anyone looking at the docs stands to be confused by the magic numbers in the example. Interestingly, your example uses 2 different moving averages but the example uses the magic number of zero for both.
On Mon, Mar 30, 2015 at 2:16 PM, Brian Cappello [email protected] wrote:
Something like this should work:
from talib import MA_Type
slowk, slowd = STOCH(high, low, close, fastk_period=5, slowk_period=3, slowk_matype=MA_Type.SMA, slowd_period=3, slowd_matype=MA_Type.EMA)
All of the available types are listed here https://github.com/mrjbq7/ta-lib/blob/master/talib/common.pyx#L51 and should work for any function that allows controlling the type of moving average used to generate its output.
— Reply to this email directly or view it on GitHub https://github.com/mrjbq7/ta-lib/issues/77#issuecomment-87833787.
Terrence Brannon 818-359-0893 (cell)
@metaperl Yes, you are right, it could be more clear! That's very likely my fault; and probably attributable to "the curse of knowledge" - so thank you for the heads up :) In the meantime, anywhere a function takes a moving average type as a parameter, any of the MA_Type constants / magic numbers (0-8) should work. (The underlying C-level functions are type-hinted on TA_MAType, as opposed to any of the specific TA_MAType_XXX types. So either upstream's code is broken, or any of the types should work!)
The C library uses integer constants (and the python library as well, but with handy MAType.SMA
aliases), but perhaps it would be nicer if we used coercion, something like this:
>>> class MAType(object):
... def __init__(self, n):
... self.n = n
... def __int__(self):
... return self.n
...
>>> SMA = MAType(0)
>>> int(SMA)
0
Do you know how these compare to tradingview stochastic indicator? They only have 3 input fields. Length , SmoothK and SmoothD
I am using TALIB = 14,3,0,3,0 and TradingView 14,3,3 The same periods give me different results. Tradingview = K/D 46.793 / 33.0618 Script = K/D 24.8443 / 18.9583
Same Issue Here Some one please help
Do you know how these compare to tradingview stochastic indicator? They only have 3 input fields. Length , SmoothK and SmoothD
I am using TALIB = 14,3,0,3,0 and TradingView 14,3,3 The same periods give me different results. Tradingview = K/D 46.793 / 33.0618 Script = K/D 24.8443 / 18.9583
Similar Problem Help Please
I mean, you could always look at the code and it should be pretty obvious:
https://github.com/TA-Lib/ta-lib/blob/master/src/ta_func/ta_STOCH.c#L502
@RaninsVand, @gavishpoddar, @snub-fighter I was also facing the issue; solved it by computing the STOCH from its formula, see https://gist.github.com/mouchh/0e4e83443d43f3d68cfe220ccac3f36a
@mrjbq7 I wish I could understand the talib code but have to admit it is a bit too high level 😄