Exhaustion Table [SpiritualHealer117]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © spiritualhealer117

//@version=5
indicator("Exhaustion Table",overlay=true)
src = input.source(close, "Source")
c1 = input.color(color.red, "Color 1")
c2 = input.color(color.white,"Color 2")
stdev_len = input.int(300,"Standard Deviation Calculation Length")

calc_ppo(len) =>
    (src-ta.ema(src,len))/ta.ema(src,len)

ppo15 = calc_ppo(15)
ppo30 = calc_ppo(30)
ppo50 = calc_ppo(50)
ppo100 = calc_ppo(100)
ppo300 = calc_ppo(300)

s1 = ta.stdev(ppo15,stdev_len)<ppo15?"↓":-ta.stdev(ppo15,stdev_len)>ppo15?"↑":"="
s2 = ta.stdev(ppo30,stdev_len)<ppo30?"↓":-ta.stdev(ppo30,stdev_len)>ppo30?"↑":"="
s3 = ta.stdev(ppo50,stdev_len)<ppo50?"↓":-ta.stdev(ppo50,stdev_len)>ppo50?"↑":"="
s4 = ta.stdev(ppo100,stdev_len)<ppo100?"↓":-ta.stdev(ppo100,stdev_len)>ppo100?"↑":"="
s5 = ta.stdev(ppo300,stdev_len)<ppo300?"↓":-ta.stdev(ppo300,stdev_len)>ppo300?"↑":"="

s21 = 2*ta.stdev(ppo15,stdev_len)<ppo15?"↓":-2*ta.stdev(ppo15,stdev_len)>ppo15?"↑":"="
s22 = 2*ta.stdev(ppo30,stdev_len)<ppo30?"↓":-2*ta.stdev(ppo30,stdev_len)>ppo30?"↑":"="
s23 = 2*ta.stdev(ppo50,stdev_len)<ppo50?"↓":-2*ta.stdev(ppo50,stdev_len)>ppo50?"↑":"="
s24 = 2*ta.stdev(ppo100,stdev_len)<ppo100?"↓":-2*ta.stdev(ppo100,stdev_len)>ppo100?"↑":"="
s25 = 2*ta.stdev(ppo300,stdev_len)<ppo300?"↓":-2*ta.stdev(ppo300,stdev_len)>ppo300?"↑":"="

if barstate.islast
    exhaustion_table = table.new(position.top_right,4,6,color.new(c1,20),c2,1,c2,1)
    table.cell(exhaustion_table,0,0,"Length", text_color = c2)
    table.cell(exhaustion_table,1,0,"Exhaustion", text_color = c2)
    table.cell(exhaustion_table,2,0,"σ", text_color = c2)
    table.cell(exhaustion_table,3,0,"2σ", text_color = c2)
    table.cell(exhaustion_table,1,1,str.tostring(math.round(ppo15,3)), text_color = c2)
    table.cell(exhaustion_table,1,2,str.tostring(math.round(ppo30,3)), text_color = c2)
    table.cell(exhaustion_table,1,3,str.tostring(math.round(ppo50,3)), text_color = c2)
    table.cell(exhaustion_table,1,4,str.tostring(math.round(ppo100,3)), text_color = c2)
    table.cell(exhaustion_table,1,5,str.tostring(math.round(ppo300,3)), text_color = c2)

    table.cell(exhaustion_table,2,1,s1, text_color = c2)
    table.cell(exhaustion_table,2,2,s2, text_color = c2)
    table.cell(exhaustion_table,2,3,s3, text_color = c2)
    table.cell(exhaustion_table,2,4,s4, text_color = c2)
    table.cell(exhaustion_table,2,5,s5, text_color = c2)

    table.cell(exhaustion_table,3,1,s21, text_color = c2)
    table.cell(exhaustion_table,3,2,s22, text_color = c2)
    table.cell(exhaustion_table,3,3,s23, text_color = c2)
    table.cell(exhaustion_table,3,4,s24, text_color = c2)
    table.cell(exhaustion_table,3,5,s25, text_color = c2)

    table.cell(exhaustion_table,0,1,"15", text_color = c2)
    table.cell(exhaustion_table,0,2,"30", text_color = c2)
    table.cell(exhaustion_table,0,3,"50", text_color = c2)
    table.cell(exhaustion_table,0,4,"100", text_color = c2)
    table.cell(exhaustion_table,0,5,"300", text_color = c2)