MarketTechnicals.jl icon indicating copy to clipboard operation
MarketTechnicals.jl copied to clipboard

Keltnerbands

Open banachtech opened this issue 2 years ago • 0 comments

Keltner bands implementation has a minor bug. Input w is unused and the range is hardcoded as 2.

function keltnerbands(ohlc::TimeArray, n::Integer = 20, w::AbstractFloat = 2.0;
                      h = :High, l = :Low, c = :Close)
  kma = rename(ema(typical(ohlc, h=h, l=l, c=c), n), :kma)
  rng = atr(ohlc, n, h=h, l=l, c=c)

  kup = rename(kma .+ (2 .* rng), :kup)
  kdn = rename(kma .- (2 .* rng), :kdn)

  merge(kup, merge(kma, kdn))
end

banachtech avatar Oct 11 '22 04:10 banachtech