# EminiAddict.com # === Upper-Right "ATR" Bubble (price + ticks) === input ATRLength = 14; input lookbackBars = 100; # window to estimate top of range input topPaddingPercent = 2.0; # % below the top (smaller = closer to top) DefineGlobalColor("Bubble", Color.YELLOW); # ATR calculation (in price units) def ATR = Round(Average(TrueRange(high, close, low), ATRLength), 2); # Convert ATR to ticks def ATRticks = Round(ATR / TickSize(), 0); # Anchor to last bar def lastBar = !IsNaN(close) and IsNaN(close[-1]); # Y-level near the top of recent range # Calculate highest/lowest once and store them properly def highestHigh = Highest(high, lookbackBars); def lowestLow = Lowest(low, lookbackBars); def range = highestHigh - lowestLow; def safeRange = if range > TickSize() * 10 then range else TickSize() * 10; def yTop = highestHigh - safeRange * (topPaddingPercent / 100.0); # Draw ATR in price and ticks AddChartBubble( lastBar, yTop, "ATR=" + ATR + " (" + ATRticks + " ticks)", GlobalColor("Bubble"), yes );