Bitcoin Miner Sell Pressure
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capriole_charles

//@version=5
indicator("Bitcoin Miner Sell Pressure",overlay=false)

miner_out = request.security("INTOTHEBLOCK:BTC_MINEROUTFLOWS","D",close)
miner_res = request.security("INTOTHEBLOCK:BTC_MINERRESERVES","D",close)

m   = math.sum(miner_out,30)/ta.sma(miner_res,30)
bbl = ta.sma(m,200) - 1*ta.stdev(m,200)
bbu = ta.sma(m,200) + 1*ta.stdev(m,200)

plot(m,color=color.blue,linewidth=2)
plot(bbl,color=color.new(color.gray,70))
plot(bbu,color=color.new(color.gray,70))
bgcolor(m>bbu?color.new(color.red,80):na)

// Sourcing
var table_source = table(na)
table_source := table.new(position=position.bottom_left, columns=1, rows=1, bgcolor=color.white, border_width=1)
table.cell(table_source, 0, 0, text="Source: Capriole Investments", bgcolor=color.white, text_color=color.black, width=20, height=7, text_size=size.normal, text_halign=text.align_left)