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

How to calculate the distance in bars between the knees zigzag

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

    How to calculate the distance in bars between the knees zigzag

    Hello !
    How to calculate the distance in bars between the knees zigzag?
    Please can be an example of how the distances in bars are calculated
    Thank!

    #2
    Hello oscsoft,

    Thanks for your post.

    The help guide section on the ZigZag indicator provides methods to find the High bar, Low bar, the value of the high bar, and the value of the low bar. Please see: https://ninjatrader.com/support/help...us/?zigzag.htm

    To find the bars difference between any two swing points you would subtract the bars ago value of the two swings of interest. The key for you will be to determine which swing point is of interest.

    I've created a short example that will print to the output window, the bars ago value for the last two swing points. This should give you enough to get starting in coding what you need for your specific situation. Please note that we do not provide coding services so this example is just to get you started. I've included a screenshot of the ninjascript output showing the last values from the current bar and then notated on the chart the location of the current bar (based on calculate.OnbarClose) and the location of the last two high bars as defined in the output data. The last two swing points are 8 bars ago and 14 bars ago so the difference is 14-8 = 6 bars between swings.


    Click image for larger version

Name:	oscsoft-1.PNG
Views:	236
Size:	220.2 KB
ID:	1040553 ​​​​​​​ ​​​​​​​

    [ATTACH]n1040554[/ATTACH]
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much! That's what I need!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,228 views
      0 likes
      Last Post xiinteractive  
      Started by andrewtrades, Today, 04:57 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      7 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      440 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      12 views
      0 likes
      Last Post FAQtrader  
      Working...
      X