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

Horizontal line draw error

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

    Horizontal line draw error

    Hello,

    I'm trying to code an indicator to draw an unlocked horizontal line on the chart which the user can then move around while the indicator still knows what price the line is at currently.

    Using these globals:
    private double LinePrice = 0;
    IHorizontalLine Line = null;

    And here in OnBarUpdate:
    if (Line == null)
    {
    Line = DrawHorizontalLine("Line1", true, Close[1], Color.White, DashStyle.Dash, 1);
    Line.Locked = false;
    }

    LinePrice = Line.Y;

    This code is working fine for my purpose, except that the line does NOT initially draw at Close[1]. Instead it draws at some random location on the chart, which is sometimes very far away from price. How can I get the line to draw at Close[1] and stay there till I move it?

    Thanks!
    Last edited by entropy; 09-24-2015, 12:44 PM.

    #2
    Hello entropy,

    Thank you for your post.

    The snippet of code you provided should produce your desired results. Can you attach the full script or a test version that produces the same result?

    Comment


      #3
      Thanks for confirming! I'll have to dig up the answer in the rest of the code.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Kaledus, Today, 01:29 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by frankthearm, Yesterday, 09:08 AM
      13 responses
      45 views
      0 likes
      Last Post frankthearm  
      Started by PaulMohn, Today, 12:36 PM
      2 responses
      16 views
      0 likes
      Last Post PaulMohn  
      Started by Conceptzx, 10-11-2022, 06:38 AM
      2 responses
      55 views
      0 likes
      Last Post PhillT
      by PhillT
       
      Started by yertle, Yesterday, 08:38 AM
      8 responses
      37 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Working...
      X