Hi everyone,
I've created this simple indicator and when I add it to a chart, it works fine. However, I encounter an issue when I try to modify its style, such as changing the color or thickness. Every time I attempt to make these adjustments, the entire chart disappears, as shown in the attached image. Has anyone else experienced this? Any suggestions on how to fix it would be greatly appreciated.
Thanks in advance!
I've created this simple indicator and when I add it to a chart, it works fine. However, I encounter an issue when I try to modify its style, such as changing the color or thickness. Every time I attempt to make these adjustments, the entire chart disappears, as shown in the attached image. Has anyone else experienced this? Any suggestions on how to fix it would be greatly appreciated.
Thanks in advance!
CODE:
using System.Diagnostics; using WealthLab.Core; using WealthLab.Indicators; namespace WLLibrary2; public class Close : IndicatorBase { public override string Name => "Close"; public override string Abbreviation => "Close"; public override string HelpDescription => "Draw a line at the close of each bar."; public override string PaneTag => "Price"; public override bool IsSmoother => false; protected override void GenerateParameters() { AddParameter("Source", ParameterType.BarHistory, null); } public Close() : base() { } public Close(BarHistory source) : base() { Parameters[0].Value = source; Populate(); } public static Close Series(BarHistory source) { var key = CacheKey(nameof(Close)); if (source.Cache.ContainsKey(key)) { return (Close)source.Cache[key]; } var close = new Close(source); source.Cache[key] = close; return close; } public override void Populate() { var source = Parameters[0].AsBarHistory; DateTimes = source.DateTimes; Values = source.Close.Values; } }
Rename
Instead of assigning Values the exact instance of the BarHistory Close, you should instead populate the indicator's Values with the same values as the Close TimeSeries. We have a shortcut method, AssumeValuesOf, to make this easier.
Instead of
Values = source.Close.Values;
use
AssumeValuesOf(source.Close);
Instead of
Values = source.Close.Values;
use
AssumeValuesOf(source.Close);
Thank you so much for your explanation. It's now clear to me that the issue was related to passing by reference 🙏
Your Response
Post
Edit Post
Login is required