Skip to contents

Register an indicator in the global registry

Usage

ledgr_register_indicator(indicator, name = NULL, overwrite = FALSE)

Arguments

indicator

A ledgr_indicator object.

name

Optional registry name (defaults to indicator id).

overwrite

Replace an existing registration with the same name.

Value

The indicator, invisibly.

Examples

local({
  registry <- get(".ledgr_indicator_registry", asNamespace("ledgr"))
  if (exists("example_last_close", envir = registry, inherits = FALSE)) {
    rm(list = "example_last_close", envir = registry)
  }
  on.exit(if (exists("example_last_close", envir = registry, inherits = FALSE)) {
    rm(list = "example_last_close", envir = registry)
  }, add = TRUE)
  ind <- ledgr_indicator(
    id = "example_last_close",
    fn = function(window) tail(window$close, 1),
    requires_bars = 1
  )
  ledgr_register_indicator(ind)
})