Documentation/AlgoCode/Function reference

macdline

MACD line (fast EMA − slow EMA)

Reference/Oscillators/Function

macdline(source, fast, slow, signal)

Defaults close, 12, 26, 9. Short form macdline() or macdline(12, 26, 9) uses close. Sisters: macdsignal, macdhist.

Parameters

NameTypeDescription
sourceoptionalseries
default close
Series to use. Omit it when the first argument is a number — ema(9) means ema(close, 9).
fastoptionalint
default 12
Fast EMA.
slowoptionalint
default 26
Slow EMA.
signaloptionalint
default 9
Signal EMA of the MACD line.

Return value

series

Short form: if the first argument is a number, Dovee uses close as the source.

Example

oscillator
fastLen = input 12 as "Fast"
slowLen = input 26 as "Slow"
sigLen = input 9 as "Signal"
m = macdline(close, fastLen, slowLen, sigLen)
s = macdsignal(close, fastLen, slowLen, sigLen)
h = macdhist(close, fastLen, slowLen, sigLen)
plot m as "MACD" blue
plot s as "Signal" orange
plot h as "Hist" gray
when m crosses above s then buy
when m crosses below s then sell

See also