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

ZigZag Values

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

    ZigZag Values

    I am trying to get the last peak value and location(ie. number of bars ago)
    I tried the following code
    int barsago1 = ZigZag(Close,DeviationType.Percent,0.5,false).High Bar(0,1,100);
    int barsago2 = ZigZag(Close,DeviationType.Percent,0.5,false).High Bar(0,2,100);
    Print("Last Zig Zag Bar=" + barsago1 +"Bars Ago");
    Print("Previous Zig Zag Bar=" + barsago2 +"Bars Ago");
    Print("LastZZ High="+ High[Math.Max(0,ZigZag(DeviationType.Percent,0.5,false) .HighBar(0,1,100))]);
    Print("Previous ZZ High="+ High[Math.Max(0,ZigZag(DeviationType.Percent,0.5,false) .HighBar(0,2,100))]);
    Which generated the following output
    12/1/2008 3:47:21 PM
    Last Zig Zag Bar=-1Bars Ago
    Previous Zig Zag Bar=-1Bars Ago
    LastZZ High=8215
    Previous ZZ High=8215
    Which does not agree with the chart.....this is on the YM 12-08

    #2
    Your output is telling you it did not find a ZigZag high within that 100 bar lookback period you defined. You will need to increase your lookback period to encompass a ZigZag high.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I am looking at the chart and I see two peaks, one 9 bars ago and the second 14 bars ago.

      Comment


        #4
        Ensure you are actually comparing apples to apples. Make sure the indicator is running with the same settings as you have defined in your code.

        If they have the same settings the indicator will evaluate out exactly the same way. You will need to just check. Ensure you are viewing the correct bar too. Your print is on bar 3:47:21PM. You get a lookback of 100 bars from that point.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thank you,
          BIG diffference between Percent and Points !!!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          6 responses
          36 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Kaledus, Today, 01:29 PM
          5 responses
          14 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Waxavi, Today, 02:00 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X