MACD (Moving Average Convergence Divergence)¶
- class src.lib.analysis.methods.macd.MACD(name)¶
Bases:
src.lib.analysis.methods.lstm.LSTM
,src.lib.analysis.basic.Basic
,src.lib.analysis.arbitration.Arbitration
,src.lib.analysis.performance_simulation.PerformanceSimulation
,src.lib.analysis.report_analysis.ReportAnalysis
,src.lib.analysis.summary.Summary
- calc_MACD()¶
Calculate de MACD indicator. The MACD is based on the following steps:
\[\text{MACD Line} = EMA_{VC}^{(N=12)} - EMA_{VC}^{(N=26)}\]where VC refers to the closing value of the stock, and where the exponential moving average is defined for a magnitude X (in the current application, \(X=VC\)) and length N by the self-recurring formular as follows:
\[\begin{split}EMA_{X}^{(N)}(k) = \begin{cases} EMA_{X}(0) = X(0) \\ EMA_{X}(k) = \alpha.X(k) + (1 - \alpha).EMA_{X}(k-1) \end{cases}\end{split}\]where:
\[\alpha = \frac{2}{1 + N}\]the result from \(\text{MACD Line}\) is used to calculate the \(\text{MACD Signal}\), determined by:
\[\text{MACD Signal} = EMA_{\text{MACD Line}}^{(N=9)}\]and finally:
\[\text{MACD Histogram} = \text{MACD Line} - \text{MACD Signal}\]The interpretation of the indicator (MACD Histogram) is that positive values indicate a buy recommendation, while negative indicate a sell position.