Multi Symbol OnBarOpened event
Created at 29 Oct 2023, 08:04
Multi Symbol OnBarOpened event
29 Oct 2023, 08:04
Hi,
I'm trying to code a custom OnBarsBarOpened() event for multi symbol bactesting as below.
encountered a "cannot implicitly convert type void to System.Action BarOpenedEventArgs" error at line bars.BarOpened += OnBarsBarOpened();
How can I fix this error and code this corectly?
protected override void OnStart()
{
// To learn more about cTrader Automate visit our Help Center:
// https://help.ctrader.com/ctrader-automate
//System.Diagnostics.Debugger.Launch();
foreach (Watchlist w in Watchlists)
if (w.Name == "Popular Markets")
TradeList = Symbols.GetSymbols(w.SymbolNames.ToArray());
foreach (Symbol s in TradeList)
{
var bars = MarketData.GetBars(TimeFrame, s.Name);
bars.BarOpened += OnBarsBarOpened();
}
}
void OnBarsBarOpened(BarOpenedEventArgs obj)
{
}
PanagiotisChar
30 Oct 2023, 06:47
Hi there,
Try changing
bars.BarOpened += OnBarsBarOpened();
to
bars.BarOpened += OnBarsBarOpened;
@PanagiotisChar