NYSE & NASDAQ Advance Minus Decline Oscillator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © All_Verklempt

//@version=5

indicator("NYSE & NASDAQ Advance Minus Decline Oscillator", "Market A-D", format=format.price, precision=2, timeframe="", timeframe_gaps=true)

// Symbol Inputs

symbolInput01 = input.symbol("ADD", "NYSE")
symbolInput02 = input.symbol("ADDQ", "NASDAQ")

// Other Inputs

marketupper = 2000
marketlower = -2000
midline     = plot(0, "Midline", color = #916cda, linewidth = 2)

// Symbol Calls

symbol01 = request.security(symbolInput01, timeframe.period, expression = close)
symbol02 = request.security(symbolInput02, timeframe.period, expression = close)


// Colors
colUp1 = symbol01 > 0 ? input.color(color.rgb(227,218,201), '', group= 'formula > 0', inline= 'up') : 
                   input.color(color.rgb(165, 80, 98), '', group= 'formula < 0', inline= 'dn')
colDn1 = symbol01 > 0 ? input.color(color.rgb(165, 80, 98), '', group= 'formula > 0', inline= 'up') : 
                   input.color(color.rgb(227,218,201), '', group= 'formula < 0', inline= 'dn')

colUp2 = symbol02 > 0 ? input.color(color.rgb(227,218,201), '', group= 'formula > 0', inline= 'up') : 
                   input.color(color.rgb(145,108,218), '', group= 'formula < 0', inline= 'dn')
colDn2 = symbol02 > 0 ? input.color(color.rgb(145,108,218), '', group= 'formula > 0', inline= 'up') : 
                   input.color(color.rgb(227,218,201), '', group= 'formula < 0', inline= 'dn')
//–––––––––––[   fill   ]–––––––––––
// fill colour between lines 'formulaPlot' & 'centerPlot'

// if value (formula) > 0 -> top_value = 2000, bottom_value = 0, use colour set colUp
// if value (formula) < 0 -> top_value = 0, bottom_value = -2000, use colour set colDn

// Plot Information

plot1 = plot(symbol01, title="S01", color=#a55062, linewidth = 3)
plot2 = plot(symbol02, title="S02", color=#916cda, linewidth = 3)

// when formula moves between these limits, the color will change towards the upper or lower colour, dependable where formula is situated
fill(plot1, midline, symbol01 > 0 ? 2000 : 0, symbol01 > 0 ? 0: -2000, colUp1, colDn1)
fill(plot2, midline, symbol02 > 0 ? 2000 : 0, symbol02 > 0 ? 0: -2000, colUp2, colDn2)




