> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# GetTimeByBarIdx()

## Definition

Returns the **ChartBars** time value calculated from a bar index parameter provided.

## Method Return Value

A **DateTime** struct representing a bar time value at a specific bar index value.

## Syntax

`ChartBars.GetTimeByBarIdx(ChartControl chartControl, int barIndex)`

## Method Parameters

| Parameter        | Description                                                                             |
| ---------------- | --------------------------------------------------------------------------------------- |
| **chartControl** | The **ChartControl** object used to determine the chart's time axis                     |
| **barIndex**     | An **int** value representing a bar index used to convert to a **ChartBar** index value |

## Examples

```csharp
protected override void OnBarUpdate()
{
   if (ChartBars != null)
   {
     Print(ChartBars.GetTimeByBarIdx(ChartControl, 50)); //8/11/2015 4:30:00 AM
   }
}
```