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

//@version=5

indicator(title="Volatility Percentage Indicator", shorttitle="VPI", overlay=true)


// Plotting lines -5%, -4%, -3%, -2%, -1%, 0%, +1%, +2%, +3%, +4%, +5%

line95=line.new(bar_index[1]+2,close*0.95,bar_index+3, close*0.95,extend=extend.none, color=color.silver, width=2)
line.delete(line95[1])
label95 = label.new(bar_index+3, close*0.95, "-5%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label95[1])

line96=line.new(bar_index[1]+2,close*0.96,bar_index+3, close*0.96,extend=extend.none, color=color.silver, width=1)
line.delete(line96[1])
label96 = label.new(bar_index+3, close*0.96, "-4%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label96[1])

line97=line.new(bar_index[1]+2,close*0.97,bar_index+3, close*0.97,extend=extend.none, color=color.silver, width=1)
line.delete(line97[1])
label97 = label.new(bar_index+3, close*0.97, "-3%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label97[1])

line98=line.new(bar_index[1]+2,close*0.98,bar_index+3, close*0.98,extend=extend.none, color=color.silver)
line.delete(line98[1])
label98 = label.new(bar_index+3, close*0.98, "-2%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label98[1])

line99=line.new(bar_index[1]+2,close*0.99,bar_index+3, close*0.99,extend=extend.none, color=color.silver)
line.delete(line99[1])
label99 = label.new(bar_index+3, close*0.99, "-1%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label99[1])

line100 = line.new(bar_index[1]+2, close, bar_index+3, close, extend=extend.none, color=color.silver, width=2)
line.delete(line100[1])
label100 = label.new(bar_index+3, close, "0%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label100[1])

line101=line.new(bar_index[1]+2,close*1.01,bar_index+3, close*1.01,extend=extend.none, color=color.silver)
line.delete(line101[1])
label101 = label.new(bar_index+3, close*1.01, "+1%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label101[1])

line102=line.new(bar_index[1]+2,close*1.02,bar_index+3, close*1.02,extend=extend.none, color=color.silver)
line.delete(line102[1])
label102 = label.new(bar_index+3, close*1.02, "+2%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label102[1])

line103=line.new(bar_index[1]+2,close*1.03,bar_index+3, close*1.03,extend=extend.none, color=color.silver, width=1)
line.delete(line103[1])
label103 = label.new(bar_index+3, close*1.03, "+3%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label103[1])

line104=line.new(bar_index[1]+2,close*1.04,bar_index+3, close*1.04,extend=extend.none, color=color.silver, width=1)
line.delete(line104[1])
label104 = label.new(bar_index+3, close*1.04, "+4%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label104[1])

line105=line.new(bar_index[1]+2,close*1.05,bar_index+3, close*1.05,extend=extend.none, color=color.silver, width=2)
line.delete(line105[1])
label105 = label.new(bar_index+3, close*1.05, "+5%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label105[1])