Momentum
Average Directional Movement Index (ADX)
MarketTechnicals.adx
— Function.adx(ohlc, n=14; h="High", l="Low", c="Close")
Average Directional Movement Index
Developed by J. Welles Wilder. This Implementation follows StockCharts.
Reference
julia> using MarketData
julia> using MarketTechnicals
julia> adx(ohlc)
473x4 TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}} 2000-02-10 to 2001-12-31
│ │ adx │ dx │ +di │ -di │
├────────────┼─────────┼─────────┼─────────┼─────────┤
│ 2000-02-10 │ 10.5998 │ 0.3916 │ 23.6226 │ 23.4383 │
│ 2000-02-11 │ 10.0953 │ 3.5371 │ 22.1956 │ 23.8233 │
│ 2000-02-14 │ 9.4222 │ 0.6728 │ 22.348 │ 22.0493 │
│ 2000-02-15 │ 9.4482 │ 9.7856 │ 25.495 │ 20.9501 │
│ 2000-02-16 │ 8.9272 │ 2.1537 │ 23.6555 │ 22.6581 │
│ 2000-02-17 │ 8.4433 │ 2.1537 │ 23.0363 │ 22.065 │
│ 2000-02-18 │ 8.0918 │ 3.5217 │ 21.8706 │ 23.4673 │
│ 2000-02-22 │ 8.459 │ 13.2324 │ 19.4557 │ 25.3898 │
│ 2000-02-23 │ 8.3907 │ 7.5034 │ 19.9902 │ 23.2335 │
⋮
│ 2001-12-19 │ 26.3951 │ 22.3314 │ 26.0296 │ 16.5263 │
│ 2001-12-20 │ 26.1049 │ 22.3314 │ 24.2042 │ 15.3674 │
│ 2001-12-21 │ 25.9085 │ 23.3553 │ 23.208 │ 14.4199 │
│ 2001-12-24 │ 25.7261 │ 23.3553 │ 22.2731 │ 13.839 │
│ 2001-12-26 │ 26.414 │ 35.357 │ 26.5486 │ 12.6789 │
│ 2001-12-27 │ 27.0528 │ 35.357 │ 25.066 │ 11.9709 │
│ 2001-12-28 │ 28.2837 │ 44.2848 │ 28.6435 │ 11.0606 │
│ 2001-12-31 │ 29.1676 │ 40.6586 │ 26.8864 │ 11.3429 │
Aroon Oscillator
MarketTechnicals.aroon
— Function.aroon(ohlc, n=25; h="High", l="Low")
Aroon Oscillator
Formula
Reference
julia> using MarketData
julia> using MarketTechnicals
julia> aroon(ohlc)
476x3 TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}} 2000-02-07 to 2001-12-31
│ │ up │ dn │ osc │
├────────────┼───────┼───────┼───────┤
│ 2000-02-07 │ 52.0 │ 32.0 │ 20.0 │
│ 2000-02-08 │ 48.0 │ 28.0 │ 20.0 │
│ 2000-02-09 │ 44.0 │ 24.0 │ 20.0 │
│ 2000-02-10 │ 40.0 │ 20.0 │ 20.0 │
│ 2000-02-11 │ 36.0 │ 16.0 │ 20.0 │
│ 2000-02-14 │ 32.0 │ 12.0 │ 20.0 │
│ 2000-02-15 │ 28.0 │ 8.0 │ 20.0 │
│ 2000-02-16 │ 24.0 │ 4.0 │ 20.0 │
│ 2000-02-17 │ 20.0 │ 4.0 │ 16.0 │
⋮
│ 2001-12-19 │ 60.0 │ 12.0 │ 48.0 │
│ 2001-12-20 │ 56.0 │ 8.0 │ 48.0 │
│ 2001-12-21 │ 52.0 │ 4.0 │ 48.0 │
│ 2001-12-24 │ 48.0 │ 4.0 │ 44.0 │
│ 2001-12-26 │ 44.0 │ 8.0 │ 36.0 │
│ 2001-12-27 │ 40.0 │ 4.0 │ 36.0 │
│ 2001-12-28 │ 36.0 │ 4.0 │ 32.0 │
│ 2001-12-31 │ 32.0 │ 4.0 │ 28.0 │
RSI
MarketTechnicals.rsi
— Function.rsi(ta, n=14; wilder=false)
Relative Strength Index
julia> using MarketData
julia> using MarketTechnicals
julia> rsi(cl)
486x1 TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}} 2000-01-24 to 2001-12-31
│ │ Close_rsi_14 │
├────────────┼──────────────┤
│ 2000-01-24 │ 45.9536 │
│ 2000-01-25 │ 54.3451 │
│ 2000-01-26 │ 51.1961 │
│ 2000-01-27 │ 50.8823 │
│ 2000-01-28 │ 38.7853 │
│ 2000-01-31 │ 42.7753 │
│ 2000-02-01 │ 38.0704 │
│ 2000-02-02 │ 36.1812 │
│ 2000-02-03 │ 45.8674 │
⋮
│ 2001-12-19 │ 55.3167 │
│ 2001-12-20 │ 43.0604 │
│ 2001-12-21 │ 47.7045 │
│ 2001-12-24 │ 52.5736 │
│ 2001-12-26 │ 54.3448 │
│ 2001-12-27 │ 61.7068 │
│ 2001-12-28 │ 65.6713 │
│ 2001-12-31 │ 55.8492 │
MACD
MarketTechnicals.macd
— Function.macd(ta, fast=12, slow=26, signal=9; wilder=false)
Moving Average Convergence / Divergence
Return:
TimeArray
with 3 columns ["macd", "dif", "signal"]
.
If the input is a multi-column TimeArray
, the new column names will be ["A_macd", "B_macd", "A_dif", "B_dif", "A_signal", "B_signal"]
.
julia> using MarketData
julia> using MarketTechnicals
julia> macd(cl)
467x3 TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}} 2000-02-18 to 2001-12-31
│ │ macd │ dif │ signal │
├────────────┼─────────┼────────┼────────┤
│ 2000-02-18 │ -0.0472 │ 3.5339 │ 3.5811 │
│ 2000-02-22 │ -0.1375 │ 3.4092 │ 3.5467 │
│ 2000-02-23 │ -0.0636 │ 3.4672 │ 3.5308 │
│ 2000-02-24 │ -0.1131 │ 3.3894 │ 3.5026 │
│ 2000-02-25 │ -0.4778 │ 2.9054 │ 3.3831 │
│ 2000-02-28 │ -0.5289 │ 2.7219 │ 3.2509 │
│ 2000-02-29 │ -0.4755 │ 2.6565 │ 3.132 │
│ 2000-03-01 │ 0.5557 │ 3.8266 │ 3.2709 │
│ 2000-03-02 │ 0.6127 │ 4.0368 │ 3.4241 │
⋮
│ 2001-12-19 │ -0.2075 │ 0.4641 │ 0.6716 │
│ 2001-12-20 │ -0.2337 │ 0.3795 │ 0.6132 │
│ 2001-12-21 │ -0.2224 │ 0.3352 │ 0.5576 │
│ 2001-12-24 │ -0.1858 │ 0.3254 │ 0.5111 │
│ 2001-12-26 │ -0.1494 │ 0.3244 │ 0.4738 │
│ 2001-12-27 │ -0.0861 │ 0.3661 │ 0.4523 │
│ 2001-12-28 │ -0.0231 │ 0.4234 │ 0.4465 │
│ 2001-12-31 │ -0.0203 │ 0.4212 │ 0.4414 │
Chaikin Oscillator
MarketTechnicals.chaikinoscillator
— Function.chaikinoscillator(ohlcv, fast=3, slow=10; h="High", l="Low", c="Close")
Chaikin Oscillator
Developed by Marc Chaikin
Formula
where the adl
is the Accumulation/Distribution Line.
Reference
julia> using MarketData
julia> using MarketTechnicals
julia> chaikinoscillator(ohlcv)
491x1 TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}} 2000-01-14 to 2001-12-31
│ │ chaikinoscillator │
├────────────┼───────────────────┤
│ 2000-01-14 │ -6.8514668666e6 │
│ 2000-01-18 │ -5.5088241581e6 │
│ 2000-01-19 │ -4.1457475832e6 │
│ 2000-01-20 │ -8.4133210223e6 │
│ 2000-01-21 │ -1.00258648284e7 │
│ 2000-01-24 │ -1.06556036696e7 │
│ 2000-01-25 │ -8.7610031514e6 │
│ 2000-01-26 │ -8.0258147742e6 │
│ 2000-01-27 │ -6.9954363677e6 │
⋮
│ 2001-12-19 │ 2.9106729951e6 │
│ 2001-12-20 │ 2.140953294e6 │
│ 2001-12-21 │ 962258.2028 │
│ 2001-12-24 │ 586108.9693 │
│ 2001-12-26 │ 49086.3672 │
│ 2001-12-27 │ 328390.5719 │
│ 2001-12-28 │ 249377.6771 │
│ 2001-12-31 │ -456423.2686 │
CCI
MarketTechnicals.cci
— Function.cci(ohlc, ma=20, c=0.015)
Commodity Channel Index
Reference
https://en.wikipedia.org/wiki/Commodity_channel_index
julia> using MarketData
julia> using MarketTechnicals
julia> cci(ohlc)
481x1 TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}} 2000-01-31 to 2001-12-31
│ │ cci │
├────────────┼──────────┤
│ 2000-01-31 │ -38.9316 │
│ 2000-02-01 │ -22.3949 │
│ 2000-02-02 │ -48.4746 │
│ 2000-02-03 │ -6.0758 │
│ 2000-02-04 │ 46.586 │
│ 2000-02-07 │ 88.8638 │
│ 2000-02-08 │ 108.1928 │
│ 2000-02-09 │ 99.3306 │
│ 2000-02-10 │ 74.4932 │
⋮
│ 2001-12-19 │ -0.5821 │
│ 2001-12-20 │ -37.2007 │
│ 2001-12-21 │ -27.4224 │
│ 2001-12-24 │ -17.225 │
│ 2001-12-26 │ 19.6668 │
│ 2001-12-27 │ 45.6476 │
│ 2001-12-28 │ 84.8749 │
│ 2001-12-31 │ 46.3511 │
Rate of Change (ROC)
MarketTechnicals.roc
— Function.roc(ta, n)
Rate of Change
Formula:
Reference:
julia> using MarketData
julia> using MarketTechnicals
julia> roc(cl, 5)
495x1 TimeSeries.TimeArray{Float64,1,Date,Array{Float64,1}} 2000-01-10 to 2001-12-31
│ │ Close_roc_5 │
├────────────┼─────────────┤
│ 2000-01-10 │ -0.1268 │
│ 2000-01-11 │ -0.0951 │
│ 2000-01-12 │ -0.1616 │
│ 2000-01-13 │ 0.0184 │
│ 2000-01-14 │ 0.0094 │
│ 2000-01-18 │ 0.0633 │
│ 2000-01-19 │ 0.1489 │
│ 2000-01-20 │ 0.3018 │
│ 2000-01-21 │ 0.1505 │
⋮
│ 2001-12-19 │ 0.006 │
│ 2001-12-20 │ -0.0157 │
│ 2001-12-21 │ 0.0299 │
│ 2001-12-24 │ 0.0359 │
│ 2001-12-26 │ 0.0228 │
│ 2001-12-27 │ 0.0208 │
│ 2001-12-28 │ 0.0851 │
│ 2001-12-31 │ 0.0429 │
Stochastic Oscillator
MarketTechnicals.stochasticoscillator
— Function.stochasticoscillator(ohlc, n=14, fast_d=3, slow_d=3; h="High", l="Low", c="Close")
Stochastic Oscillator
A.k.a %K%D, or KD
Parameter
n
: period of fast(raw)%K
fast_d
: MA period of fast%D
slow_d
: MA period of slow%D
Formula
Reference
julia> using MarketData
julia> using MarketTechnicals
julia> stochasticoscillator(ohlc)
483x3 TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}} 2000-01-27 to 2001-12-31
│ │ fast_k │ fast_d │ slow_d │
├────────────┼─────────┼─────────┼─────────┤
│ 2000-01-27 │ 67.1429 │ 69.4667 │ 67.4413 │
│ 2000-01-28 │ 43.2 │ 59.3429 │ 64.9016 │
│ 2000-01-31 │ 49.2857 │ 53.2095 │ 60.673 │
│ 2000-02-01 │ 39.2857 │ 43.9238 │ 52.1587 │
│ 2000-02-02 │ 21.7586 │ 36.7767 │ 44.6367 │
│ 2000-02-03 │ 32.6296 │ 31.2247 │ 37.3084 │
│ 2000-02-04 │ 50.0 │ 34.7961 │ 34.2658 │
│ 2000-02-07 │ 72.4444 │ 51.6914 │ 39.2374 │
│ 2000-02-08 │ 75.4815 │ 65.9753 │ 50.8209 │
⋮
│ 2001-12-19 │ 38.8325 │ 25.2115 │ 18.6783 │
│ 2001-12-20 │ 14.7208 │ 25.6345 │ 21.8838 │
│ 2001-12-21 │ 23.0964 │ 25.5499 │ 25.4653 │
│ 2001-12-24 │ 32.2335 │ 23.3503 │ 24.8449 │
│ 2001-12-26 │ 41.0557 │ 32.1286 │ 27.0096 │
│ 2001-12-27 │ 68.2759 │ 47.1884 │ 34.2224 │
│ 2001-12-28 │ 80.4124 │ 63.248 │ 47.5216 │
│ 2001-12-31 │ 62.1993 │ 70.2958 │ 60.2441 │