Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ZigZag and Fib levels

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

    ZigZag and Fib levels

    Hi,

    I would like to get the recent 3 zigzag high and low on 1D, 4Hr and 60min and use them to find fib levels for each timeframe via ninja scripting.
    Is it possible to achieve? If so can you show/guide me with some examples.

    Thanks you very much for all your help. this forum and NT support is awesome.

    #2
    Hello greenhollow803,

    Thank you for your post.

    Yes, you could get the 3 most recent ZigZag highs and lows programmatically. The syntax available for the ZigZag indicator (including an example) may be found on this page of the help guide:


    Since you want to use multiple timeframes, you will need to call AddDataSeries() in your script to add the necessary time frames:


    Then, since you will be working with a multi-time frame script, you should keep the following information in mind:

    Note: The "Using Bars Objects as Input to Indicator Methods" section of the page is especially relevant for working with the ZigZag indicator in your script.

    When you mention using the ZigZag highs and lows for fib levels, what exactly do you mean? Do you mean drawing Fibonacci tools at those points? The Draw() methods for use in NinjaScript are listed here, including the Fibonacci tools:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Thank you very much for a such quick response. Yes I would like to draw fib retracements for the given zig zag high and zigzag low.
      I tried based on the examples given the documentation. But no luck.

      double H1 = High[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100))];
      double L1 = Low[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100))];
      Print("Zigzag levels :"+H1 + " :"+L1);
      Draw.FibonacciRetracements(this, "fib", true, 100, H1, 0, L1);​


      I gave bars to look back 100 as I am not sure what value I need to provide. However this didn't work for me. Can you advise what I am missing?

      Comment


        #4
        Hello greenhollow803,

        Thank you for your reply.

        Rather than trying to get the High/Low price of the ZigZag.HighBar and ZigZag.LowBar, I suggest first printing out the value from the ZigZag method to see what happens. The prints would return a value of -1 if no swing point is found in the lookback of 100 bars, or you will get an int that represents the number of bars ago since the swing point. Here is an example that will look to see if there is a ZigZagHigh or ZigZag low in the last 100 bars:

        Code:
        if (ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100) == -1)
        Print(Time[0] + " No ZigZag High found in the last 100 bars");
        else
        Print(Time[0] + " ZigZag High found " + ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100) + " bars ago!");
        
        if (ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100) == -1)
        Print(Time[0] + " No ZigZag Low found in the last 100 bars");
        else
        Print(Time[0] + " ZigZag Low found " + ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100) + " bars ago!");
        If you do not see any prints in the NinjaScript Output window, be sure to check the Log tab of the Control Center for any error messages.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Thank you Emily

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          57 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          133 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X