Volatility Screener
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © hajixde

//@version=5
indicator("Volatility Screener", overlay = false)


coin1 = input.string("WINUSDT", group = "Coins" , inline = "coins_")
coin2 = input.string("DODOUSDT", group = "Coins" , inline = "coins_")
coin3 = input.string("AUCTIONUSDT", group = "Coins" , inline = "coins_")
coin4 = input.string("MBOXUSDT", group = "Coins" , inline = "coins_")
coin5 = input.string("ETHUSDT", group = "Coins" , inline = "coins_")
coin6 = input.string("BTCUSDT", group = "Coins" , inline = "coins_")
coin7 = input.string("IMXUSDT", group = "Coins" , inline = "coins_")
coin8 = input.string("VIDYUSDT", group = "Coins" , inline = "coins_")
coin9 = input.string("ALICEUSDT", group = "Coins" , inline = "coins_")
coin10 = input.string("VGXUSDT", group = "Coins" , inline = "coins_")
coin11 = input.string("CTKUSDT", group = "Coins" , inline = "coins_")
coin12 = input.string("BORINGUSDT", group = "Coins" , inline = "coins_")
coin13 = input.string("DOGEUSDT", group = "Coins" , inline = "coins_")
coin14 = input.string("SHIBUSDT", group = "Coins" , inline = "coins_")
coin15 = input.string("LAMBUSDT", group = "Coins" , inline = "coins_")

length = input.int(100, minval=1)
minVolatility = input.float(10, title = "Minimum Volatility Percentage")


volatility(src, len) =>
    dev = ta.stdev(src, len)
    s = ta.sma(src, len)
    v = 100*dev / s
    v

vol2price(src, volume_, len) =>
    close24 = ta.sma(src, len)
    vol = ta.sma(volume_, len)
    x = vol*close24/1000000
    x

priceChange(src, len) =>
    close24 = ta.sma(src, len)
    x = 100*(src - close24)/close24
    x


var table statTable = table.new(position.middle_center, 4, 36,  bgcolor = color.black, frame_width = 1, frame_color = color.black, border_color = color.black, border_width = 1)
table.cell(statTable, 0, 0, " Ticker                ", text_color = color.white, bgcolor = #336688)
table.cell(statTable, 1, 0, " Volatility Index", text_color = color.white, bgcolor = #336688)
table.cell(statTable, 2, 0, " Volume*Price/1M", text_color = color.white, bgcolor = #336688)
table.cell(statTable, 3, 0, " Price Change", text_color = color.white, bgcolor = #336688)

table.cell(statTable, 0, 1, coin1, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 2, coin2, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 3, coin3, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 4, coin4, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 5, coin5, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 6, coin6, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 7, coin7, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 8, coin8, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 9, coin9, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 10, coin10, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 11, coin11, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 12, coin12, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 13, coin13, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 14, coin14, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 0, 15, coin15, text_color = color.white, bgcolor = #9999EE)



table.cell(statTable, 1, 1, str.tostring(volatility(request.security(coin1, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin1, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 2, str.tostring(volatility(request.security(coin2, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin2, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 3, str.tostring(volatility(request.security(coin3, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin3, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 4, str.tostring(volatility(request.security(coin4, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin4, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 5, str.tostring(volatility(request.security(coin5, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin5, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 6, str.tostring(volatility(request.security(coin6, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin6, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 7, str.tostring(volatility(request.security(coin7, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin7, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 8, str.tostring(volatility(request.security(coin8, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin8, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 9, str.tostring(volatility(request.security(coin9, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin9, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 10, str.tostring(volatility(request.security(coin10, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin10, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 11, str.tostring(volatility(request.security(coin11, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin11, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 12, str.tostring(volatility(request.security(coin12, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin12, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 13, str.tostring(volatility(request.security(coin13, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin13, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 14, str.tostring(volatility(request.security(coin14, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin14, timeframe.period, close), length) > minVolatility ? #992266 : #998833)
table.cell(statTable, 1, 15, str.tostring(volatility(request.security(coin15, timeframe.period, close), length), "#.##") + " %", text_color = color.white, 
     bgcolor = volatility(request.security(coin15, timeframe.period, close), length) > minVolatility ? #992266 : #998833)


v1 = vol2price(request.security(coin1, timeframe.period, close), request.security(coin1, timeframe.period, volume), length)
table.cell(statTable, 2, 1, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin2, timeframe.period, close), request.security(coin2, timeframe.period, volume), length)
table.cell(statTable, 2, 2, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin3, timeframe.period, close), request.security(coin3, timeframe.period, volume), length)
table.cell(statTable, 2, 3, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin4, timeframe.period, close), request.security(coin4, timeframe.period, volume), length)
table.cell(statTable, 2, 4, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin5, timeframe.period, close), request.security(coin5, timeframe.period, volume), length)
table.cell(statTable, 2, 5, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin6, timeframe.period, close), request.security(coin6, timeframe.period, volume), length)
table.cell(statTable, 2, 6, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin7, timeframe.period, close), request.security(coin7, timeframe.period, volume), length)
table.cell(statTable, 2, 7, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin8, timeframe.period, close), request.security(coin8, timeframe.period, volume), length)
table.cell(statTable, 2, 8, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin9, timeframe.period, close), request.security(coin9, timeframe.period, volume), length)
table.cell(statTable, 2, 9, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin10, timeframe.period, close), request.security(coin10, timeframe.period, volume), length)
table.cell(statTable, 2, 10, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin11, timeframe.period, close), request.security(coin11, timeframe.period, volume), length)
table.cell(statTable, 2, 11, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin12, timeframe.period, close), request.security(coin12, timeframe.period, volume), length)
table.cell(statTable, 2, 12, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin13, timeframe.period, close), request.security(coin13, timeframe.period, volume), length)
table.cell(statTable, 2, 13, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin14, timeframe.period, close), request.security(coin14, timeframe.period, volume), length)
table.cell(statTable, 2, 14, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)
v1 := vol2price(request.security(coin15, timeframe.period, close), request.security(coin15, timeframe.period, volume), length)
table.cell(statTable, 2, 15, str.tostring(v1, "#.##"), text_color = color.white, bgcolor = v1 > 1 ? #992266 : #998833)


v1 := priceChange(request.security(coin1, timeframe.period, close), length)
table.cell(statTable, 3, 1, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin2, timeframe.period, close), length)
table.cell(statTable, 3, 2, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin3, timeframe.period, close), length)
table.cell(statTable, 3, 3, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin4, timeframe.period, close), length)
table.cell(statTable, 3, 4, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin5, timeframe.period, close), length)
table.cell(statTable, 3, 5, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin6, timeframe.period, close), length)
table.cell(statTable, 3, 6, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin7, timeframe.period, close), length)
table.cell(statTable, 3, 7, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin8, timeframe.period, close), length)
table.cell(statTable, 3, 8, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin9, timeframe.period, close), length)
table.cell(statTable, 3, 9, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin10, timeframe.period, close), length)
table.cell(statTable, 3, 10, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin11, timeframe.period, close), length)
table.cell(statTable, 3, 11, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin12, timeframe.period, close), length)
table.cell(statTable, 3, 12, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin13, timeframe.period, close), length)
table.cell(statTable, 3, 13, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin14, timeframe.period, close), length)
table.cell(statTable, 3, 14, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)
v1 := priceChange(request.security(coin15, timeframe.period, close), length)
table.cell(statTable, 3, 15, str.tostring(v1, "#.##") + " %", text_color = color.white, bgcolor = v1 > 0 ? #008822 : #880022)


