Technical Analysis Functions

Dagobert provides all common functions for technical analysis, such as moving averages, oscillators, candlestick pattern detectors, strength indices, and Hilbert transformations. The zero crossing or reaching of a certain limit of a technical analysis function is often used as an indicator for trade signals.

Parameters:

offset The bar number for which the value is calculated, relative to the current bar; can be omitted for using the current bar.
fastPeriod The number of bars for the first period, if any; normally 12, minimum 2.
slowPeriod The number of bars for the second period, if any; normally 26, minimum 3.
signalPeriod The number of bars for the third period, if any; normally 9, minimum 2.

Range:

+/-Price variation, dependent on the asset

Usage:

macd(12,26,9) calculates the standard MACD for the current bar; macd(3,12,26,9) calculates the standard MACD for 3 bars ago.

Remarks:

Example:

// when the MACD Histogram goes above zero, buy long 
if (crossOver(macdHist(12,26,9),constant(0)))
  buyLong(0);
// sell when it goes below zero
if (crossUnder(macdHist(12,26,9),constant(0)))
  sellLong(0);

See also:

macd

► latest version online