MACD Periods Can Be Set to Values Other Than Standard Defaults
Summary
The document addresses whether MACD must use its familiar fast, slow, and signal periods or can be adjusted for a particular analysis horizon. The response says the values are configurable in the cited technical analysis library: its example uses the common defaults, while the function accepts alternative period arguments. It also points to an example where those periods are supplied through caller-defined settings.
The response does not prescribe how to scale the periods for a five-day analysis window, nor does it establish that the proposed shorter values are appropriate. It gives no comparison, trading evidence, or guidance on selecting parameters. The practical takeaway is limited to implementation flexibility: MACD can be computed with other periods, while choosing useful settings requires justification beyond the material shown here.
Key ideas
- MACD’s fast, slow, and signal periods are configurable inputs.
- The commonly shown settings are examples rather than mandatory values.
- Alternative periods can be passed directly or supplied through caller-defined settings.
- The document does not provide a method for scaling periods to a chosen analysis horizon.
Tags
Full text
# Can MACD be calculated for values other than 12 and 26? # Can MACD be calculated for values other than 12 and 26? 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? ## Answer by rajah9 (score 1) https://quant.stackexchange.com/a/46847 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 ``` talib.MACD(prices,context.SHORTPERIOD,context.LONGPERIOD,context.SMOOTHPERIOD) ``` and you will have set `context` from the caller.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.