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 kaywai, 09-01-2023, 08:44 PM
      5 responses
      601 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      22 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      19 views
      0 likes
      Last Post Pattontje  
      Started by flybuzz, 04-21-2024, 04:07 PM
      17 responses
      230 views
      0 likes
      Last Post TradingLoss  
      Started by agclub, 04-21-2024, 08:57 PM
      3 responses
      17 views
      0 likes
      Last Post TradingLoss  
      Working...
      X