Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I limit the length of an horizontal line?

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

    How do I limit the length of an horizontal line?

    The code below draws the horizontal line across the entire chart. However, i would like to limit the length to the last 20bars. Is there a way to do this.

    if (UseExtendedLine)
    {
    // Draw.HorizontalLine(this, "Currprice", false, SLTPLineC, LineColor, LineStyle, LineWidth);
    Draw.HorizontalLine(this, "Currprice1", false, Close[0]+SLTPLine1, LineColor1, LineStyle1, LineWidth1);
    Draw.HorizontalLine(this, "Currprice2", false, Close[0]-SLTPLine1, LineColor1, LineStyle1, LineWidth1);
    Draw.HorizontalLine(this, "Currprice3", false, Close[0]+SLTPLine2, LineColor2, LineStyle2, LineWidth2);
    Draw.HorizontalLine(this, "Currprice4", false, Close[0]-SLTPLine2, LineColor2, LineStyle2, LineWidth2);
    Draw.HorizontalLine(this, "Currprice5", false, Close[0]+SLTPLine3, LineColor3, LineStyle3, LineWidth3);
    Draw.HorizontalLine(this, "Currprice6", false, Close[0]-SLTPLine3, LineColor3, LineStyle3, LineWidth3);

    }

    I tried using the draw.line code below, but it wasn't drawing the line on the chart.

    Draw.Line(this, "CurrPrice7", false, 20, Close[0]+SLTPLine1, 0, Close[0]+SLTPLine1, LineColor1, LineStyle1, LineWidth1)

    What am I doing wrong?

    #2
    Hello cryfgg,

    Thanks for your post.

    Draw.HorizontalLine does not allow you to specify the number of bars back that you would like the line to start.

    Instead, Draw.Line would need to be used if you want to specify the number of bars back that the line starts.

    See the attached example script which demonstrates using Draw.Line to draw a line starting 20 bars ago.

    Also, see this help guide page for more information: https://ninjatrader.com/support/help.../draw_line.htm

    Let us know if we may further assist.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    637 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X