I've already tried repurposing the code from ABToolbars and read the discussion here:
https://forum.ninjatrader.com/forum/...ator-show-hide
I tried adding to public class:
private bool isDrawRectangleVisible = true; private Chart chartWindow; // Declare chartWindow at the class level
private void OnKeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.D && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
{
ToggleDrawsVisibility();
}
}
private void ToggleDrawsVisibility()
{
foreach (var obj in chartWindow.ActiveChartControl.ChartObjects)
{
var draw = obj as DrawingTool;
if (draw != null && draw.IsUserDrawn &&
(draw.Name.Contains("Top Cluster") || draw.Name.Contains("Bottom Cluster")))
{
draw.IsVisible = !draw.IsVisible; // Toggle visibility
}
}
chartWindow.ActiveChartControl.InvalidateVisual();
ForceRefresh();
}
Any advice would be much appreciated.

Comment