Skip to content

Instantly share code, notes, and snippets.

@e1t0n
Created October 8, 2016 14:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e1t0n/ac985b6d537b6fbbfebe52a48dcbbd2b to your computer and use it in GitHub Desktop.
Save e1t0n/ac985b6d537b6fbbfebe52a48dcbbd2b to your computer and use it in GitHub Desktop.
Pine Script
//tradingview.com pine script
study("Average Directional Index with Threshold", shorttitle="ADX")
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
up = change(high)
down = -change(low)
truerange = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, 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)
th1 = input(title="threshold", type=integer, defval=10)
th2 = input(title="threshold", type=integer, defval=20)
th3 = input(title="threshold", type=integer, defval=40)
plot(sig, color=green, title="ADX", style=histogram)
hline(th1, color=silver, linestyle=dashed)
hline(th2, color=silver, linestyle=dashed)
hline(th3, color=silver, linestyle=dashed)
@Prashnt123456780
Copy link

Hi
Can we create a histogram with above script. If yes can we make algo trade with that script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment