Skip to content

Commit

Permalink
drop 0.4 support (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed May 23, 2017
2 parents 5595116 + daf0853 commit 77a9c21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/MarketTechnicals.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION >= v"0.4.0-dev+6521" && __precompile__(true)
__precompile__(true)

using TimeSeries, StatsBase

Expand Down
10 changes: 4 additions & 6 deletions src/volatility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ Bollinger Bands
\end{align*}
```
"""
function bollingerbands{T,N}(ta::TimeArray{T,N}, ma::Int, width::Float64)
function bollingerbands{T,N}(ta::TimeArray{T,N}, ma::Integer=20,
width::AbstractFloat=2.0)
tama = sma(ta, ma)
upband = tama .+ moving(ta, std, ma) .* width .* sqrt((ma-1)/ma) # take out Bessel correction, per algorithm
dnband = tama .- moving(ta, std, ma) .* width .* sqrt((ma-1)/ma)
bands = merge(upband, dnband)
merge(bands, tama, colnames = ["up", "down", "mean"])
end

bollingerbands{T,N}(ta::TimeArray{T,N}) = bollingerbands(ta, 20, 2.0)

doc"""
truerange(ohlc; h="High", l="Low", c="Close")
Expand Down Expand Up @@ -53,14 +52,13 @@ It's the exponential moving average of [`truerange`](@ref)
```
"""
function atr{T,N}(ohlc::TimeArray{T,N}, n::Int; h="High", l="Low", c="Close")
function atr{T,N}(ohlc::TimeArray{T,N}, n::Integer=14;
h="High", l="Low", c="Close")
# atr was invented by Wilder, so only his ema is currently supported
res = ema(truerange(ohlc), n, wilder=true)
TimeArray(res.timestamp, res.values, ["atr"], ohlc.meta)
end

atr{T,N}(ta::TimeArray{T,N}) = atr(ta, 14)

# function keltnerbands{T,N}(ohlc::TimeArray{T,N}, n::Int)
# typ = typical(ohlc)
# rng = ohlc["High"] .- ohlc["Low"]
Expand Down

0 comments on commit 77a9c21

Please sign in to comment.