Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing Rays connecting Pivot Highs

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

    Drawing Rays connecting Pivot Highs

    Hi,

    I’m planning to code a downward sloping ray which connects pivot highs together, as long as a previous pivot high is higher than the latest previous high.

    Definition of Pivot High: High[0] < High[1] && High[2] < High[1]

    The question I have is what would be the best way to store the pivot high values?

    Back in NT7, I tried using the DataSeries and there were many zero values in the DataSeries because not every high is a pivot high.

    Could you please put me on the right track?

    Regards
    Kay Wai


    #2
    Hello kaywai,

    Thanks for your post.

    If you need the current Pivot High value and the previous Pivot High value, you could consider using two double variables, one variable to hold the current Pivot High value and the second variable to hold the previous Pivot High value.

    These two variables could then be compared in a condition in your script if needed.

    Please let us know if we may assist further.
    <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


      #3
      Hi BrandonH,

      I will be needing more than 2 values as there are some pivot high values which are 50 datapoints apart that may need to be connected because nothing in between meets the criteria for the ray to be drawn.

      So to connect to a previous pivot high with is higher than the current pivot high, the code will need to do a lookback to find a higher pivot high.

      I've attached a sample of what I'm trying to achieve. The squares are the pivot highs.

      Regards
      Kay Wai
      Attached Files
      Last edited by kaywai; 05-11-2022, 02:04 PM. Reason: added a sample chart

      Comment


        #4
        Hello kaywai,

        Thanks for your note.

        The Pivots indication repeats the values until new values are found.

        If you wanted a set number of pivots such as the current pivot and the last pivot, you could use two double variables and shift the value from the current pivot to the last pivot when you find a new current pivot.

        Otherwise, you could plot the Pivot and use loops to find the instances of swings. You could view the code for the Swing indicator that comes default with NinjaTrader for an example of using custom methods with loops to find instances of swings. To view the code of the Swing indicator, open a New > NinjaScript Editor window, open the Indicators folder, and double click on the Swing indicator.

        Let us know if we may assist further.
        <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


          #5
          Hi BrandonH,

          Thank you for that.

          What I can't figure out or reconcile is how I am able to draw the rays if I am unable to store the values. I have been able to identify pivot highs using a loop but am struggling with joining the highs together when a previous pivot high is greater than the current pivot high.

          The swing indicator identifies pivot highs but it doesn't connect between pivot highs.

          Regards
          Kay Wai

          Comment


            #6
            Hello kaywai,

            Thanks for your note.

            "...if I am unable to store the values."

            See post #4 which contains two different ways you could store values to be used in your script. I have reposted these ways below as well.

            If you wanted a set number of pivots such as the current pivot and the last pivot, you could use two double variables and shift the value from the current pivot to the last pivot when you find a new current pivot.

            Otherwise, you could plot the Pivot and use loops to find the instances of swings. You could view the code for the Swing indicator that comes default with NinjaTrader for an example of using custom methods with loops to find instances of swings. To view the code of the Swing indicator, open a New > NinjaScript Editor window, open the Indicators folder, and double click on the Swing indicator.

            "I have been able to identify pivot highs using a loop.."

            This would be a possible third option for storing values. You would loop over all the data and then make your condition.

            Note that regardless of the way you choose, you would need to plot the values you find. You could choose to make the plot a constant value, then use your logic to update the plot to new values when new pivots are found. Or, you could store 1 value on certain bars when the condition is true and then later use a loop to locate those instances.

            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. If you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request, please contact vendorsupport[AT]ninjatrader.com.

            Let us know if we may assist further.
            <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
            571 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X