Volatility Elvis
// 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_")

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


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", text_color = color.white, bgcolor = #336688)
table.cell(statTable, 2, 0, " Ticker                ", text_color = color.white, bgcolor = #336688)
table.cell(statTable, 3, 0, " Volatility", 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, 2, 1, coin7, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 2, 2, coin8, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 2, 3, coin9, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 2, 4, coin10, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 2, 5, coin11, text_color = color.white, bgcolor = #9999EE)
table.cell(statTable, 2, 6, coin12, 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, 3, 1, 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, 3, 2, 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, 3, 3, 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, 3, 4, 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, 3, 5, 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, 3, 6, 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)

