Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Paul H.NinjaTrader Customer Service

    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.
      Paul H.NinjaTrader Customer Service

      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
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kempotrader, Today, 08:56 AM
          0 responses
          6 views
          0 likes
          Last Post kempotrader  
          Started by kempotrader, Today, 08:54 AM
          0 responses
          4 views
          0 likes
          Last Post kempotrader  
          Started by mmenigma, Today, 08:54 AM
          0 responses
          2 views
          0 likes
          Last Post mmenigma  
          Started by halgo_boulder, Today, 08:44 AM
          0 responses
          1 view
          0 likes
          Last Post halgo_boulder  
          Started by drewski1980, Today, 08:24 AM
          0 responses
          3 views
          0 likes
          Last Post drewski1980  
          Working...
          X