- ago
Hello WealthLab team,

I am trying to create a custom indicator for use as an IndicatorNeuronSource in NeuroLab (WL8 latest build).
I noticed a problem: NeuroLab never calls the constructor that accepts BarHistory. Instead, it always instantiates the indicator with the parameterless constructor. As a result, Bars is always null inside Populate().

To diagnose, I built a minimal indicator (NeuroCtorProbe), which logs constructor calls and whether Bars is available.
CODE:
using System; using System.IO; using WealthLab.Core; namespace WealthLab.Indicators { public class NeuroCtorProbe : IndicatorBase { private static readonly string LogFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "WL_ctor_probe.txt"); private static void L(string s) => File.AppendAllText(LogFile, $"{DateTime.Now:HH:mm:ss.fff} | neuroprobe: {s}{Environment.NewLine}"); public NeuroCtorProbe() : base() { L("ctor() parameterless"); } public NeuroCtorProbe(BarHistory source) : this() { Bars = source; L($"ctor(BarHistory) sym='{source?.Symbol}' cnt={(source==null?0:source.Count)}"); } protected override void GenerateParameters() { AddParameter("dummy", ParameterType.Int32, 0); } public override void Populate() { Clear(); if (Bars == null || Bars.Count < 2) { this[0] = 0.0; L("Populate(): Bars=NULL (dummy value written)"); return; } for (int i = 0; i < Bars.Count; i++) this[i] = 0.0; L($"Populate(): Bars ok ({Bars.Symbol}) cnt={Bars.Count}"); } public override string Name => "NeuroCtorProbe"; public override string Abbreviation => "neuroprobe"; public override string HelpDescription => "Diagnostic indicator to test NeuroLab ctor binding."; public override string PaneTag => "probe"; } }

When I add this indicator as an output block in NeuroLab, the log file shows only ctor() parameterless calls, followed by Populate(): Bars=NULL ….
The ctor(BarHistory …) constructor is never used, so Bars is always null. This results in empty series being passed to NeuroLab, which later causes runtime errors (Sequence contains no elements in ucNeuronContainer.UpdateStats()).

Questions:

Is this the intended behavior — that NeuroLab only passes a TimeSeries and not a BarHistory?

If yes, what is the correct constructor signature for a custom NeuroLab indicator that needs access to Bars (symbol, OHLCV data)?

If this is a bug, could you please confirm and advise a workaround until fixed?
0
170
3 Replies

Reply

Bookmark

Sort
Glitch8
 ( 8.86% )
- ago
#1
It's not a bug. Just because it's calling the parameterless constructor does not mean that the BarHistory is not eventually assigned and it is there by the time Populate is called. NeuroLab is just using a different flow of methods rather than calling the constructor with parameters.
0
- ago
#2
Is there additional documentation beside the 3 examples on how to build a new custom indicator (for an output neuron)?
0
Glitch8
 ( 8.86% )
- ago
#3
The documentation is here, this page directs you to the IndicatorBase class reference on wl.com for more detailed info.

0

Reply

Bookmark

Sort