Skip to content

CustomSymbol.AddBars

method · CustomSymbol · cAlgo.API Since 5.3

DesktopCLICloud

Adds bars for a time frame that will be used for this custom symbol.

Environment behaviour

CLI — not supported. Available to plugins only, and plugins cannot run in the CLI.

Cloud — not supported. Available to plugins only, and plugins cannot run in the cloud.

Definition

CustomBars AddBars(TimeFrame timeFrame)
customSymbol.AddBars(timeFrame: TimeFrame) -> CustomBars

Parameters

Name C# type Python type Description
timeFrame TimeFrame TimeFrame Bars TimeFrame, it must be a built-in time frame not custom.

Returns CustomBars — CustomBars

Examples

var customSymbol = CustomSymbols.Add("MYEURUSD", Symbols.GetSymbol("EURUSD"));
var customBars = customSymbol.AddBars(TimeFrame.Hour);
var sourceBars = MarketData.GetBars(TimeFrame.Hour, "EURUSD");
customBars.AppendBars(sourceBars.Select(bar => new CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, (long)bar.TickVolume)));
customSymbol = api.CustomSymbols.Add("MYEURUSD", api.Symbols.GetSymbol("EURUSD"))
customBars = customSymbol.AddBars(TimeFrame.Hour)
for bar in api.MarketData.GetBars(TimeFrame.Hour, "EURUSD"):
    customBars.AppendBar(CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, int(bar.TickVolume)))