2
2
3
3
"""
4
4
```
5
- aroon(hl::Matrix{T}; n::Int64=25)::Array{T }
5
+ aroon(hl::Matrix{T}; n::Int64=25)::Array{Float64 }
6
6
```
7
7
8
8
Aroon up/down/oscillator
@@ -13,7 +13,7 @@ Aroon up/down/oscillator
13
13
- Column 2: Aroon Down
14
14
- Column 3: Aroon Oscillator
15
15
"""
16
- function aroon (hl:: Matrix{T} ; n:: Int64 = 25 ):: Matrix{T } where {T<: Real }
16
+ function aroon (hl:: Matrix{T} ; n:: Int64 = 25 ):: Matrix{Float64 } where {T<: Real }
17
17
@assert size (hl,2 ) == 2 " Argument `hl` must have exactly 2 columns."
18
18
@assert n < size (hl,1 ) " Argument `n` must be less than the number of rows in argument `hl`."
19
19
out = zeros (T, (size (hl,1 ),3 ))
30
30
31
31
"""
32
32
```
33
- donch(hl::Matrix{T}; n::Int64=10, inclusive::Bool=true)::Array{T }
33
+ donch(hl::Matrix{T}; n::Int64=10, inclusive::Bool=true)::Array{Float64 }
34
34
```
35
35
36
36
Donchian channel (if inclusive is set to true, will include current bar in calculations.)
@@ -41,7 +41,7 @@ Donchian channel (if inclusive is set to true, will include current bar in calcu
41
41
- Column 2: Average of highest high and lowest low of last `n` periods
42
42
- Column 3: Highest high of last `n` periods
43
43
"""
44
- function donch (hl:: Matrix{T} ; n:: Int64 = 10 , inclusive:: Bool = true ):: Matrix{T } where {T<: Real }
44
+ function donch (hl:: Matrix{T} ; n:: Int64 = 10 , inclusive:: Bool = true ):: Matrix{Float64 } where {T<: Real }
45
45
@assert size (hl,2 ) == 2 " Argument `hl` must have exactly 2 columns."
46
46
local lower:: Array{T} = runmin (hl[:,2 ], n= n, cumulative= false , inclusive= inclusive)
47
47
local upper:: Array{T} = runmax (hl[:,1 ], n= n, cumulative= false , inclusive= inclusive)
51
51
52
52
"""
53
53
```
54
- momentum(x::Array{T}; n::Int64=1)::Array{T }
54
+ momentum(x::Array{T}; n::Int64=1)::Array{Float64 }
55
55
```
56
56
57
57
Momentum indicator (price now vs price `n` periods back)
58
58
"""
59
- function momentum (x:: Array{T} ; n:: Int64 = 1 ):: Array{T } where {T<: Real }
59
+ function momentum (x:: Array{T} ; n:: Int64 = 1 ):: Array{Float64 } where {T<: Real }
60
60
@assert n> 0 " Argument n must be positive."
61
61
return diffn (x, n= n)
62
62
end
63
63
64
64
"""
65
65
```
66
- roc(x::Array{T}; n::Int64=1)::Array{T }
66
+ roc(x::Array{T}; n::Int64=1)::Array{Float64 }
67
67
```
68
68
69
69
Rate of change indicator (percent change between i'th observation and (i-n)'th observation)
70
70
"""
71
- function roc (x:: Array{T} ; n:: Int64 = 1 ):: Array{T } where {T<: Real }
71
+ function roc (x:: Array{T} ; n:: Int64 = 1 ):: Array{Float64 } where {T<: Real }
72
72
@assert n< size (x,1 ) && n> 0 " Argument n out of bounds."
73
73
out = zeros (size (x)) .* NaN
74
74
@inbounds for i = (n+ 1 ): size (x,1 )
79
79
80
80
"""
81
81
```
82
- macd(x::Array{T}; nfast::Int64=12, nslow::Int64=26, nsig::Int64=9)::Array{T }
82
+ macd(x::Array{T}; nfast::Int64=12, nslow::Int64=26, nsig::Int64=9)::Array{Float64 }
83
83
```
84
84
85
85
Moving average convergence-divergence
@@ -91,7 +91,7 @@ Moving average convergence-divergence
91
91
- Column 3: MACD Histogram
92
92
"""
93
93
function macd (x:: Array{T} ; nfast:: Int64 = 12 , nslow:: Int64 = 26 , nsig:: Int64 = 9 ,
94
- fastMA:: Function = ema, slowMA:: Function = ema, signalMA:: Function = sma):: Matrix{T } where {T<: Real }
94
+ fastMA:: Function = ema, slowMA:: Function = ema, signalMA:: Function = sma):: Matrix{Float64 } where {T<: Real }
95
95
out = zeros (T, (length (x),3 ))
96
96
out[:,1 ] = fastMA (x, n= nfast) - slowMA (x, n= nslow)
97
97
out[:,2 ] = signalMA (out[:,1 ], n= nsig)
@@ -101,12 +101,12 @@ end
101
101
102
102
"""
103
103
```
104
- rsi(x::Array{T}; n::Int64=14, ma::Function=ema, args...)::Array{T }
104
+ rsi(x::Array{T}; n::Int64=14, ma::Function=ema, args...)::Array{Float64 }
105
105
```
106
106
107
107
Relative strength index
108
108
"""
109
- function rsi (x:: Array{T} ; n:: Int64 = 14 , ma:: Function = ema, args... ):: Array{T } where {T<: Real }
109
+ function rsi (x:: Array{T} ; n:: Int64 = 14 , ma:: Function = ema, args... ):: Array{Float64 } where {T<: Real }
110
110
@assert n< size (x,1 ) && n> 0 " Argument n is out of bounds."
111
111
N = size (x,1 )
112
112
ups = zeros (N)
126
126
127
127
"""
128
128
```
129
- adx(hlc::Array{T}; n::Int64=14, wilder=true)::Array{T }
129
+ adx(hlc::Array{T}; n::Int64=14, wilder=true)::Array{Float64 }
130
130
```
131
131
132
132
Average directional index
@@ -137,7 +137,7 @@ Average directional index
137
137
- Column 2: DI-
138
138
- Column 3: ADX
139
139
"""
140
- function adx (hlc:: Array{T} ; n:: Int64 = 14 , ma:: Function = ema, args... ):: Matrix{T } where {T<: Real }
140
+ function adx (hlc:: Array{T} ; n:: Int64 = 14 , ma:: Function = ema, args... ):: Matrix{Float64 } where {T<: Real }
141
141
@assert n< size (hlc,1 ) && n> 0 " Argument n is out of bounds."
142
142
if size (hlc,2 ) != 3
143
143
error (" HLC array must have three columns" )
164
164
165
165
"""
166
166
```
167
- psar(hl::Array{T}; af_min::T=0.02, af_max::T=0.2, af_inc::T=af_min)::Array{T }
167
+ psar(hl::Array{T}; af_min::T=0.02, af_max::T=0.2, af_inc::T=af_min)::Array{Float64 }
168
168
```
169
169
170
170
Parabolic stop and reverse (SAR)
@@ -175,7 +175,7 @@ Parabolic stop and reverse (SAR)
175
175
- `af_max`: maximum acceleration factor (accel factor capped at this value)
176
176
- `af_inc`: increment to the acceleration factor (speed of increase in accel factor)
177
177
"""
178
- function psar (hl:: Array{T} ; af_min:: T = 0.02 , af_max:: T = 0.2 , af_inc:: T = af_min):: Array{T } where {T<: Real }
178
+ function psar (hl:: Array{T} ; af_min:: T = 0.02 , af_max:: T = 0.2 , af_inc:: T = af_min):: Array{Float64 } where {T<: Real }
179
179
@assert af_min< 1.0 && af_min> 0.0 " Argument af_min must be in [0,1]."
180
180
@assert af_max< 1.0 && af_max> 0.0 " Argument af_max must be in [0,1]."
181
181
@assert af_inc< 1.0 && af_inc> 0.0 " Argument af_inc must be in [0,1]."
@@ -227,14 +227,14 @@ end
227
227
```
228
228
kst(x::Array{T};
229
229
nroc::Array{Int64}=[10,15,20,30], navg::Array{Int64}=[10,10,10,15],
230
- wgts::Array{Int64}=collect(1:length(nroc)), ma::Function=sma)::Array{T }
230
+ wgts::Array{Int64}=collect(1:length(nroc)), ma::Function=sma)::Array{Float64 }
231
231
232
232
```
233
233
234
234
KST (Know Sure Thing) -- smoothed and summed rates of change
235
235
"""
236
236
function kst (x:: Array{T} ; nroc:: Array{Int64} = [10 ,15 ,20 ,30 ], navg:: Array{Int64} = [10 ,10 ,10 ,15 ],
237
- wgts:: Array{Int64} = collect (1 : length (nroc)), ma:: Function = sma):: Array{T } where {T<: Real }
237
+ wgts:: Array{Int64} = collect (1 : length (nroc)), ma:: Function = sma):: Array{Float64 } where {T<: Real }
238
238
@assert length (nroc) == length (navg)
239
239
@assert all (nroc.> 0 ) && all (nroc.< size (x,1 ))
240
240
@assert all (navg.> 0 ) && all (navg.< size (x,1 ))
@@ -249,25 +249,25 @@ end
249
249
250
250
"""
251
251
```
252
- wpr(hlc::Matrix{T}, n::Int64=14)::Array{T }
252
+ wpr(hlc::Matrix{T}, n::Int64=14)::Array{Float64 }
253
253
```
254
254
255
255
Williams %R
256
256
"""
257
- function wpr (hlc:: Matrix{T} ; n:: Int64 = 14 ):: Array{T } where {T<: Real }
257
+ function wpr (hlc:: Matrix{T} ; n:: Int64 = 14 ):: Array{Float64 } where {T<: Real }
258
258
hihi = runmax (hlc[:,1 ], n= n, cumulative= false )
259
259
lolo = runmin (hlc[:,2 ], n= n, cumulative= false )
260
260
return - 100 * (hihi - hlc[:,3 ]) ./ (hihi - lolo)
261
261
end
262
262
263
263
"""
264
264
```
265
- cci(hlc::Matrix{T}; n::Int64=20, c::T=0.015, ma::Function=sma)::Array{T }
265
+ cci(hlc::Matrix{T}; n::Int64=20, c::T=0.015, ma::Function=sma)::Array{Float64 }
266
266
```
267
267
268
268
Commodity channel index
269
269
"""
270
- function cci (hlc:: Matrix{T} ; n:: Int64 = 20 , c:: T = 0.015 , ma:: Function = sma, args... ):: Array{T } where {T<: Real }
270
+ function cci (hlc:: Matrix{T} ; n:: Int64 = 20 , c:: T = 0.015 , ma:: Function = sma, args... ):: Array{Float64 } where {T<: Real }
271
271
tp = (hlc[:,1 ] + hlc[:,2 ] + hlc[:,3 ]) ./ 3.0
272
272
dev = runmad (tp, n= n, cumulative= false , fun= mean)
273
273
avg = ma (tp, n= n; args... )
@@ -276,13 +276,13 @@ end
276
276
277
277
"""
278
278
```
279
- stoch(hlc::Matrix{T}; nK::Int64=14, nD::Int64=3, kind::Symbol=:fast, ma::Function=sma, args...)::Matrix{T }
279
+ stoch(hlc::Matrix{T}; nK::Int64=14, nD::Int64=3, kind::Symbol=:fast, ma::Function=sma, args...)::Matrix{Float64 }
280
280
```
281
281
282
282
Stochastic oscillator (fast or slow)
283
283
"""
284
284
function stoch (hlc:: Matrix{T} ; nK:: Int64 = 14 , nD:: Int64 = 3 ,
285
- kind:: Symbol = :fast , ma:: Function = sma, args... ):: Matrix{T } where {T<: Real }
285
+ kind:: Symbol = :fast , ma:: Function = sma, args... ):: Matrix{Float64 } where {T<: Real }
286
286
@assert kind == :fast || kind == :slow " Argument `kind` must be either :fast or :slow"
287
287
@assert nK< size (hlc,1 ) && nK> 0 " Argument `nK` out of bounds."
288
288
@assert nD< size (hlc,1 ) && nD> 0 " Argument `nD` out of bounds."
@@ -301,13 +301,13 @@ end
301
301
"""
302
302
```
303
303
smi(hlc::Matrix{T}; n::Int64=13, nFast::Int64=2, nSlow::Int64=25, nSig::Int64=9,
304
- maFast::Function=ema, maSlow::Function=ema, maSig::Function=sma)::Matrix{T }
304
+ maFast::Function=ema, maSlow::Function=ema, maSig::Function=sma)::Matrix{Float64 }
305
305
```
306
306
307
307
SMI (stochastic momentum oscillator)
308
308
"""
309
309
function smi (hlc:: Matrix{T} ; n:: Int64 = 13 , nFast:: Int64 = 2 , nSlow:: Int64 = 25 , nSig:: Int64 = 9 ,
310
- maFast:: Function = ema, maSlow:: Function = ema, maSig:: Function = sma):: Matrix{T } where {T<: Real }
310
+ maFast:: Function = ema, maSlow:: Function = ema, maSig:: Function = sma):: Matrix{Float64 } where {T<: Real }
311
311
hihi = runmax (hlc[:,1 ], n= n, cumulative= false )
312
312
lolo = runmin (hlc[:,2 ], n= n, cumulative= false )
313
313
hldif = hihi- lolo
0 commit comments