Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

lightning until the first touch

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

    lightning until the first touch

    You can have a line drawn along the chart until it touches the next candle that reaches your price.

    #2
    Hello franatas,

    Thank you for your post.

    It appears you have made a statement about drawing a line. Do you have a question about drawing a line that remains on the chart until a certain price is reached? If so, please provide more details and let us know what you might have questions about so we may understand your inquiry and assist you accurately.

    Thank you for using NinjaTrader.

    Comment


      #3
      Yes, I want that line to graph until a subsequent candle touches the price of the line, so that that is the end point

      Comment


        #4
        Hello franatas,

        Thank you for your reply.

        You could use the Draw.Line() method which allows you to set the startBarsAgo and endBarsAgo values. What you would do is save the bar that you want the line to start on into a variable in order to calculate your startBarsAgo, and you would update the endBarsAgo to a variable that holds the bar where the candle touches the desired price. For example, here is a pseudo-code snippet that demonstrates this idea:

        Code:
        private int startBarIndex, endBarIndex, lineStartBarsAgo, lineEndBarsAgo;
        private bool priceTouched;
        
        if ( // condition that triggers the line to start)
        {
        startBarIndex = CurentBar;
        }
        // if price is not touched yet, update endBarIndex to CurrentBar
        if (priceTouched == false)
        endBarIndex = CurrentBar;
        // check if the price has been touched. If so, save the CurrentBar index to endBarIndex and toggle the bool to true so endBarIndex is no longer updated
        if (priceTouched == false && Close[0] // == or >= or <= comparison to desired target price to touch)
        {
        endBarIndex = CurrentBar;
        priceTouched = true;
        }
        lineStartBarsAgo = CurrentBar - startBarIndex;
        lineEndBarsAgo = CurrentBar - endBarIndex;
        // using the following syntax, we will draw the line Draw.Line(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush)
        // use whichever startPrice, endPrice, and brush that you'd like, this is just an example
        Draw.Line(this, "myLine", lineStartBarsAgo, startPrice, lineEndBarsAgo, endPrice, Brushes.Blue);
        Please let us know if we may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        598 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 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
        557 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X