---
id: "T:cAlgo.API.CustomTimeFrameBarsNeededArgs"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomTimeFrameBarsNeededArgs/"
---

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

# CustomTimeFrameBarsNeededArgs (class)

Provides data for custom time frame BarsNeeded handler.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

## Definition

```csharp
public class CustomTimeFrameBarsNeededArgs
```

Available since cAlgo.API 5.3.

## Examples

C#:

```csharp
protected override void OnStart()
{
    var customTimeFrame = TimeFrameManager.Custom.Add("My Custom TF");
    customTimeFrame.BarsNeeded = OnBarsNeeded;
}

private void OnBarsNeeded(CustomTimeFrameBarsNeededArgs args)
{
    var bars = MarketData.GetBars(TimeFrame.Daily, args.CustomBars.Symbol.Name);
    args.CustomBars.AppendBars(bars.Select(bar => new CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, (long)bar.TickVolume)));
    Print("Provided {0} bars for {1}", bars.Count, args.CustomTimeFrame.Name);
}
```

Python:

```python
from System import Action

def on_start(self):
    customTimeFrame = api.TimeFrameManager.Custom.Add("My Custom TF")
    customTimeFrame.BarsNeeded = Action[CustomTimeFrameBarsNeededArgs](self.on_bars_needed)

def on_bars_needed(self, args):
    bars = api.MarketData.GetBars(TimeFrame.Daily, args.CustomBars.Symbol.Name)
    for bar in bars:
        args.CustomBars.AppendBar(CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, int(bar.TickVolume)))
    api.Print(f"Provided {bars.Count} bars for {args.CustomTimeFrame.Name}")
```

## Properties

- `public CustomBars CustomBars {get;}` — Gets custom bars. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomTimeFrameBarsNeededArgs/CustomBars/index.md)
- `public CustomTimeFrame CustomTimeFrame {get;}` — Gets custom time frame. [details](https://help.ctrader.com/ctrader-algo/references/Plugin/TimeFrame/Custom/CustomTimeFrameBarsNeededArgs/CustomTimeFrame/index.md)

