ADeXt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wallneradam

//@version=5
indicator("ADeXt")

// This indicator uses my TaExt library, that can be used in any strategy or study where this indicator needed
import wallneradam/TAExt/6

atr_length = input.int(14, "ATR Length", minval=1, group="ATR")
atr_ma_type = input.string("RMA", "ATR MA Type", options=['SMA', 'EMA', 'WMA', "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "JMA"], group="ATR")
atr_stdev_length = input.int(100, "STDev Length", minval=1, group="ATR")
atr_stdev_mult = input.float(1.0, "STDev Multiplier", minval=0.0, step=0.1, group="ATR")
high_src = input.source(high, "Source of High", group="DI")
low_src = input.source(low, "Source of Low", group="DI")
di_length = input.int(14, "DI Length", minval=1, group="DI")
di_ma_type = input.string("RMA", "DI MA Type", options=['SMA', 'EMA', 'WMA', "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA", "JMA"], group="DI")
di_hist_mult = input.float(2.0, "Histogram Multiplier", minval=0.01, step=0.1, group="DI")
adx_length = input.int(14, "ADX Length", minval=1, group="ADX")
adx_ma_type = input.string("RMA", "ADX MA Type", options=['SMA', 'EMA', 'WMA', "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA", "JMA"], group="ADX")

[plus, minus, adx] = 
     TAExt.adx(atr_length=atr_length, atr_ma_type=atr_ma_type, high_src=high_src, low_src=low_src, 
     di_length=di_length, di_ma_type=di_ma_type, adx_length=adx_length, adx_ma_type=adx_ma_type, 
     atr_stdev_length=atr_stdev_length, atr_stdev_mult=atr_stdev_mult)

hist = plus - minus
hist_color = hist > 0 ? color.new(color.green, 75) : color.new(color.red, 75)

plot(plus, color=color.lime, title="+DI", display=display.none)
plot(minus, color=color.red, title="-DI", display=display.none)
plot(adx, color=color.yellow, title="ADX")
plot(math.abs(hist) * di_hist_mult, "Histogram", color=hist_color, style=plot.style_columns)

hline(20, "Threshold")
