ATR Multiplier Overlay
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Credits to bjr117 for original code, Modified by Hedgineering

//@version=5
indicator(title = "ATR Multiplier", shorttitle = "ATRX", overlay = true)

//==============================================================================
// Input Parameters
//==============================================================================
atr_length      = input.int(14, title = "ATR Length", minval = 0, group = "ATR Indicator Settings")

atr1_multiplier = input.float(1.5, title = "ATR Multiplier #1", minval = 0, group = "ATR Multiplier Settings")
show_atr2       = input.bool(false, title = "Show 2nd ATR line?",           group = "ATR Multiplier Settings")
atr2_multiplier = input.float(3,   title = "ATR Multiplier #2", minval = 0, group = "ATR Multiplier Settings")

offset = input.int(0, title = "ATR Length", minval = 0, group = "ATR Indicator Backward Offset")
//==============================================================================


//==============================================================================
// ATR #1 and ATR #2 Calculation
//==============================================================================
// Calculate basic ATR value with given smoothing parameters
atr  = ta.rma(ta.tr, atr_length)

// Multiply atr by the given atr1 multiplier to get atr1
atr1_top = atr * atr1_multiplier + close[offset]
atr1_bottom = atr * atr1_multiplier * -1 + close[offset]

// Multiply atr by the given atr2 multiplier to get atr2
atr2_top = atr * atr2_multiplier + close[offset]
atr2_bottom = atr * atr2_multiplier * -1 + close[offset]
//==============================================================================


//==============================================================================
// Plot ATR #1 and ATR #2
//==============================================================================
atr1_color = show_atr2 ? color.red : color.new(#0000ff, 0)

atr1_top_plot = plot(atr1_top, title = "ATR #1 Top", color = atr1_color)
atr1_bottom_plot = plot(atr1_bottom, title = "ATR #1 Bottom", color = atr1_color)
atr2_top_plot = plot(show_atr2 ? atr2_top : na, title = "ATR #2 Top", color = color.green)
atr2_bottom_plot = plot(show_atr2 ? atr2_bottom : na, title = "ATR #2 Bottom", color = color.green)
//==============================================================================