Skip to content

CustomBars.PrependBar

method · CustomBars · cAlgo.API Since 5.3

DesktopCLICloud

Prepends a new bar to the start of bars collection.

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

void PrependBar(CustomBar bar)
customBars.PrependBar(bar: CustomBar) -> None

Parameters

Name C# type Python type Description
bar CustomBar CustomBar New bar

Examples

var customBars = TimeFrameManager.Custom.Add("My Custom TF").AddBars(Symbols.GetSymbol("EURUSD"));
var openTime = customBars.Bars.Count > 0 ? customBars.Bars[0].OpenTime.AddHours(-1) : Server.Time.Date;
customBars.PrependBar(new CustomBar(openTime, 1.0830, 1.0855, 1.0825, 1.0850, 900));
customBars = api.TimeFrameManager.Custom.Add("My Custom TF").AddBars(api.Symbols.GetSymbol("EURUSD"))
openTime = customBars.Bars[0].OpenTime.AddHours(-1) if customBars.Bars.Count > 0 else api.Server.Time.Date
customBars.PrependBar(CustomBar(openTime, 1.0830, 1.0855, 1.0825, 1.0850, 900))