> ## 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.

# How to put a marker on a specific bar

> Marking one bar with plotshape by writing a condition that is true on exactly that bar, or with a label for a marker that carries text.

`plotshape` takes a condition as its first argument and marks the bars where it is true. To mark one bar, write a condition that is
true on one bar.

```lipi wrap theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Mark the last bar", overlay=true)
plot(close, title="Close", color=color.gray)
plotshape(barstate.islast, title="Last bar", shape=shape.flag, location=location.abovebar, color=color.blue, size=size.small)
```

| To mark | Condition |
| - | - |
| the first bar of the chart | `barstate.isfirst` |
| the last bar of the chart | `barstate.islast` |
| the last loaded bar of a closed market | `barstate.islastconfirmedhistory` (never true while the market is open) |
| the first bar of each session | `session.isfirst` |
| a bar you can name by position | `bar_index == 250` |

`bar_index` is a series value, so comparing it with a number picks out one bar.

## Other markers

* `plotchar` is `plotshape` with a character (`char`) in place of the shape.
* `plotarrow` takes a number, not a condition, and has no location, shape, size or text: `colorup` and `colordown` color its two kinds
  of arrow and the size follows the number.
* A label carries text and may be created inside an `if`, because drawing calls have no top-level rule:

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Mark the 250th bar with a label", overlay=true)
if bar_index == 250 {
    label.new(bar_index, high, "Bar 250", style=label.style_label_down)
}
```

The `x` of a label is a bar index, so subtract an offset to mark a bar further back: on the newest bar, `label.new(bar_index - 3, high[3], "3 back")` marks the bar three before it, at that bar's high.

## The mistake to avoid

Calling `plotshape`, `plotchar` or `plotarrow` inside an `if` to pick the bar. They must be at the top level, so the condition goes
in the first argument; two conditions mean two calls. Putting one inside a branch gives: `plotshape()` must be called in the global scope.
See [Text and markers](https://gocharting.com/docs/scripting/chart-output/text-and-markers.md).


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