Learn R Programming

cryptoQuotes (version 1.3.0)

macd: Add MACD indicators to the chart

Description

[Experimental]

Traders and investors use the MACD indicator to identify trend changes, potential reversals, and overbought or oversold conditions in the market. It is a versatile tool that can be applied to various timeframes and asset classes, making it a valuable part of technical analysis for many traders.

Usage

macd(
  nFast = 12,
  nSlow = 26,
  nSig = 9,
  maType = "SMA",
  percent = TRUE,
  internal = list(),
  ...
)

Value

Invisbly returns a plotly object.

Arguments

nFast

Number of periods for fast moving average.

nSlow

Number of periods for slow moving average.

nSig

Number of periods for signal moving average.

maType

Either:

  1. A function or a string naming the function to be called.

  2. A list with the first component like (1) above, and additional parameters specified as named components. See Examples.

percent

logical; if TRUE, the percentage difference between the fast and slow moving averages is returned, otherwise the difference between the respective averages is returned.

internal

An empty list. Used for internal purposes. Ignore.

...

Other arguments to be passed to the maType function in case (1) above.

See Also

Other chart indicators: add_event(), alma(), bollinger_bands(), chart(), dema(), ema(), evwma(), fgi(), hma(), lsr(), rsi(), sma(), volume(), vwap(), wma(), zlema()

Other subcharts: add_event(), fgi(), lsr(), rsi(), volume()

Examples

Run this code
# script: scr_charting
# date: 2023-10-25
# author: Serkan Korkmaz, serkor1@duck.com
# objective: Charting in general
# script start;

## charting the klines
## with indicators as
## subcharts
chart(
  ticker     = BTC,
  main       = kline(),
  sub        = list(
    volume(),
    macd()
  ),
  indicator = list(
    bollinger_bands(),
    sma(),
    alma()
  ),
  options = list(
    dark = TRUE,
    deficiency = FALSE
  )
)

## charting the MACD-indicator
## with klines as subcharts
chart(
  ticker     = BTC,
  main       = macd(),
  sub        = list(
    volume(),
    kline()
  ),
  indicator = list(
    bollinger_bands(),
    sma()
  ),
  options = list(
    dark = TRUE,
    deficiency = FALSE
  )
)

# script end;

Run the code above in your browser using DataLab