Skip to Main Content
Back to website
Indicator Disclaimer | Report this indicator

Overview
The ATR Table is a convenient and powerful "Heads-Up Display" (HUD) that provides a comprehensive, at-a-glance summary of an asset’s volatility. Instead of plotting a line in a separate panel, this indicator displays key Average True Range (ATR) metrics in a clean, customizable table directly on your price chart. This is particularly useful for traders, especially day traders, who need to quickly assess market conditions, evaluate risk, and determine the viability of potential trades without cluttering their charts.

How It Works
The indicator calculates the Average True Range (ATR) based on a user-defined length. It then populates a table with critical volatility data, which updates in real-time. The table shows not only the current ATR but also provides context by comparing it to the previous bar’s ATR and a short-term moving average of the ATR. All values are presented both in absolute points and as a percentage of the current price, allowing for standardized comparisons across different assets.

Key Features & How to Use

  • Comprehensive Volatility Dashboard: The table provides a multi-faceted view of volatility:
    • Current ATR: See the asset’s current expected range in both points and as a percentage of price.
    • Recent ATR: Compare the current ATR to the value from the previous bar to see if volatility is expanding or contracting in the immediate short term.
    • Average ATR: A 5-bar average of the ATR helps to smooth out noise and identify the recent trend in volatility.
  • Trade Viability Assessment: Use the ATR to set realistic expectations. If the current ATR is 15 points, a trade with a 50-point profit target might be unrealistic for the current session. It helps in setting practical stop-loss and take-profit levels.
  • Risk Management: A high ATR percentage indicates high volatility and, therefore, higher risk. This can inform position sizing decisions.
  • Fully Customizable: Users can adjust the ATR calculation length and choose the on-screen position of the table (top-left, top-right, bottom-left, or bottom-right) to best suit their chart layout.
describe_indicator('ATR Table');

const atrLength = input.number('ATR Length', 14, { min: 1 });
const tablePosition = input.select('Table Position', 'Bottom Left', ['Top Left', 'Top Right', 'Bottom Left', 'Bottom Right']);

const myAtr = atr(high, low, close, atrLength);
const myAtrAverage = sma(myAtr, 5);

const positionMap = {
    'Top Left': 'top_left',
    'Top Right': 'top_right',
    'Bottom Left': 'bottom_left',
    'Bottom Right': 'bottom_right'
};

const formatNumber = (num) => num.toFixed(2);
const formatPercent = (num) => num.toFixed(2) + '%';

// Import the tinycolor library
const tinycolor = library('tinycolor2');

const getColor = (color, alpha) => tinycolor(color).setAlpha(alpha).toRgbString();

paint_overlay('ATR Table', { position: positionMap[tablePosition] }, {
    rows: [
        {
            cells: [
                { text: 'ATR Period', color: 'white', background: getColor('blue', 0.1) },
                { text: atrLength.toString(), color: 'white', background: getColor('blue', 0.1) }
            ]
        },
        {
            cells: [
                { text: 'Current ATR (Points)', color: 'white', background: getColor('green', 0.1) },
                { text: formatNumber(myAtr[myAtr.length - 1]), color: 'white', background: getColor('green', 0.1) }
            ]
        },
        {
            cells: [
                { text: 'Current ATR (%)', color: 'white', background: getColor('green', 0.1) },
                { text: formatPercent((myAtr[myAtr.length - 1] / close[close.length - 1]) * 100), color: 'white', background: getColor('green', 0.1) }
            ]
        },
        {
            cells: [
                { text: 'ATR 1 Bar Ago (Points)', color: 'white', background: getColor('orange', 0.1) },
                { text: formatNumber(myAtr[myAtr.length - 2]), color: 'white', background: getColor('orange', 0.1) }
            ]
        },
        {
            cells: [
                { text: 'ATR 1 Bar Ago (%)', color: 'white', background: getColor('orange', 0.1) },
                { text: formatPercent((myAtr[myAtr.length - 2] / close[close.length - 2]) * 100), color: 'white', background: getColor('orange', 0.1) }
            ]
        },
        {
            cells: [
                { text: 'ATR Avg (5 Bars) (Points)', color: 'white', background: getColor('purple', 0.1) },
                { text: formatNumber(myAtrAverage[myAtrAverage.length - 1]), color: 'white', background: getColor('purple', 0.1) }
            ]
        },
        {
            cells: [
                { text: 'ATR Avg (5 Bars) (%)', color: 'white', background: getColor('purple', 0.1) },
                { text: formatPercent((myAtrAverage[myAtrAverage.length - 1] / close[close.length - 1]) * 100), color: 'white', background: getColor('purple', 0.1) }
            ]
        }
    ]
});