Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing IsVisible on Indicator in code doesn't hide draw objects.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by ntbone View Post
    The code to hide the drawing objects is very straight forward and won't fix your problem unless you are using the drawing objects. If you are calling AddPlot to render your visuals then the code that I have won't help you.

    Code:
    private void ShowIndicator(bool isVisible)
    {
    foreach(var chartObject in chartWindow.ActiveChartControl.ChartObjects)
    {
    var indicator = chartObject as Indicator;
    if(indicator != null && indicator.DrawOnPricePanel)
    {
    indicator.IsVisible = isVisible;
    ToggleIndicatorDrawingObjectVisibilty(indicator, isVisible);
    }
    }
    
    // forces the chart to redraw.
    chartWindow.ActiveChartControl.InvalidateVisual();
    }
    
    private void ToggleIndicatorDrawingObjectVisibilty(Indicator indicator, bool isVisible)
    {
    foreach(var obj in indicator.DrawObjects)
    {
    if(obj.DrawnBy == indicator)
    {
    obj.IsVisible = isVisible;
    }
    }
    }
    When added to my indie there is an error on two lines 'The name 'chartWindow' does not exist in the current context.' are there missing starements or lines to specify when it is called or to what method these functions will be called to.

    Comment


      #17
      chartWindow is of type Chart and was a member variable of the class the code was copied from. I had downloaded ABtoolBar from here https://ninjatraderecosystem.com/use...ers-and-wicks/ and modified it as the code in there to hide indicators wasn't hiding their drawing objects, just their plots. The Chart object for an indicator can be obtained via OwnerChart property.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      57 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      78 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      39 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      101 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      61 views
      0 likes
      Last Post PaulMohn  
      Working...
      X