Moving Average Convergence Divergence indicator (MACD) shows the difference between two moving averages of different lengths. This custom MACD allows using different moving averages for all smoothings.

The Signal line is signal period moving average of MACD. Histogram shows the difference between MACD and Signal (MACD - Signal).

Hierarchy

Constructors

  • Parameters

    • priceChart: TradingChart
    • chart: ChartXY<UIBackground>
    • openValues: number[]
    • highValues: number[]
    • lowValues: number[]
    • closeValues: number[]
    • longPeriodCount: number
    • shortPeriodCount: number
    • signalPeriodCount: number
    • macdColor: Color
    • signalColor: Color
    • positiveStrongColor: Color
    • positiveWeakColor: Color
    • negativeStrongColor: Color
    • negativeWeakColor: Color
    • lineWidth: number
    • rowIndex: number

    Returns MovingAverageConvergenceDivergenceCustom

Methods

  • Gets the indicator name.

    Returns string

    The indicator name.

  • Sets the colors for the histogram.

    Parameters

    • positiveStrongColor: string

      The positive strong color for Histogram.

    • positiveWeakColor: string

      The positive weak color for Histogram.

    • negativeStrongColor: string

      The negative strong color for Histogram.

    • negativeWeakColor: string

      The negative weak color for Histogram.

    Returns void

  • Sets the width of the MACD and Signal lines.

    Parameters

    • newWidth: number

      New line width.

    Returns void

  • Sets the color of the MACD line.

    Parameters

    • newColor: string

      New line color as string, should be in HEX format e.g. #FFFFFF.

    Returns void

  • Sets the moving average types used to calculate MACD and signal lines.

    Parameters

    • shortMovingAverage: MovingAverageType

      Moving average type used to calculate the short moving average.

    • longMovingAverage: MovingAverageType

      Moving average type used to calculate the long moving average.

    • signalMovingAverage: MovingAverageType

      Moving average type used to calculate the signal line.

    Returns void

  • Sets the name of the indicator.

    Parameters

    • name: string

      New indicator name.

    Returns void

  • Moves the indicator from its calculated position forward or backward.

    Parameters

    • newOffset: number

      New offset value.

    Returns void

  • Sets the numbers of time periods (n) used to calculate the indicator.

    Parameters

    • longPeriodCount: number

      New long period count.

    • shortPeriodCount: number

      New short period count.

    • signalPeriodCount: number

      New signal period count.

    Returns void

  • Sets the color of the Signal line.

    Parameters

    • newColor: string

      New line color as string, should be in HEX format e.g. #FFFFFF.

    Returns void

  • Sets which values the indicator calculations are based on.

    Parameters

    • source: Source

      Values to base the calculations on.

    Returns void

  • Sets the type of the indicator's value label(s).

    Parameters

    Returns void

  • Sets the visibility of the indicator. Hiding the indicator via setVisible(false) does not remove it. Use dispose() to delete any indicator.

    Parameters

    • visible: boolean

      Visibility of the indicator.

    Returns void

  • Programmatically opens the indicator settings menu.

    Returns void