CustomBar constructor
constructor · CustomBar · cAlgo.API Since 5.3
DesktopCLICloud
Creates a new custom bar.
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 CustomBar(DateTime time, double open, double high, double low, double close, long volume)
CustomBar(time: DateTime, open: float, high: float, low: float, close: float, volume: int)
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
time | DateTime | DateTime | Open time |
open | double | float | Open price |
high | double | float | High price |
low | double | float | Low price |
close | double | float | Close price |
volume | long | int | Volume amount |
Examples
var lastBar = MarketData.GetBars(TimeFrame.Hour, "EURUSD").LastBar;
var customBar = new CustomBar(lastBar.OpenTime, lastBar.Open, lastBar.High, lastBar.Low, lastBar.Close, (long)lastBar.TickVolume);
Print("Custom bar created at {0}", customBar.Time);
lastBar = api.MarketData.GetBars(TimeFrame.Hour, "EURUSD").LastBar
customBar = CustomBar(lastBar.OpenTime, lastBar.Open, lastBar.High, lastBar.Low, lastBar.Close, int(lastBar.TickVolume))
api.Print(f"Custom bar created at {customBar.Time}")