Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
Overlap Studies
Momentum Indicators
Volume Indicators
Volatility Indicators
Cycle Indicators
Price Transform
Statistic Functions
Math Transform
Math Operators
Pattern Recognition
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Calculates the Moving Average Convergence/Divergence and returns the MACD line, signal line and histogram.

talib.MACD(inReal)
talib.MACD(inReal, optInFastPeriod)
talib.MACD(inReal, optInFastPeriod, optInSlowPeriod)
talib.MACD(inReal, optInFastPeriod, optInSlowPeriod, optInSignalPeriod)

Examples

Compute the Moving Average Convergence/Divergence from the latest K-lines.

javascript
function main() { var records = exchange.GetRecords() if (!records) return var ret = talib.MACD(records) // Output: [MACD line array, signal line array, histogram array] Log(ret) }
python
import talib def main(): records = exchange.GetRecords() if not records: return ret = talib.MACD(records.Close) # Output: (MACD line array, signal line array, histogram array) Log(ret)

Returns

TypeDescription

array

Two-dimensional array: [MACD line array, signal line array, histogram array] (a tuple in the same order in Python).

Arguments

NameTypeRequiredDescription

inReal

Record array / numeric array

Yes

K-line array (close prices are used) or numeric array; in Python, pass a numeric array such as records.Close.

optInFastPeriod

number

No

Fast period. Default 12.

optInSlowPeriod

number

No

Slow period. Default 26.

optInSignalPeriod

number

No

Signal line period. Default 9.

See Also

Remarks

TA-Lib equivalent: MACD(Records[Close],Fast Period = 12,Slow Period = 26,Signal Period = 9) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)].