CustomBars
interface cAlgo.API Since 5.3
DesktopCLICloud
Represents a mutable collection of OHLC bars that will be used for a custom time frame / 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
public interface CustomBars
Namespace: cAlgo.API · Group: Custom
Examples
var customBars = TimeFrameManager.Custom.Add("My Custom TF").AddBars(Symbols.GetSymbol("EURUSD"));
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)));
Print("{0} custom bars for {1}, last close {2}", customBars.Bars.Count, customBars.Symbol.Name, customBars.Bars.LastBar.Close);
customBars = api.TimeFrameManager.Custom.Add("My Custom TF").AddBars(api.Symbols.GetSymbol("EURUSD"))
sourceBars = api.MarketData.GetBars(TimeFrame.Hour, "EURUSD")
for bar in sourceBars:
customBars.AppendBar(CustomBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, int(bar.TickVolume)))
api.Print(f"{customBars.Bars.Count} custom bars for {customBars.Symbol.Name}, last close {customBars.Bars.LastBar.Close}")
Methods
| Name | Description |
|---|---|
AppendBarDesktopCLICloudvoid | Appends a new bar to the end of bars collection. |
AppendBarsDesktopCLICloudvoid | Appends a collection of bars to the end of bars collection. |
PrependBarDesktopCLICloudvoid | Prepends a new bar to the start of bars collection. |
PrependBarsDesktopCLICloudvoid | Prepends a collection of bars to the start of bars collection. |
UpdateLastBarDesktopCLICloudvoid | Updates the last bar. |
Properties
| Name | Description |
|---|---|
BarsDesktopCLICloudBars | Gets readonly bars. |
IsLoadedDesktopCLICloudbool | Gets IsLoaded status, If true it means custom bars is being used and can't be removed. |
SymbolDesktopCLICloudSymbol | Gets symbol of custom bars. |
TimeFrameDesktopCLICloudTimeFrame | Gets timeframe of custom bars. |
Events
| Name | Description |
|---|---|
NeedsMoreDesktopCLICloudAction<CustomBarsNeedsMoreEventArgs> | Occurs when user scrolls back on a custom bars chart. |