MACD (Indicator)
Input Information
Name | Expression | Default | Description |
FastLength | Numeric | 12 | Number of bars to include in calculation of the fast exponential average. |
SlowLength | Numeric | 26 | Number of bars to include in calculation of the slow exponential average. |
MACDLength | Numeric | 9 | Number of bars used to calculate the MACD exponential average. |
AlertIfCrossUp | Numeric | 1 | Set to 1 for an alert to be triggered when the MACD histogram's value crosses from below 0 to above 0; Otherwise, set to 0 for no alert to be triggered in this case. |
AlertIfCrossDown | Numeric | 1c | Set to 1 for an alert to be triggered when the MACD histogram's value crosses from above 0 to below 0; Otherwise, set to 0 for no alert to be triggered in this case. |
MACDDiff_Up_Color | Numeric | UpColorDefault | Color for positive values of MACDDiff. |
MACDDiff_Down_Color | Numeric | DownColorDefault | Color for negative values of MACDDiff. |
BackgroundColorAlertCell | Numeric | DarkGray | Color for grid cell background when alert criteria is met. |
Market Synopsis
The Moving Average Convergence Divergence indicator calculates 2 exponential moving averages of the lengths specified by the inputs FastLength and SlowLength. The difference between these 2 averages is then plotted as the MACD. This value is also averaged for the number of bars specified by the input MACDLength and then plotted as the MACDAvg. Finally, the difference between the MACD and the MACD average is calculated and plotted as the MACDDiff. As a trend-following indicator, the MACD may be interpreted similarly to other moving averages. When the MACD crosses above the MACD Average, it may be the beginning of an uptrend. Conversely, when the MACD crosses below the MACD Average, it may be the beginning of a downtrend. As an oscillator, the MACD can indicate overbought and oversold conditions.
Plot Information
Number | Name | Default Color | Description |
Plot1 | MACD | Yellow | Plots the MACD value. |
Plot2 | MACDAvg | Cyan | Plots the MACD exponential average. |
Plot3 | MACDDiff | Red | Plots the difference between the MACD and MACDAvg as a histogram. |
Plot4 | ZeroLine | Dark Green | Plots a reference line at zero. |
Plot5 | CrossBarsAgo | Default | In a grid, plots the number of bars ago that the last cross of MACDDiff over or under 0 occurred. |
When applied to a chart, this indicator displays four plots in a separate subgraph from the price data. In a grid, displays five plots.