Skip to content

Commit

Permalink
Merge pull request #79 from JuliaQuant/ib-macd-wilder
Browse files Browse the repository at this point in the history
macd: add wiler option for `ema` calculation
  • Loading branch information
iblislin committed May 11, 2017
2 parents 7098772 + 451a334 commit 1e8a032
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/momentum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function cci{T,N}(ohlc::TimeArray{T,N}, ma::Int=20, c::Float64=0.015)
end

doc"""
macd(ta, fast=12, slow=26, signal=9)
macd(ta, fast=12, slow=26, signal=9; wilder=false)
Moving Average Convergence / Divergence
Expand All @@ -82,9 +82,10 @@ If the input is a multi-column `TimeArray`, the new column names will be
"""
function macd{T,N}(ta::TimeArray{T,N},
fast::Int=12, slow::Int=26, signal::Int=9)
dif = ema(ta, fast) .- ema(ta, slow)
sig = ema(dif, signal)
fast::Int=12, slow::Int=26, signal::Int=9;
wilder::Bool=false)
dif = ema(ta, fast, wilder=wilder) .- ema(ta, slow, wilder=wilder)
sig = ema(dif, signal, wilder=wilder)
osc = dif .- sig

cols = ["macd", "dif", "signal"]
Expand Down

0 comments on commit 1e8a032

Please sign in to comment.