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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    68 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    150 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X