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 cmoran13, Yesterday, 01:02 PM
    0 responses
    23 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    16 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    94 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    147 views
    2 likes
    Last Post CaptainJack  
    Working...
    X