---
id: "M:cAlgo.API.TimeSeries.GetIndexByExactTime(System.DateTime)"
kind: "method"
type: "T:cAlgo.API.TimeSeries"
url: "https://help.ctrader.com/ctrader-algo/references/Collections/DataSeries/TimeSeries/GetIndexByExactTime/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# TimeSeries.GetIndexByExactTime

Member of [TimeSeries](https://help.ctrader.com/ctrader-algo/references/Collections/DataSeries/TimeSeries/index.md).

## GetIndexByExactTime(DateTime dateTime)

Find the index in the different time frame series.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
int GetIndexByExactTime(DateTime dateTime)
```

Python:

```python
timeSeries.GetIndexByExactTime(dateTime: DateTime) -> int
```

### Parameters

- `dateTime` (`DateTime`, Python `DateTime`): The open time of the bar at this index

### Returns

`int` — Exact index of bar at passed time

### Examples

C#:

```csharp
var hourlyBars = MarketData.GetBars(TimeFrame.Hour);
var hourlyIndex = hourlyBars.OpenTimes.GetIndexByExactTime(Bars.OpenTimes.LastValue);
if (hourlyIndex >= 0)
    Print("Hourly bar with the same open time: {0}", hourlyBars[hourlyIndex].Close);
else
    Print("No hourly bar opened exactly at {0}", Bars.OpenTimes.LastValue);
```

Python:

```python
hourlyBars = api.MarketData.GetBars(TimeFrame.Hour)
hourlyIndex = hourlyBars.OpenTimes.GetIndexByExactTime(api.Bars.OpenTimes.LastValue)
if hourlyIndex >= 0:
    api.Print(f"Hourly bar with the same open time: {hourlyBars[hourlyIndex].Close}")
else:
    api.Print(f"No hourly bar opened exactly at {api.Bars.OpenTimes.LastValue}")
```

