Announcement

Collapse
No announcement yet.

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:	40
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 NeverDownMoney, Today, 02:42 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by localappleseed, Today, 02:20 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by asmmbillah, Today, 02:48 PM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by KacemRhaz, Today, 01:31 PM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChristopherD  
      Started by ronaldgreene828, Today, 12:08 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Kate  
      Working...
      X