Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Are draw object Labels specific to the indicator instance or global Ninja?

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

    Are draw object Labels specific to the indicator instance or global Ninja?

    Are draw object Labels specific to the indicator instance that drew them or global for the entire Ninja run time?

    #2
    Hello llanqui,

    Thanks for your post.

    ​A drawing objects tag can be accessed from any indicator or strategy by looping through the DrawObjects collection.

    See the sample code on this help guide page for more information: https://ninjatrader.com/support/help...ub=DrawObjects
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Ok, then ..... to be more specific.....if I (Ninjascript) draws a horizontal line Label called NQ-01 on Chart 1

      and another indicator on another chart draws a horizontal line with the same Label.....

      what happens in the Drawing Tool

      does it only draw one of them on one of the charts (i.e. overlay the first drawn)?

      Comment


        #4
        sorry, by "Label" I mean "TAG:"

        Comment


          #5
          Hello llanqui,

          Thanks for your notes.

          ​I have tested this on my end by creating an indicator that draws a horizontal line on the chart with the Tag name "tag1" and a Brush color DodgerBlue.

          In a second indicator, I looped through the DrawObjects collection to get the Tag of the horizontal line drawn by the first indicator and assigned that Tag name to a variable that returns the string "tag1". Then, I called Draw.HorizontalLine() and used the variable for the 'Tag' parameter of the method and used a different Brush color of Lime to tell the lines apart.

          The result is that the first indicator will draw a line with Tag name "tag1" and the second indicator will also draw a horizontal line with the name "tag1". Since the Tag name is being used by different indicators, the line drawn by the first indicator is not modified by the second indicator and a second line is drawn instead.

          I attached the indicators used to test this for you to view.​
          Attached Files
          Last edited by NinjaTrader_BrandonH; 06-08-2023, 11:54 AM.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Thank you :-)

            Comment


              #7
              Hi Bandon,

              My indicator draws a horizontal line with the tag "My_Line" using this syntax:
              PHP Code:
              Draw.HorizontalLine(this, "My_Line", double y, bool isGlobal, string templateName) 
              

              The other part of the indicator can detect this line and derive its price based on its tag name:
              PHP Code:
                                  foreach (DrawingTool draw in DrawObjects.ToList())
                                  {
              
                                      // Non GLobal Line
                                      if (draw is DrawingTools.HorizontalLine
                                              && (!draw.IsUserDrawn)    
                                              && draw.Tag == "My_Line"
                                          )
                                              
                                          {
                                              DrawingTools.HorizontalLine HL    = draw as DrawingTools.HorizontalLine;
                                              HLValue                           = HL.StartAnchor.Price;                                
                                          }  
              
              
                                      // GLobal Line
                                      else if (draw is DrawingTools.HorizontalLine
                                          && (!draw.IsUserDrawn)
                                          && (draw.IsGlobalDrawingTool)
                                          && draw.Tag == "My_Line"                            
                                          )
                                              
                                          {
                                              DrawingTools.HorizontalLine HL    = draw as DrawingTools.HorizontalLine;
                                              HLValue                           = HL.StartAnchor.Price;                                
                                          }
              &#8203;                          
              
                                  }      &#8203; 
              

              When the drawn line is a local line, it can be detected with no problem. However, when the line is a global line, draw.Tag == "My_Line doesn't work. Is there a way to identify the tag of a global horizontal line?

              Comment


                #8
                Hello Rainmakersg,

                When an object is made global, typically the @ symbol is added to the start of the tag string.

                Try printing the tags of all objects to see if these have changed.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks so much Chelsea

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  557 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