CustomBars.PrependBars
method · CustomBars · cAlgo.API Since 5.3
DesktopCLICloud
Prepends a collection of bars 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 PrependBars(IEnumerable<CustomBar> bars)
customBars.PrependBars(bars: Iterable[CustomBar]) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
bars | IEnumerable<CustomBar> | Iterable[CustomBar] | New bars |
Examples
var customBars = TimeFrameManager.Custom.Add("My Custom TF").AddBars(Symbols.GetSymbol("EURUSD"));
var sourceBars = MarketData.GetBars(TimeFrame.Hour, "EURUSD");
var loadedCount = sourceBars.LoadMoreHistory();
customBars.PrependBars(sourceBars.Take(loadedCount).Select(bar => new CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, (long)bar.TickVolume)));
from System import Array
customBars = api.TimeFrameManager.Custom.Add("My Custom TF").AddBars(api.Symbols.GetSymbol("EURUSD"))
sourceBars = api.MarketData.GetBars(TimeFrame.Hour, "EURUSD")
loadedCount = sourceBars.LoadMoreHistory()
olderBars = [CustomBar(sourceBars[i].OpenTime, sourceBars[i].Open, sourceBars[i].High, sourceBars[i].Low, sourceBars[i].Close, int(sourceBars[i].TickVolume)) for i in range(loadedCount)]
customBars.PrependBars(Array[CustomBar](olderBars))