# MACD

`macd`

The gap between a fast and a slow EMA, with a signal line and histogram.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| source | source | close |  |
| fast_period | int | 12 | 1 to 5000 |
| slow_period | int | 26 | 1 to 5000 |
| signal_period | int | 9 | 1 to 5000 |

## Outputs

| Name | Kind |
| --- | --- |
| macd | value |
| signal | value |
| histogram | value |

Warm-up: max(fast_period, slow_period) + signal_period - 2 bars (33 at the defaults).

Repaints: No.

## Formula

MACD = EMA(source, fast_period) - EMA(source, slow_period), both seeded on the first value

signal = the simple average of MACD over signal_period, as MetaTrader 5 computes it

histogram = MACD - signal
