//@version=6 indicator("ADR Tracker", overlay = true) // ========== SAFETY CHECK ========== if not timeframe.isdaily runtime.error("This indicator only works on Daily timeframe. Please change to Daily chart.") // ========== INPUTS ========== lengthADRI_long = input.int(14, "ADR Long Length") lengthADRI_short = input.int(5, "ADR Short Length") // Table settings string tableSize = input.string("Normal", "Table Size", options = ["Small", "Normal", "Large", "Huge"]) string colorTheme = input.string("Dark", "Color Theme", options = ["Dark", "Light", "Blue", "Green", "Amber"]) // ========== AUTO PIP SIZE DETECTION ========== pipSize = syminfo.mintick * 10 // ========== MAP SIZE ========== getTextSize(string size) => switch size "Small" => size.small "Normal" => size.normal "Large" => size.large "Huge" => size.huge => size.normal // ========== MAP COLOR THEME ========== getThemeColors(string theme) => switch theme "Dark" => [color.new(color.black, 85), color.new(color.white, 0), color.new(color.gray, 50)] "Light" => [color.new(color.white, 85), color.new(color.black, 0), color.new(color.gray, 50)] "Blue" => [color.new(color.navy, 85), color.new(color.white, 0), color.new(color.blue, 70)] "Green" => [color.new(color.green, 85), color.new(color.white, 0), color.new(color.lime, 70)] "Amber" => [color.new(color.orange, 85), color.new(color.white, 0), color.new(color.yellow, 70)] => [color.new(color.black, 85), color.new(color.white, 0), color.new(color.gray, 50)] [bgColor, textColor, borderColor] = getThemeColors(colorTheme) tableFontSize = getTextSize(tableSize) // ========== CALCULATIONS (Daily TF only) ========== dailyRangePips = (high - low) / pipSize // Long ADR (14-day) adrPrice_long = ta.sma(high - low, lengthADRI_long) adrPips_long = adrPrice_long / pipSize // Short ADR (5-day) adrPrice_short = ta.sma(high - low, lengthADRI_short) adrPips_short = adrPrice_short / pipSize // Percentage based on LONG ADR percentUsed = (dailyRangePips / adrPips_long) * 100 pipsDifference = dailyRangePips - adrPips_long // Positive = over ADR, Negative = under ADR // Determine regime string regime = "" color regimeColor = color.gray if percentUsed >= 300 regime := "EXTREME" regimeColor := color.red else if percentUsed >= 150 regime := "EXPANSION" regimeColor := color.orange else regime := "NORMAL" regimeColor := color.green // ========== TABLE ========== var table adrTable = na if barstate.islast adrTable := table.new(position.top_right, 2, 6, bgcolor = bgColor, border_color = borderColor) // Header table.cell(adrTable, 0, 0, "ADR (14)", text_color = textColor, text_size = tableFontSize) table.cell(adrTable, 1, 0, str.tostring(adrPips_long, format.mintick) + " pips", text_color = textColor, text_size = tableFontSize) // Short ADR table.cell(adrTable, 0, 1, "ADR (5)", text_color = textColor, text_size = tableFontSize) table.cell(adrTable, 1, 1, str.tostring(adrPips_short, format.mintick) + " pips", text_color = textColor, text_size = tableFontSize) // Today's range table.cell(adrTable, 0, 2, "Today", text_color = textColor, text_size = tableFontSize) table.cell(adrTable, 1, 2, str.tostring(dailyRangePips, format.mintick) + " pips", text_color = textColor, text_size = tableFontSize) // Percentage used table.cell(adrTable, 0, 3, "Used", text_color = textColor, text_size = tableFontSize) color percentColor = percentUsed >= 100 ? color.red : percentUsed >= 75 ? color.orange : textColor table.cell(adrTable, 1, 3, str.tostring(percentUsed, "#.##") + "%", text_color = percentColor, text_size = tableFontSize) // Extra (shows both negative and positive) table.cell(adrTable, 0, 4, "Extra", text_color = textColor, text_size = tableFontSize) string extraText = (pipsDifference > 0 ? "+" : "") + str.tostring(pipsDifference, format.mintick) + " pips" color extraColor = pipsDifference > 0 ? color.red : (pipsDifference < 0 ? color.green : textColor) table.cell(adrTable, 1, 4, extraText, text_color = extraColor, text_size = tableFontSize) // Regime table.cell(adrTable, 0, 5, "Regime", text_color = textColor, text_size = tableFontSize) table.cell(adrTable, 1, 5, regime, text_color = regimeColor, text_size = tableFontSize)