Parabolic SAR with the ADX overlay
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Eervin123

//@version=5
indicator("YOSAR", overlay = true)

start       = input.float(defval = 0.02, title = "Start", step = 0.01)
increment   = input.float(defval = 0.02, title = "Increment", step = 0.01)
maximum     = input.float(defval = 0.20, title = "Maximum", step = 0.01)
// ADX Inputs
len         = input.int(14, minval=1, title="DI Length")
lensig      = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
ADXlowerBound = input.int(25, minval=1, title="ADX Lower Bound")

// Function prints a message at the bottom-right of the chart.
f_print(_text) =>
    var table _t = table.new(position.bottom_right, 1, 1)
    table.cell(_t, 0, 0, _text, bgcolor = color.new(color.yellow, transp=50))

sar = ta.sar(start, increment, maximum)
[diplus, diminus, adx] = ta.dmi(len, lensig) // Pull in the DI+ DI- and ADX

// Create the plot colors for SAR
sarColor = if(close > sar)
    color.green
else
    color.red
// Plot the SAR
plot(sar, style = plot.style_cross, linewidth=2, color = sarColor)

// Plot the ADX color background
adxColor = if(adx > 25)
    switch
        (diplus > diminus) => color.new(color.green, transp=90)
        (diplus < diminus) => color.new(color.red, transp=90)

bgcolor(adxColor)

// Probably comment the following out once you understand the chart
f_print("No background color means the ADX is indicating a rangebound market with no trend in place")