> For the complete documentation index, see [llms.txt](https://algotrade-1.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algotrade-1.gitbook.io/docs/indicators-library-and-guide/macd-moving-average-convergence-divergence.md).

# MACD (Moving Average Convergence Divergence)

#### What is MACD?

The **MACD** (Moving Average Convergence Divergence) is a trend-following momentum indicator that helps traders identify when momentum is building or fading in either direction. It’s built from three key components:

* **MACD Line**: The difference between a fast and slow EMA.
* **Signal Line**: An EMA of the MACD Line, used to identify buy/sell signals.
* **Histogram**: A visual representation of the difference between the MACD Line and the Signal Line.

It works especially well to confirm trends, detect potential reversals, or time entries and exits more precisely.

***

#### Why Use MACD in Your Strategy?

MACD (Moving Average Convergence Divergence) is a powerful momentum and trend-following indicator that helps you identify the **strength, direction, and timing** of a trend. Here's why it's valuable in your strategy:

* **Trend Confirmation**: MACD helps confirm whether a trend is strengthening or weakening by analyzing the convergence or divergence of two moving averages.
* **Momentum Shifts**: Crossovers of the MACD line and signal line highlight potential momentum shifts great for catching early trend reversals.
* **Bullish & Bearish Divergences**: When MACD diverges from price, it can signal a loss of strength and a potential reversal point.
* **Flexible Across Timeframes**: Works well on both low and high timeframes, making it suitable for scalping, swing trading, and long-term strategies.
* **Combines Well with Other Tools**: Often used alongside RSI or Bollinger Bands to confirm entry/exit signals and reduce false positives.

Using MACD gives your strategy a structured approach to momentum and trend analysis—essential for building reliable, automated trading systems.

***

#### MACD Settings in the AlgoBuilder

| Setting         | Description                                         | Default |
| --------------- | --------------------------------------------------- | ------- |
| Fast EMA        | Shorter-term EMA used in the MACD Line calculation  | 12      |
| Slow EMA        | Longer-term EMA used in the MACD Line calculation   | 26      |
| Signal Line EMA | EMA of the MACD Line used to generate trade signals | 9       |

You can tweak these values to adjust sensitivity. Smaller values make it react faster, while larger values smooth out the signals.

***

#### Entry Examples Using MACD

**Bullish Crossover:**\
Enter a long position when the MACD Line crosses **above** the Signal Line.\
→ This is a common buy signal indicating bullish momentum may be starting.

**Bearish Crossover:**\
Enter a short position when the MACD Line crosses **below** the Signal Line.\
→ Suggests the start of downward momentum or weakening bullish pressure.

***

#### 🎯 Take Profit / Exit (Long) Examples

**MACD Line Reversal:**\
Exit long when the MACD Line peaks and starts turning back toward the Signal Line.\
→ Suggests the upward momentum is weakening.

**Histogram Shrinking:**\
Exit long when the Histogram begins to shrink after a strong run.\
→ Can indicate a potential trend stall or early reversal.

***

#### 🎯 Take Profit / Exit (Short) Examples

**MACD Line Reversal Upward:**\
Exit short when the MACD Line starts rising toward or crosses over the Signal Line.\
→ Indicates potential momentum loss in the downtrend.

**Histogram Begins to Rise:**\
Exit short if the red Histogram bars begin decreasing.\
→ Signals early strength in price recovery or a possible bounce.

***

#### Tips for Using MACD in the AlgoBuilder

* Combine MACD with RSI or EMA to avoid false positives or confirm momentum alignment.
* Use histogram flips as early warnings for trend reversals or loss of momentum.
* Customize the Fast/Slow EMA values to suit your timeframe — shorter timeframes may require quicker reaction, while longer timeframes need more smoothing.
* Use MACD as both an entry trigger and a momentum-based exit filter for smarter trade management.
