Introduction
Automation Platform
Botmain DAO
Building Trading Strategies
API References Dev Live Stream
@botmain/indicators / Class

Macd

The Macd is a momentum indicator that shows the relationship between two ExponentialMovingAverages of prices. The Macd Line is calculated as the difference between a fast and a slow Ema, and the Signal Line is an Ema of the Macd Line itself. The Macd helps signal the start of new trends and potential reversals, with high values typically indicating overbought conditions and low values suggesting oversold ones. Divergence between the Macd and price action is also a key signal of the end of a current trend, particularly when Macd is at extremely high or low values.

  • A buy signal is indicated when the Macd Line crosses above the Signal Line.
  • A sell signal is suggested when the Macd Line crosses below the Signal Line.
  • Additionally, it is common to consider buying or selling when the Macd crosses above or below the zero line. The Macd is calculated using the following formulas:
Macd = Ema(Price, fastPeriod) - Ema(Price, slowPeriod)
Signal = Ema(Macd, signalPeriod)

Constructor

Default values fastPeriod = 12, slowPeriod = 26, signalPeriod = 9

Presentation
constructor(
	
): Macd;

Properties

NameTypeDescription
historyCapacity
inherited from BaseIndicator
number

The maximum history held by the indicator. As new data comes in only this many points are kept.

historyCount
inherited from BaseIndicator
number

The number of historical points currently held by the indicator. Will never be larger than historyCapacity.

last
inherited from BaseIndicator
T
values
inherited from BaseIndicator
T[]

Methods

add()

inherited from BaseSeriesIndicator
No documentation has been provided.
Presentation
add(value: number): void;
Parameters
NameTypeDescription
value
number

Adds the latest value (usually price) to the indicator. Normally called for each indicator in onBarClose()

Returns

void