CustomTimeFrame.BarsUnloaded
event · CustomTimeFrame · cAlgo.API Since 5.3
DesktopCLICloud
Occurs when a custom bars is unloaded and not being used anymore.
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<CustomTimeFrameBarsUnloadedEventArgs> BarsUnloaded;
customTimeFrame.BarsUnloaded += handler # handler(obj: CustomTimeFrameBarsUnloadedEventArgs)
Examples
protected override void OnStart()
{
var customTimeFrame = TimeFrameManager.Custom.Add("My Custom TF");
customTimeFrame.BarsUnloaded += OnBarsUnloaded;
}
private void OnBarsUnloaded(CustomTimeFrameBarsUnloadedEventArgs args)
{
var isRemoved = args.CustomTimeFrame.RemoveBars(args.CustomBars.Symbol);
Print("Unloaded bars of {0} removed: {1}", args.CustomBars.Symbol.Name, isRemoved);
}
def on_start(self):
customTimeFrame = api.TimeFrameManager.Custom.Add("My Custom TF")
customTimeFrame.BarsUnloaded += self.on_bars_unloaded
def on_bars_unloaded(self, args):
isRemoved = args.CustomTimeFrame.RemoveBars(args.CustomBars.Symbol)
api.Print(f"Unloaded bars of {args.CustomBars.Symbol.Name} removed: {isRemoved}")