# MACD

> Moving Average Convergence Divergence: the difference of a fast and a slow EMA, its signal line and the histogram between them, with automatic divergence lines.

Updated: 2026-10-25T00:01:52.000Z · https://chartrider.com/docs/indicators/macd/

## What you see
In its own pane: histogram bars (positive color above zero, negative color below), the MACD line and the signal line. The pane scales to the lowest and highest value of all three over the visible candles. Green and red lines mark divergences between price and the MACD line.

## How it is calculated
- A fast and a slow [EMA](https://chartrider.com/docs/indicators/ema/) of the close (`EMA Fast Period`, `EMA Slow Period`). Each starts with the simple average of its first N closes.
- `MACD = fast EMA − slow EMA`, in price units.
- `Signal` = EMA of the MACD line over `Signal Period`, starting with the simple average of its first values.
- `Histogram = MACD − Signal`

Divergences use the MACD line with `EMA Fast Period` as the swing window and the same rules as the [RSI](https://chartrider.com/docs/indicators/rsi/).

## How to read it
- MACD above zero: the fast EMA is above the slow one, momentum points up. Below zero it points down.
- The MACD crossing its signal line, which is the histogram changing sign, is the classic signal. Shrinking histogram bars show momentum fading before the cross.
- Values are in price units, so their size depends on the market's price level.

## Using it in strategies
Outputs: `macd`, `signal`, `histogram`, and `value`, which is also the MACD line. In the [Trade Setup](https://chartrider.com/docs/strategies/trade-setup/), "Compare" with `histogram` above 0 checks that the MACD is above its signal; as a trigger it fires when the histogram turns positive. "With" at center 0 on `macd` is a trend filter. In [WickScript](https://chartrider.com/docs/wickscript/), `m = macd(close, 12, 26, 9)` gives `m.line`, `m.signal` and `m.histogram`; note that the built-in calls the MACD line `line`, while this indicator's output is `macd`. With `use indicator "MACD" with fastPeriod 12, slowPeriod 26, signalPeriod 9 as md` you read `md.histogram` and the other outputs.

## Settings

Open the settings with the slider icon next to the indicator (Indicators, `F3`). Numeric settings can be swept as Step 1 / Step 2 parameters when you run a strategy.

### Inputs

| Setting | Type | Default | Description |
|---|---|---|---|
| EMA Fast Period | Number | `12` | Period of the fast EMA. Also the swing window for divergence detection. (min 1) |
| EMA Slow Period | Number | `26` | Period of the slow EMA. (min 1) |
| Signal Period | Number | `9` | Period of the EMA that turns the MACD line into the signal line. (min 1) |
| Height | Number | `50` | Height of the pane in pixels. (min 10) |
| Look Back Range | Number | `2` | Candles after a swing point that are checked before the swing counts for a divergence. Higher values give fewer, later divergences. (min 1) |

### Styles

| Setting | Type | Default | Description |
|---|---|---|---|
| MACD Line Color | Color | `#1ca6bf` |  |
| Signal Line Color | Color | `#d13570` |  |
| Histogram Color Positive | Color | `#9ccd86` |  |
| Histogram Color Negative | Color | `#fd4649` |  |

## Outputs

These values can be used in Trade Setup triggers, filters and exits (see [Trade Setup](https://chartrider.com/docs/strategies/trade-setup/)) and in WickScript.

| Output | In WickScript | Description |
|---|---|---|
| value | `value` | The MACD line, the same as `macd`. |
| macd | `macd` | Fast EMA minus slow EMA. |
| signal | `signal` | EMA of the MACD line. |
| histogram | `histogram` | MACD line minus signal line. |

## Use in WickScript

`use indicator` creates this indicator inside a script, with settings by their ID. Each output is a field of the name after `as`. See [WickScript indicators](https://chartrider.com/docs/wickscript/indicators/).

```wickscript
wickscript 1
indicator "MACD from the list" in pane
use indicator "MACD" with fastPeriod 12 as myMacd
show myMacd.value as line "value"
```
