• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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:	1
Size:	220.2 KB
ID:	1040553 ​​​​​​​ ​​​​​​​

    ZigZagExample.zip
    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 Johnny Santiago, Today, 04:50 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by rickyblah12, Yesterday, 08:17 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by jamarc, Today, 02:30 AM
      0 responses
      4 views
      0 likes
      Last Post jamarc
      by jamarc
       
      Started by mrlucky1x, Yesterday, 08:07 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by uday12, Yesterday, 07:21 PM
      0 responses
      5 views
      0 likes
      Last Post uday12
      by uday12
       
      Working...
      X