Moving Average Convergence Divergence (MACD)
Indicator that uses 2 different averages of prices to calculate a trend’s momentum, direction and strength.
Moving Average Convergence Divergence (MACD) is considered one of the most important indicators. It uses 2 different averages of prices to calculate a trend’s momentum, direction and strength.
Trading application
MACD and Signal Line oscillate through a 0 reference line. There are 2 kinds of events that suggest a buy or sell action. When MACD crosses up through the Signal Line, it is a buy signal. Conversely, if MACD crosses down through the Signal Line, it is seen as a sell signal.
We can also consider it a signal to buy when MACD crosses the 0 line from negative into positive values, and a signal to sell when it crosses the 0 line from positive to negative values. As long as MACD is above 0, we can consider the asset to be in a bullish trend, while MACD staying below zero indicates bearish conditions.
Divergences also reflect bullish or bearish conditions: we can consider it bearish if the asset’s price increases more than the MACD (e.g. reaching a new high while the indicator doesn’t), in the same way that it would be bullish to see the asset’s price decreasing more than the MACD does.
Calculation
MACD Line:
Signal Line:
EMA: Exponential Moving Average
Parameters
Input Parameters
Name | Type | Range of value | Description |
| int | <1, int.MaxValue> | Number of bars to calculate the fast EMA inside MACD indicator. |
| int | <1, int.MaxValue> | Number of bars to calculate the slow EMA. |
| int | <1, int.MaxValue> | The number of bars to calculate the EMA signal line. |
Output Parameters
Indicator ouptuts an object of values.
Name | Type | Range of value | Description |
| double | (0, double.MaxValue) | Output value of MACD indicator. |
| double | (0, double.MaxValue) | Average of MACD indicator. |
| double | (0, double.MaxValue) | The difference of MACD indicator. |
Examples
Complete example
Last updated