Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing a horizontal line from an unlocked vertical line

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

    Drawing a horizontal line from an unlocked vertical line

    I would like a horizontal line to be drawn automatically starting from an unlocked vertical line. The horizontal line should be drawn at, for example, the high of the candle where the vertical line is drawn on.

    The unlocked vertical line can be moved by the user. The horizontal line should be refreshed as soon as the vertical line moves from one bar to another.

    The only thing I have been able to find is how to unlock a vertical line:

    //draw Vertical Line
    IVerticalLine VLine = DrawVerticalLine("tag1", 0, ColorOfTheVLine, DashStyle.Solid, 2);

    // Unlock Line
    foreach (IDrawObject draw in DrawObjects)
    {
    if (draw.DrawType == DrawType.VerticalLine)
    draw.Locked = false;
    }


    Thanks for your help

    #2
    Hello sixteencorners,

    Thanks for your plot.

    Here is an example of drawing a vertical line, obtaining the high of the bar that the line is on and drawing a line with those characteristics.

    Code:
    			if (CurrentBar < Bars.Count-2)
    				return;
    
                             if (VLine == null)
    			{
    				VLine = DrawVerticalLine("vline", 20, Color.Blue, DashStyle.Solid, 5);
    			}
    			foreach (IDrawObject draw in DrawObjects)
    			{
    				if (draw.DrawType == DrawType.VerticalLine)
    					draw.Locked = false;
    			}
    			if (VLine != null)
    			{
    				DrawLine("hline", VLine.BarsAgo, High[VLine.BarsAgo], 0, High[VLine.BarsAgo], Color.Blue);
    		}
    If you set your code CalculateOnBarClose = false;, the indicator will update on each tick and move the horizontal line when you move the vertical line.

    References:
    http://ninjatrader.com/support/helpG...rawobjects.htm
    http://ninjatrader.com/support/helpG...rticalline.htm

    Comment


      #3
      Hello sixteencorners,

      Thanks for your reply.

      Please note that for the example provided you would need to declare: private IVerticalLine VLine; in the region variables.

      Comment


        #4
        Thank you Paul.
        Actually, is there a way for the horizontal bar to be updated as soon as the user displace the vertical line? When the market is slow for example, it can take a while for the update.

        Thanks again

        Comment


          #5
          Hello sixteencorners,

          Thanks for your post.

          You might try using the plot override. I'm not sure if that will get what you want. The override is not documented so I cannot provide any helpguide references. You can see an example of the capabilities by looking at the following indicators:

          CustomPlotSample.CS - contains the best documentation we have
          Pivots.CS
          VolumeProfile.CS

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          589 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          342 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
          555 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