> For the complete documentation index, see [llms.txt](https://docs.itradingbot.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.itradingbot.net/en/signals-and-strategy-conditions/indicators/macd.md).

# MACD

<mark style="color:$tint;">MACD calculates the difference between two moving averages, the signal line and the histogram. In the ISignal constructor, you can choose one of the four signal conditions and use it for entry or exit.</mark>

### Fill in the period

<mark style="color:$tint;">Add the MACD to the block you want. The instrument is out of the question. Select</mark> <mark style="color:$tint;"></mark><mark style="color:$tint;">**The TF**</mark> <mark style="color:$tint;"></mark><mark style="color:$tint;">and Candle Type, then fill in the periods of fast, slow and signal moving averages.</mark>

<mark style="color:$tint;">Each period is set to an integer between 2 and 50 bars. The default values of the new card are 12, 26 and 9, respectively. It's the basic interface settings, not the recommendation.</mark>

<mark style="color:$tint;">Select</mark> <mark style="color:$tint;"></mark><mark style="color:$tint;">**Calculation**</mark> <mark style="color:$tint;"></mark><mark style="color:$tint;">in the Bar Closing or Intersection (secondly). In the second case, the bar is checked. Its meanings may change before closing.</mark>

### Select the condition

<mark style="color:$tint;">The following directions are shown when the Reverse is turned off.</mark>

**Intersection of MACD and signal line**

<mark style="color:$tint;">A long signal is generated when the MACD moves down to or above the signal line. Short when MACD moves from above to below the line. The previous value must be strictly on the other side.</mark>

**Cross-referencing of MACD and zero**

<mark style="color:$tint;">Long signal: the previous MACD value was below zero, current is zero or higher. Short: the previous one was above zero, the current one is zero or lower.</mark>

**By the growth of the histogram**

<mark style="color:$tint;">The long signal appears at the beginning of the site, where the histogram is undeniable and its value increases. Short at the beginning of the plot where the histogram is negative and its value decreases or remains the same. No new signal is generated to continue the same route.</mark>

**By reducing the histogram**

<mark style="color:$tint;">The long signal appears at the beginning of the site where the histogram is negative, but its value increases to zero. Short at the beginning of the plot where the histogram is non-negative and its value decreases or remains the same. Continuing the same state doesn't create a new signal.</mark>

<mark style="color:$tint;">For the conditions of the histogram, three consecutive values are compared: current and two previous ones. Focus on the sign and change of value; the color of the column in another chart may indicate a different setting.</mark>

### Check the entry or exit

<mark style="color:$tint;">The reverse switch changes the direction of the signals in places. The signal must be in line with the task. In the reverse-free exit block, the short signal is used to close the long, the long to close the short.</mark>

<mark style="color:$tint;">To exit, select the action in the</mark> <mark style="color:$tint;"></mark><mark style="color:$tint;">**When the signal is received**</mark> <mark style="color:$tint;"></mark><mark style="color:$tint;">field. The deviation mode depends on the configuration and type of robot and does not guarantee profitable execution.</mark>

<mark style="color:$tint;">Keep the card and check the conditions of the task according to</mark> [<mark style="color:$tint;">The ISignal instructions</mark>](/en/signals-and-strategy-conditions/isignal-entry-filters-and-exit.md)<mark style="color:$tint;">. The MACD filter is set by a separate card. The presence of a signal does not confirm the acceptance and execution of an order on the exchange.</mark>
