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

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.
    Emily C.NinjaTrader Customer Service

    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.
        Emily C.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        17 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        5 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,408 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Working...
        X