TSG's Binance Round NRs - only for BTC
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheSecretsOfTrading

//@version=5
indicator("TSG's Binance Round NRs", overlay = true)

check = input.int(20, "Candles to check")

var label highlab = label.new(na, na, "", color = color.new(color.black, 99), textcolor = color.white)
var label lowlab = label.new(na, na, "", style=label.style_label_up, color = color.new(color.black, 99), textcolor = color.white)

bin_perp_highs = request.security("BTCUSDTPERP", timeframe.period, high)
bin_perp_lows = request.security("BTCUSDTPERP", timeframe.period, low)

highest = ta.highest( bin_perp_highs, check)
lowest = ta.lowest( bin_perp_lows, check)

if barstate.islast
    for i=0 to check
        if bin_perp_highs[i] == math.round(bin_perp_highs[i]) and bin_perp_highs[i] == highest
            label.set_x(highlab, bar_index-i)
            label.set_y(highlab, high[i])
            label.set_text(highlab, str.tostring(bin_perp_highs[i]))
            break
    for i=0 to check
        if bin_perp_lows[i] == math.round(bin_perp_lows[i]) and bin_perp_lows[i] == lowest
            label.set_x(lowlab, bar_index-i)
            label.set_y(lowlab, low[i])
            label.set_text(lowlab, str.tostring(bin_perp_lows[i]))
            break
