Skip to content

Commit b5ff477

Browse files
author
everget
committed
Update indicators
1 parent e2152d4 commit b5ff477

13 files changed

+144
-59
lines changed

‎src/movings/adaptive_rsi.pine

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ study("Adaptive RSI", shorttitle="ARSI", overlay=true)
66
length = input(title="Length", type=integer, defval=14, minval=1)
77
src = input(title="Source", type=source, defval=close)
88

9-
alpha = abs(rsi(src, length) / 100 - 0.5) * 2
9+
arsi(src, length) =>
10+
alpha = abs(rsi(src, length) / 100 - 0.5) * 2
1011

11-
arsi = 0.0
12-
arsi := alpha * src + (1 - alpha) * nz(arsi[1])
12+
arsi = 0.0
13+
arsi := alpha * src + (1 - alpha) * nz(arsi[1])
1314

14-
plot(arsi, title="ARSI", color=#741b47, linewidth=2, transp=0)
15+
plot(arsi(src, length), title="ARSI", color=#741b47, linewidth=2, transp=0)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@version=3
2+
// Copyright (c) 2018-present, Alex Orekhov (everget)
3+
// Arnaud Legoux Moving Average script may be freely distributed under the MIT license.
4+
study("Arnaud Legoux Moving Average", shorttitle="ALMA", overlay=true)
5+
6+
length = input(title="Length", type=integer, minval=1, defval=9)
7+
offset = input(title="Offset", type=float, defval=0.85)
8+
sigma = input(title="Sigma", type=float, defval=6)
9+
src = input(title="Source", type=source, defval=close)
10+
11+
plot(alma(src, length, offset, sigma), title="ALMA", linewidth=2, color=#e69138, transp=0)

‎src/movings/elastic_volume_weighted_moving_average.pine

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
// Elastic Volume Weighted Moving Average script may be freely distributed under the MIT license.
44
study("Elastic Volume Weighted Moving Average", shorttitle="EVWMA", overlay=true)
55

6-
length = input(title="Length", type=integer, defval=14, minval=1)
6+
length = input(title="Length", type=integer, minval=1, defval=14)
77
src = input(title="Source", type=source, defval=close)
88

9-
volumeSum = sum(volume, length)
9+
evwma(src, length) =>
10+
volumeSum = sum(volume, length)
1011

11-
evwma = 0.0
12-
evwma := ((volumeSum - volume) * nz(evwma[1]) + volume * src) / volumeSum
12+
evwma = 0.0
13+
evwma := ((volumeSum - volume) * nz(evwma[1]) + volume * src) / volumeSum
1314

14-
plot(evwma, title="EVWMA", linewidth=2, color=#6d1e7f, transp=0)
15+
plot(evwma(src, length), title="EVWMA", linewidth=2, color=#6d1e7f, transp=0)

‎src/movings/fractal_adaptive_moving_average.pine

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,23 @@
33
// Fractal Adaptive Moving Average script may be freely distributed under the MIT license.
44
study(title="Fractal Adaptive Moving Average", shorttitle="FRAMA", overlay=true)
55

6-
length = input(title="Length", type=integer, defval=20, minval=1)
6+
length = input(title="Length", type=integer, minval=1, defval=20)
77
src = input(title="Source", type=source, defval=close)
88

9-
hh = highest(high, length)
10-
ll = lowest(low, length)
9+
frama(src, length) =>
10+
length2 = round(length / 2)
1111

12-
length2 = round(length / 2)
12+
hh2 = highest(high, length2)
13+
ll2 = lowest(low, length2)
1314

14-
hh2 = highest(high, length2)
15-
ll2 = lowest(low, length2)
15+
N1 = (hh2 - ll2) / length2
16+
N2 = (hh2[length2] - ll2[length2]) / length2
17+
N3 = (highest(high, length) - lowest(low, length)) / length
18+
D = (log(N1 + N2) - log(N3)) / log(2)
1619

17-
N1 = (hh2 - ll2) / length2
20+
alpha = exp(-4.6 * (D - 1))
1821

19-
N2 = (hh2[length2] - ll2[length2]) / length2
22+
frama = 0.0
23+
frama := alpha * src + (1 - alpha) * nz(frama[1])
2024

21-
N3 = (hh - ll) / length
22-
23-
D = (log(N1 + N2) - log(N3)) / log(2)
24-
25-
factor = exp(-4.6 * (D - 1))
26-
27-
frama = 0.0
28-
frama := factor * src + (1 - factor) * nz(frama[1])
29-
30-
plot(frama, title="FRAMA", color=#741b47, linewidth=2, transp=0)
25+
plot(frama(src, length), title="FRAMA", color=#741b47, linewidth=2, transp=0)

‎src/movings/hull_moving_average.pine

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@version=3
2+
// Copyright (c) 2018-present, Alex Orekhov (everget)
3+
// Hull Moving Average script may be freely distributed under the MIT license.
4+
study("Hull Moving Average", shorttitle="HMA", overlay=true)
5+
6+
length = input(title="Length", type=integer, defval=14, minval=1)
7+
src = input(title="Source", type=source, defval=close)
8+
9+
hma(src, length) =>
10+
wma(2 * wma(src, length / 2) - wma(src, length), round(sqrt(length)))
11+
12+
plot(hma(src, length), title="HMA", linewidth=2, color=#6d1e7f, transp=0)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@version=3
2+
// Copyright (c) 2018-present, Alex Orekhov (everget)
3+
// Kaufman Adaptive Moving Average script may be freely distributed under the MIT license.
4+
study("Kaufman Adaptive Moving Average", shorttitle="KAMA", overlay=true)
5+
6+
length = input(title="Length", type=integer, minval=1, defval=14)
7+
fastLength = input(title="Fast MA Length", type=integer, minval=1, defval=2)
8+
slowLength = input(title="Slow MA Length", type=integer, minval=1, defval=30)
9+
src = input(title="Source", type=source, defval=close)
10+
11+
kama(src, length, fastLength, slowLength) =>
12+
change = abs(nz(src[1]) - nz(src[length]))
13+
volatility = sum(abs(src - nz(src[1])), length)
14+
15+
// Efficiency Ratio
16+
ER = volatility != 0
17+
? change / volatility
18+
0
19+
20+
fastSC = 2 / (fastLength + 1)
21+
slowSC = 2 / (slowLength + 1)
22+
23+
// Smoothing constant
24+
SC = pow((ER * (fastSC - slowSC)) + slowSC, 2)
25+
26+
kama = 0.0
27+
kama := SC * src + (1 - SC) * nz(kama[1])
28+
29+
plot(kama(src, length, fastLength, slowLength), title="KAMA", linewidth=2, color=#e69138, transp=0)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@version=3
2+
// Copyright (c) 2018-present, Alex Orekhov (everget)
3+
// Linear Weighted Moving Average script may be freely distributed under the MIT license.
4+
study("Linear Weighted Moving Average", shorttitle="LWMA", overlay=true)
5+
6+
length = input(title="Length", type=integer, minval=1, defval=14)
7+
src = input(title="Source", type=source, defval=close)
8+
9+
lwma(src, length) =>
10+
weightSum = 0.0
11+
sum = 0.0
12+
13+
for i = 0 to length - 1
14+
weight = length - i
15+
weightSum := weightSum + weight
16+
sum := sum + nz(src[i]) * weight
17+
18+
sum / weightSum
19+
20+
plot(lwma(src, length), title="LWMA", linewidth=2, color=#e69138, transp=0)

‎src/movings/mcginley_dynamic.pine

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@version=3
2+
// Copyright (c) 2018-present, Alex Orekhov (everget)
3+
// McGinley Dynamic script may be freely distributed under the MIT license.
4+
study("McGinley Dynamic", shorttitle="MD", overlay=true)
5+
6+
length = input(title="Length", type=integer, minval=1, defval=14)
7+
k = input(title="K", type=float, step=0.1, defval=0.6)
8+
src = input(title="Source", type=source, defval=close)
9+
10+
md(src, length, k) =>
11+
md = 0.0
12+
md := na(md[1]) ? src : md[1] + (src - md[1]) / (k * length * pow(src / md[1], 4))
13+
14+
plot(md(src, length, k), title="MD", linewidth=2, color=#6d1e7f, transp=0)

‎src/movings/regularized_exponential_moving_average.pine

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
// Regularized Exponential Moving Average script may be freely distributed under the MIT license.
44
study("Regularized Exponential Moving Average", shorttitle="REMA", overlay=true)
55

6-
length = input(title="Length", type=integer, defval=20, minval=1)
7-
lambda = input(title="Regularization Constant", type=float, defval=0.5, minval=0)
6+
length = input(title="Length", type=integer, minval=1, defval=20)
7+
lambda = input(title="Regularization Constant", type=float, minval=0, defval=0.5)
88
src = input(title="Source", type=source, defval=close)
99

10-
alpha = 2 / (length + 1)
10+
rema(src, length, lambda) =>
11+
alpha = 2 / (length + 1)
1112

12-
rema = 0.0
13-
rema := (nz(rema[1]) + alpha * (src - nz(rema[1])) + lambda * (2 * nz(rema[1]) - nz(rema[2]))) / (lambda + 1)
13+
rema = 0.0
14+
rema := (nz(rema[1]) + alpha * (src - nz(rema[1])) + lambda * (2 * nz(rema[1]) - nz(rema[2]))) / (lambda + 1)
1415

15-
plot(rema, title="REMA", linewidth=2, color=#741b47, transp=0)
16+
plot(rema(src, length, lambda), title="REMA", linewidth=2, color=#741b47, transp=0)

‎src/movings/t3_moving_average.pine

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
// T3 script may be freely distributed under the MIT license.
44
study(title="T3", shorttitle="T3", overlay=true)
55

6-
len = input(title="Length", type=integer, defval=5, minval=1)
7-
factor = input(title="Factor", type=float, defval=0.7, minval=0, maxval=1)
6+
length = input(title="Length", type=integer, minval=1, defval=5)
7+
alpha = input(title="Alpha", type=float, minval=0, maxval=1, defval=0.7)
88
src = input(title="Source", type=source, defval=close)
99

10-
gd(series, length) => ema(series, length) * (1 + factor) - ema(ema(series, length), length) * factor
10+
gd(series, seriesLength, alpha) =>
11+
ema(series, seriesLength) * (1 + alpha) - ema(ema(series, seriesLength), seriesLength) * alpha
1112

12-
t3 = gd(gd(gd(src, len), len), len)
13+
t3(src, length, alpha) =>
14+
gd(gd(gd(src, length, alpha), length, alpha), length, alpha)
1315

14-
plot(t3, title="T3", color=#741b47, linewidth=2, transp=0)
16+
plot(t3(src, length, alpha), title="T3", color=#741b47, linewidth=2, transp=0)

0 commit comments

Comments
 (0)