Momentum Indicators

Example

using Temporal, Indicators, Plots
X = quandl("CHRIS/CME_CL1", rows=252, sort='d')
x = cl(X)
x.fields[1] = :Crude

m = macd(x)
r = rsi(x)
p = psar(hl(X))

f1 = plot(x, linewidth=3, color=:black)
scatter!(p, color=:blue, markersize=2)
f2 = plot(m, linewidth=2, color=[:green :cyan :orange])
hline!([0.0], linestyle=:dash, color=:grey, label="")
f3 = plot(r, linewidth=2, color=:gold)
hline!([20, 80], linestyle=:dot, color=[:green, :red], label="")
plot(f1, f2, f3, layout=@layout[a{0.6h}; b{0.2h}; c{0.2h}])
/home/travis/.julia/packages/GR/oiZD3/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
Did you start 'gksqt'?

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

Reference

Indicators.adxMethod
adx(hlc::Array{T}; n::Int64=14, wilder=true)::Array{T}

Average directional index

Output

  • Column 1: DI+
  • Column 2: DI-
  • Column 3: ADX
source
Indicators.aroonMethod
aroon(hl::Matrix{T}; n::Int64=25)::Array{T}

Aroon up/down/oscillator

Output

  • Column 1: Aroon Up
  • Column 2: Aroon Down
  • Column 3: Aroon Oscillator
source
Indicators.cciMethod
cci(hlc::Matrix{T}; n::Int64=20, c::T=0.015, ma::Function=sma)::Array{T}

Commodity channel index

source
Indicators.donchMethod
donch(hl::Matrix{T}; n::Int64=10, inclusive::Bool=true)::Array{T}

Donchian channel (if inclusive is set to true, will include current bar in calculations.)

Output

  • Column 1: Lowest low of last n periods
  • Column 2: Average of highest high and lowest low of last n periods
  • Column 3: Highest high of last n periods
source
Indicators.kstMethod
kst(x::Array{T};
    nroc::Array{Int64}=[10,15,20,30], navg::Array{Int64}=[10,10,10,15],
    wgts::Array{Int64}=collect(1:length(nroc)), ma::Function=sma)::Array{T}

KST (Know Sure Thing) – smoothed and summed rates of change

source
Indicators.macdMethod
macd(x::Array{T}; nfast::Int64=12, nslow::Int64=26, nsig::Int64=9)::Array{T}

Moving average convergence-divergence

Output

  • Column 1: MACD
  • Column 2: MACD Signal Line
  • Column 3: MACD Histogram
source
Indicators.momentumMethod
momentum(x::Array{T}; n::Int64=1)::Array{T}

Momentum indicator (price now vs price n periods back)

source
Indicators.psarMethod
psar(hl::Array{T}; af_min::T=0.02, af_max::T=0.2, af_inc::T=af_min)::Array{T}

Parabolic stop and reverse (SAR)

Arguments

  • hl: 2D array of high and low prices in first and second columns respectively
  • af_min: starting/initial value for acceleration factor
  • af_max: maximum acceleration factor (accel factor capped at this value)
  • af_inc: increment to the acceleration factor (speed of increase in accel factor)
source
Indicators.rocMethod
roc(x::Array{T}; n::Int64=1)::Array{T}

Rate of change indicator (percent change between i'th observation and (i-n)'th observation)

source
Indicators.rsiMethod
rsi(x::Array{T}; n::Int64=14, ma::Function=ema, args...)::Array{T}

Relative strength index

source
Indicators.smiMethod
smi(hlc::Matrix{T}; n::Int64=13, nFast::Int64=2, nSlow::Int64=25, nSig::Int64=9,
    maFast::Function=ema, maSlow::Function=ema, maSig::Function=sma)::Matrix{T}

SMI (stochastic momentum oscillator)

source
Indicators.stochMethod
stoch(hlc::Matrix{T}; nK::Int64=14, nD::Int64=3, kind::Symbol=:fast, ma::Function=sma, args...)::Matrix{T}

Stochastic oscillator (fast or slow)

source