Skip to content

CustomTimeFrame.NewChart

event · CustomTimeFrame · cAlgo.API Since 5.3

DesktopCLICloud

Occurs when user opens a new chart of current custom time frame.

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

event Action<CustomTimeFrameNewChartEventArgs> NewChart;
customTimeFrame.NewChart += handler  # handler(obj: CustomTimeFrameNewChartEventArgs)

Examples

protected override void OnStart()
{
    var customTimeFrame = TimeFrameManager.Custom.Add("My Custom TF");
    customTimeFrame.NewChart += OnCustomTimeFrameNewChart;
}

private void OnCustomTimeFrameNewChart(CustomTimeFrameNewChartEventArgs args)
{
    Print("New {0} chart opened for {1}", args.CustomTimeFrame.Name, args.CustomBars.Symbol.Name);
}
def on_start(self):
    customTimeFrame = api.TimeFrameManager.Custom.Add("My Custom TF")
    customTimeFrame.NewChart += self.on_custom_time_frame_new_chart

def on_custom_time_frame_new_chart(self, args):
    api.Print(f"New {args.CustomTimeFrame.Name} chart opened for {args.CustomBars.Symbol.Name}")