Exchange Net Highs-Lows
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © crutchie

//@version=5
indicator(title="Exchange Net Highs-Lows", shorttitle="Net Highs-Lows")

//Inputs
exchange = input.string("NYSE", options = ["NYSE", "Nasdaq"])
MA_length = input(50, "MA Length")

// Data
NetHL = exchange == "NYSE" ? request.security("MAHN", timeframe.period, close)-request.security("MALN",timeframe.period,close) : request.security("MAHQ", timeframe.period, close)-request.security("MALQ",timeframe.period,close)

// Determine color of bars
bar_color = NetHL >= 0 ? color.green : color.red

// Plots
plot(NetHL, "Net HL", style=plot.style_histogram, color=bar_color, linewidth=4)

Average = ta.sma(NetHL,MA_length)
plot(Average,"SMA", color = color.black)

hline(0, "Zero line",linestyle=hline.style_solid, color = color.black)

//Signal shading
signalcolor = NetHL > Average ? color.rgb(76, 175, 79, 90) : color.rgb(255, 82, 82, 92)
bgcolor(signalcolor, title = "Signal shading")