Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

changing the line length dynamically from indicator

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

    changing the line length dynamically from indicator

    Hi, I am using below code to increase the length of existing line drawing object . But it is not working consistently. It is working all the times. Is it the right approach to increase the length of line ?

    aLine.Anchors.ElementAt(1).BarsAgo=aLine.Anchors.E lementAt(1).BarsAgo - 1;

    #2
    Hi, thanks for posting.

    Instead of using BarsAgo use DrawnOnBar to get the bar index of the draw object. BarsAgo gives the initial bars ago value when the draw object constructor was called.

    Kind regards,
    -ChrisL

    Comment


      #3
      HI Chris, I am using BarsAgo to get the bar index. aLine.Anchors.E lementAt(1).BarsAgo is representing the end X value of Line Object.

      I will put my question in different way. I have drawn a Line object using aLine = Draw.Line() . How to change the aLine length (start X and end X) values ?

      Comment


        #4
        Hi, thanks for your reply.

        The most straight forward way to change an existing draw object is to call Draw.Line() again with the same tag and different bar placement parameters. The Anchor collection is Read-Only so it should only be used to reference the location of previously drawn chart objects in new calls to Draw.<draingtool>().

        Kind regards,
        -ChrisL

        Comment


          #5
          I have two questions on that approach.

          1. I want to update the line length after every bar close . There will be 30 to 50 lines needs to re-drawn. Will that not cause performance issue ?
          2. If I am going with the approach you are suggesting, how to get the old values to re-create the line object . I am storing the Line object in memory. Below is the way i create Line object.

          aLine = Draw.Line(this, "myTag"+CurrentBar, isAutoAcale, lineX, price, -5, price, LineProp.Brush, LineProp.DashStyleHelper, (int)LineProp.Width);

          Comment


            #6
            Hi, thanks for your reply.

            1. Any large amount of draw objects will cause performance problems if the hardware is not fast enough. If you do run into performane problems in the script we reccomend using SharpDX in the OnRender method to draw high performance graphics.


            2. You are already doing this with your first post: aLine.Anchors all information on the previously drawn draw object is held in the variable aLine, so you can use the data from this to re-draw the lines. The only thing you would want to change is the second paremeter: "myTag"+CurrentBar this will generate a unique tag for every bar, so this would need to be changed to overwrite existing lines.

            Kind regards,
            -ChrisL


            Comment

            Latest Posts

            Collapse

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