private void ToggleIndicatorVisibility() { var indicator = ChartControl.Indicators.FirstOrDefault(indi => indi.Name == "MyCustomIndicator"); if (indicator != null) { indicator.IsVisible = !indicator.IsVisible; // Toggle visibility } ForceRefresh(); }
I've able to turn on and off any indicator I want, but changing the name "MyCustomIndicator" There's only one catch.
I can not remove the label.
If I want the annoying top left corner text to disappear and I go into the indicator's properties here:
If I remove the Label,
then the above code won't be able to turn off and on the Indicator's visibility anymore.
All of this to ask, is there an alternative for this line:
var indicator = ChartControl.Indicators.FirstOrDefault(indi => indi.Name == "MyCustomIndicator");
I also tried using:
private void ToggleIndicatorVisibility() { if (myObj != null && myObj.Name == "MyCustomIndicator") { myObj.IsVisible = !myObj.IsVisible; // Toggle visibility Print(myObj.IsVisible ? "Show Indicator" : "Hide Indicator"); } ForceRefresh(); }
based on other discussion here in the forum, but I keep getting unhandled error exception.
Comment