ADR in 0.5 / 1 / 3 / 5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © superbeeki

//@version=5

indicator(title='ADR in 0.5 / 1 / 3 / 5', shorttitle='ADR indicator', overlay=true, precision=2)

//adr information
show_adrp = input(true, title='Show ADR')
adrp_length = input.int(20, title='ADR length')
adrp_col = input(color.white, title='Text color (ADR%)')

//adr * 3
show_adrp3 = input(true, title='Show ADR*3')
adrp3_col = input(color.white, title='Text color (ADR*3)')

//adr * 5
show_adrp5 = input(true, title='Show ADR*5')
adrp5_col = input(color.white, title='Text color (ADR*5)')

//adr * 0.5 in dollar
show_adrd05 = input(true, title='Show ADR*0.5 in $')
adrd05_col = input(color.white, title='Text color ADR*0.5 in $')


//data creation
arp = 100 * (ta.sma(high / low, adrp_length) - 1)
adrp = request.security(syminfo.tickerid, 'D', arp)
adrp3 = 3 * adrp
adrp5 = 5* adrp
adrp05 = 0.5 * adrp
adrd05 = (open * adrp05) / 100 

//table
bg_col = input(#00000000, title='Background color')
table t = table.new(position.bottom_right, 2, 5, bgcolor=bg_col, frame_color=color.white)
if barstate.islast
    if show_adrd05
        table.cell(t, 0, 0, 'ADR*0.5', text_color=adrd05_col, text_size=size.normal)
        table.cell(t, 1, 0, str.tostring(math.round(adrd05, 2)) + '$', text_color=adrd05_col, text_size=size.normal)
    if show_adrp
        table.cell(t, 0, 1, 'ADR', text_color=adrp_col, text_size=size.normal)
        table.cell(t, 1, 1, str.tostring(math.round(adrp, 2)) + '%', text_color=adrp_col, text_size=size.normal)
    if show_adrp3
        table.cell(t, 0, 2, 'ADR*3', text_color=adrp3_col, text_size=size.normal)
        table.cell(t, 1, 2, str.tostring(math.round(adrp3, 2)) + '%', text_color=adrp3_col, text_size=size.normal)
    if show_adrp5
        table.cell(t, 0, 3, 'ADR*5', text_color=adrp5_col, text_size=size.normal)
        table.cell(t, 1, 3, str.tostring(math.round(adrp5, 2)) + '%', text_color=adrp5_col, text_size=size.normal)
