BinanceUS Wicks
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5

// -- made by Loner , @btcexe

indicator(title='BinanceUS Wicks', max_lines_count=500, overlay =true)

div = input(defval=3000,title = ' SPOT/US Div')

// Binance Spot
A = request.security('BINANCE:BTCUSDT','240',high)
B = request.security('BINANCE:BTCUSDT','240',low)
//Binance US USDC
C = request.security('BINANCEUS:BTCUSDC','240',high)
D = request.security('BINANCEUS:BTCUSDC','240',low)
//Binance US USD
E = request.security('BINANCEUS:BTCUSD','240',high)
F = request.security('BINANCEUS:BTCUSD','240',low)


// Wick Condition calculation
// Upside wick
p1 = if C > (A + div) or E > ( A + div) 
    true
else 
    na
//Downside wick
p2 = if  D < (B - div) or F < (B - div) 
    true
else 
    na

//Condition to have plots only on BTC charts ...
var visible = false
var tickers = array.new_string(9)
array.set(tickers, 0, "XBTUSD")
array.set(tickers, 1, "XBTUSDT")
array.set(tickers, 2, "BTCUSDT")
array.set(tickers, 3, "BTCUSDTPERP")
array.set(tickers, 4, "BTCPERP")
array.set(tickers, 5, "BTCUSDT.P")
array.set(tickers, 6, "BTCUSD.P")
array.set(tickers, 7, "BTCUSD")
array.set(tickers, 8, "XBTUSD.P")

for i = 0 to 8
    if syminfo.ticker == array.get(tickers, i)
        visible := true
        break

// condition to detect eithr of USDC OR USD Wick based on which one is noticeable.
//upside
Lcon()=>
    if C > E
        C
    else if E > C
        E

//downside
Scon()=>
    if D < F
        D
    else if F < D
        F

//arrays
var body = array.new_line()

//Wick plot color ...
col = close > open ? #63cddd3f : close < open ? #ed5d2d75 :na

// plotting Up and Down wicks ...
if p1 and visible

    L = line.new(bar_index,open,bar_index,Lcon(),color=col, width=4)
    if array.size(body) == 30
        line.delete(array.shift(body))
    array.push(body, L)
   
if p2 and visible

    L2 = line.new(bar_index,open,bar_index,Scon(),color=col, width=4)
    if array.size(body) == 30
        line.delete(array.shift(body))
    array.push(body, L2)
   

// Circle plots
plotshape(series=p1 and visible,location=location.abovebar,size=size.tiny,style = shape.circle,color=color.rgb(76, 175, 79, 60))
plotshape(series=p2 and visible,location=location.belowbar,size=size.tiny,style = shape.circle,color=color.rgb(255, 82, 82, 60))

// Alert condition based wicks
alertcondition(p1, title='WICK UPSIDE', message=' Binance US printed Huge wick upside !!')
alertcondition(p2, title='WICK DOWNSIDE', message='Binance Us printed Huge wick downside !!')

// Code End ! :-)