Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Button Click to Hide Objects or return

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

    Button Click to Hide Objects or return

    Hello All,

    I'm trying to create a button for my indicator to allow for easy cycling of showing the indicator. The indicator draws lines and text at specific DateTime's. I want to just click a button and remove all objects, than upon clicking again, to show all objects.

    I have tried using a bool cycle in the button click function, than checking that bool in OnBarUpdate to return; if true. This does not work.

    Is there any method that can accomplish this? I have searched the forum and just am not finding what I need.
    Last edited by ChrisR; 12-04-2024, 08:32 AM.

    #2
    Hello ChrisR,

    From the button click even handler method, you would need to call TriggerCustomEvent() then for each drawing object set the .IsVisible property.
    You could loop through the drawing objects either in your custom collection or the DrawObjects collection.
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello ChrisR,

      From the button click even handler method, you would need to call TriggerCustomEvent() then for each drawing object set the .IsVisible property.
      You could loop through the drawing objects either in your custom collection or the DrawObjects collection.
      Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

      Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
      Thanks, Chelsea.

      The following is working, but removing objects from other indicators with similar content in the tag. How can I check if the object owner is the current indicator (this)?

      foreach (var drawObject in chartWindow.ActiveChartControl.ChartObjects)
      {
      if (drawObject is DrawingTool drawingTool && drawingTool.Tag.Contains("Open"))
      {
      drawObject.IsVisible = HideScript;
      }
      }​

      Comment


        #4
        Hello ChrisR,

        You could add the objects to your own collection and loop over that collection instead.

        Or you could check drawObject.DrawnBy == this.
        Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks again!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          556 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X