Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Update Line Property Like endBarsAgo , brush ?

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

    How to Update Line Property Like endBarsAgo , brush ?

    From my Indicator , i am drawing Line using below code. From my indicator, I need to update the color and length of Line on some condition. Kindly share your input.

    Draw.Line(this, "LineRGT"+CurrentBar, true, 1, Open[1], -10, Open[1], Brushes.Pink, DashStyleHelper.Dot, 2);

    #2
    Hello nandhumca,

    Thanks for your first post and welcome to the NinjaTrader forums!

    In order to update the line, you will need to save or recreate the "tag name" and then use the Draw.Line() method with the new parameters and the same tag name.

    For example:

    if (conditions to draw the line)
    {
    Draw.Line(this, "LineRGT"+CurrentBar, true, 1, Open[1], -10, Open[1], Brushes.Pink, DashStyleHelper.Dot, 2);
    myTagname = "LineRGT"+CurrentBar;
    }

    if (conditions to update that specific line)
    {
    Draw.Line(this, "LineRGT"+CurrentBar, true, 20, Open[1], 1, Open[1], Brushes.Magenta, DashStyleHelper.Dot, 2);
    }




    Comment


      #3
      In my use case, i want to get the value of x, y to redraw. How to get the property values using tagname ?

      Comment


        #4
        Hello nandhumca,

        Thanks for your reply.

        I will create a short example but it will not be until tomorrow.

        Thanks in advance for your patience.

        Comment


          #5
          Hello nandhumca,

          Thanks for your patience.

          I've attached a working example of creating a line and then printing the properties of that line. Please apply this to a fast chart such as 10-second bars with real time data. On the chart, as soon as the first bar closes you will see the line drawn and in the Ninjascript output window, you will see the values of the (X, Y) anchors.


          DrawLineCheck.zip


          Comment


            #6
            Thanks. This is what i am looking for.

            Comment


              #7
              Hi Paul, I have follow up question on the same. If i remove the line from chart manually, i want to capture that event in my indicator ? How to listen for that event in my indicator ?

              Comment


                #8
                Hello nandhumca,

                Thanks for your additional question.

                Removing a drawing object created by the indicator will cause the indicator to also be removed.

                Comment


                  #9
                  Hi Paul,

                  After setting AllowRemovalOfDrawObjects as true, i can able to remove the line drawn by indicator without removing indicator from chart. Now I want to know that will there be any event triggrered for removal and will that be captured in indicator ?

                  Comment


                    #10
                    Hello nandhumca,

                    Thanks for your reply.

                    Nice catch!

                    You could observe that the chart objects collection list has changed.

                    Here is a link to an example script in post #9 that I tested with the script I previously provided and adding AllowRemovalOfDrawObjects=true;

                    Comment


                      #11
                      Thanks once again. I will explore and get back if I stuck somewhere

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      580 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      336 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      554 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      552 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X