ADX Color Coded Bar
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © christofferka
//@version=5
indicator("ADX Color Coded Bar", timeframe='',timeframe_gaps =false)
adxlen = input.int(14, minval=1, title="ADX Smoothing")
dilen = input.int(14, minval=1, title="DI Length")
dirmov(len) =>
	up = ta.change(high)
	down = -ta.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 = ta.rma(ta.tr, len)
	plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
	minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
	[plus, minus]
adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)


ADXColorthreshhold = input.int(25, minval=1, title="ADX Color Threshold",tooltip="Green = Confident moves are more likely to happen. Red = More likely to be fakeouts, choppy and consolidating market conditions. Keep in mind that confident moves can happen in the red zone and that this is a lagging indicator.) ")

ADXColorGreen = sig > ADXColorthreshhold ? color.green :color.red

//  ADX BAR
ADXBarTopLine = plot(sig ? -41 : na, title = 'ADX Bar TOP Line', transp = 100)
ADXBarBottomLine = plot(sig ? -45 : na, title = 'ADX Bar BOTTOM Line', transp = 100)
fill(ADXBarTopLine, ADXBarBottomLine, title = 'ADX Bar Colors', color = ADXColorGreen, transp = 35)

