---
id: "M:cAlgo.API.Internals.IIndicatorsAccessor.MacdHistogram(System.Int32,System.Int32,System.Int32)"
kind: "method"
type: "T:cAlgo.API.Internals.IIndicatorsAccessor"
url: "https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/MacdHistogram/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# IIndicatorsAccessor.MacdHistogram

Member of [IIndicatorsAccessor](https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/index.md).

## MacdHistogram(int longCycle, int shortCycle, int signalPeriods)

The MACD Histogram is a momentum indicator measured by typically subtracting a 26 period moving average from a 12 period moving average.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
MacdHistogram MacdHistogram(int longCycle, int shortCycle, int signalPeriods)
```

Python:

```python
api.Indicators.MacdHistogram(longCycle: int, shortCycle: int, signalPeriods: int) -> MacdHistogram
```

### Parameters

- `longCycle` (`int`, Python `int`): The long period used calculation.
- `shortCycle` (`int`, Python `int`): The short period used calculation.
- `signalPeriods` (`int`, Python `int`): The period used for the calculation of the signal.

### Returns

`MacdHistogram` — The Macd Histogram indicator instance

### Examples

C#:

```csharp
var macd = Indicators.MacdHistogram(26, 12, 9);
Print("MACD histogram: {0}, signal: {1}", macd.Histogram.LastValue, macd.Signal.LastValue);
```

Python:

```python
macd = api.Indicators.MacdHistogram(26, 12, 9)
api.Print(f"MACD histogram: {macd.Histogram.LastValue}, signal: {macd.Signal.LastValue}")
```

## MacdHistogram(DataSeries source, int longCycle, int shortCycle, int signalPeriods)

Initializes the MacdHistogram indicator instance for a specific source series

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
MacdHistogram MacdHistogram(DataSeries source, int longCycle, int shortCycle, int signalPeriods)
```

Python:

```python
api.Indicators.MacdHistogram(source: DataSeries, longCycle: int, shortCycle: int, signalPeriods: int) -> MacdHistogram
```

### Parameters

- `source` (`DataSeries`, Python `DataSeries`): The source series to be applied
- `longCycle` (`int`, Python `int`): The long period used calculation.
- `shortCycle` (`int`, Python `int`): The short period used calculation.
- `signalPeriods` (`int`, Python `int`): The period used for the calculation of the signal.

### Returns

`MacdHistogram` — The Macd Histogram indicator instance

### Examples

C#:

```csharp
var macd = Indicators.MacdHistogram(Bars.MedianPrices, 26, 12, 9);
Print("MACD histogram of median prices: {0}", macd.Histogram.LastValue);
```

Python:

```python
macd = api.Indicators.MacdHistogram(api.Bars.MedianPrices, 26, 12, 9)
api.Print(f"MACD histogram of median prices: {macd.Histogram.LastValue}")
```

