//DMI Indicator //Resolution input option for higher/lower time frames study(title="DMI ADX TREND 2.0", shorttitle="ADX TREND 2.0") adxlen = input(14, title="ADX Smoothing") dilen = input(14, title="DI Length") thold = input(20, title="Threshold") threshold = thold //Script for Indicator 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) [adx, plus, minus] [sig, up, down] = adx(dilen, adxlen) osob=input(40,title="Exhaustion Level for ADX, default = 40") col = sig >= sig[1] ? green : sig <= sig[1] ? red : gray //Plot Definitions Current Timeframe p1 = plot(sig, color=col, linewidth = 3, title="ADX") p2 = plot(sig, color=col, style=circles, linewidth=3, title="ADX") p3 = plot(up, color=blue, linewidth = 3, title="+DI") p4 = plot(up, color=blue, style=circles, linewidth=3, title="+DI") p5 = plot(down, color=fuchsia, linewidth = 3, title="-DI") p6 = plot(down, color=fuchsia, style=circles, linewidth=3, title="-DI") h1 = plot(threshold, color=black, linewidth =3, title="Threshold") trender = (sig >= up or sig >= down) ? 1 : 0 bgcolor(trender>0?black:gray, transp=85) //Alert Function for ADX crossing Threshold Up_Cross = crossover(up, threshold) alertcondition(Up_Cross, title="DMI+ cross", message="DMI+ Crossing Threshold") Down_Cross = crossover(down, threshold) alertcondition(Down_Cross, title="DMI- cross", message="DMI- Crossing Threshold")