> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# xloc constants

> Reference for the 2 constants of the xloc namespace: xloc.bar_index and xloc.bar_time, each with its definition and an example.

> [!NOTE]
>
> Language version: 2 · Reference version: 2.7 · Date: 2026-10-25 · Compiler build: df7b3b14 · Namespace: xloc · Entries: 3

## `xloc` (library)

**Definition**

Named constants for how drawing x-coordinates are interpreted: bar index or UNIX time.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("xloc Library Example", overlay=true)
if barstate.islast {
    label.new(bar_index - 5, high[5], text="By bar index", xloc=xloc.bar_index)
    label.new(time[10], high[10], text="By time", xloc=xloc.bar_time)
}
```

## `xloc.bar_index` (constant)

**Definition**

X-coordinate is a bar index.

**Type**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("xloc.bar_index Example", overlay=true)
if barstate.islast {
    // x is a bar index: 10 bars ago
    label.new(bar_index - 10, high[10], text="10 bars ago", xloc=xloc.bar_index)
}
```

## `xloc.bar_time` (constant)

**Definition**

X-coordinate is a UNIX timestamp in milliseconds.

**Type**

`const string`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("xloc.bar_time Example", overlay=true)
if barstate.islast {
    // x is a UNIX time in milliseconds: the time of the bar 10 bars ago
    label.new(time[10], high[10], text="10 bars ago", xloc=xloc.bar_time)
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.