-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMyADX14-40.pine
More file actions
26 lines (23 loc) · 823 Bytes
/
MyADX14-40.pine
File metadata and controls
26 lines (23 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//@version=4
study("ADX_40", shorttitle="ADX", format=format.price, precision=2, resolution="")
fastlength = input(12)
slowlength = input(36)
levelline = input(40)
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
up = change(high)
down = -change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = rma(tr, len)
plus = fixnan(100 * rma(plusDM, len) / truerange)
minus = fixnan(100 * rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
plot(sig, color=color.red, title="ADX")
plot(levelline, color=color.yellow, title="40Level")