I am working on time-series classification problem using Convolutional Neural Networks in Python. The data-set used is financial stock market data (like yahoo finance). I am using some technical indicators calculated using raw values high, low, volume, open, close.

One of the technical indicators is MACD (Moving Average Convergence Divergence) using TA Library. However, it is written, in most places, that it is calculated for n_fast = 12 and n_slow = 26 periods (considering trading period to be 6 days which is 5 days in our case) with RSI (Relative Strength Index) being calculated for 14 days and n_sign = 9 (parameter of macd_diff() in TA library).

So, if I am calculating RSI for 5 days analysis period (with 5 days trading period) then how do we set these n_fast and n_slow values according to it? Should these be n_fast = 3 and n_slow = 8. Also, what should be the value of n_sign then?


1 Answer 1


Please take a look at the TA-lib documentation on momentum indicators.

While the example for MACD contains 12 and 26:

macd, macdsignal, macdhist = MACD(close, fastperiod=12, slowperiod=26, signalperiod=9)

you are free to set them to other numbers.

There are also examples for MACD that use a context at this source code browser. One function uses


and you will have set context from the caller.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.