Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Updating a Line

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

    Updating a Line

    Hello,

    I would like to know if its possible how to update a line that has been drawn on screen.

    e.g. Draw.Line(this, "FirstUpLine", false, 5, Low[5], 1, High[1], Brushes.DodgerBlue, DashStyleHelper.Solid, 4);

    When certain conditions are met, this line is drawn as seen in the attached photo. What I would like to do is when a Higher High appears, I want the end anchor point to keep moving to the next high Which is Bar 7, then finally will end up into Bar 8.
    Attached Files

    #2
    Hello Don, thanks for writing in. You can save your Line object as a class member and change its Start and End Anchor points at a later time e.g.

    Code:
            bool drawonce = false;
            NinjaTrader.NinjaScript.DrawingTools.Line myLine;
            protected override void OnBarUpdate()
            {
                if(State != State.Realtime)
                    return;
    
                if(!drawonce)
                {
                    myLine = Draw.Line(this, "tag1", 0, High[0], 10, High[10], Brushes.Red);
                    drawonce = true;
                }
                else
                {
                    myLine.StartAnchor.Price = High[0];
                    myLine.StartAnchor.SlotIndex = CurrentBar;
                }
    
            }​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    35 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    12 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    18 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X