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 having issue with printing lowbar. I believe the syntax is not right.
    Print("The high of the zigzag bar is " + High[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100))]);
    Print("The low of the zigzag bar is " + Low[Math.Min(0, ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100))]);



    #2
    Hello tkaboris,

    Print("The low of the zigzag bar is " + Low[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100))]);

    The Math.Max(0, barsAgoValue) is to ensure that the index returned is not negative, which would be an invalid index.​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thank you
      how do i find high bar length in price level, not in number of points?
      In my condition i want to specify that Close[0] > Hbarlength ​(price level)
      I attached a screenshot to find what i am looking for.

      double HBar = High[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100))];
      double HBarPrev = High[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 2, 100))];
      double LBar = Low[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100))];
      double LBarPrev = Low[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 2, 100))];
      double Hbarlength = Math.Abs(HBar - LBar) / 2;

      ​​Click image for larger version

Name:	image.png
Views:	93
Size:	98.5 KB
ID:	1271347

      Comment


        #4
        Hello tkaboris,

        "how do i find high bar length in price level, not in number of points"

        You are asking for length as in number of bars, but expressed as a price?

        Or you are asking for the height as in High minus Low?

        The value circled on your screenshot does not appear to be a length but appears to be the price a few ticks below the bar.

        Are you asking how many bars it is between each HighBar and LowBar?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          i am asking to find a middle of the bullish zigzag leg in price value, not points as was pointed in screenshot.

          Comment


            #6
            Hello tkaboris,

            So the most recent High/Low bar number minus the previous High/Low bar number then divided by 2?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              yes thats what i am looking for

              Comment


                #8
                Hello,

                // if the last direction change was a highbar
                if (ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100) < ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100))
                {
                // print the bar located at the absolute distance from the most recent high bar to the most recent low bar, then divide by 2
                int distance = ( Math.Abs( ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100) - ZigZag(DeviationType.Points, 0.5, false).LowBar(0, 1, 100) ) / 2 );
                Print(Close[ Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100) + distance ] ));
                }
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by FishTrade, Yesterday, 11:11 PM
                3 responses
                11 views
                0 likes
                Last Post FishTrade  
                Started by Graci117, Today, 09:02 PM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by ETFVoyageur, Today, 07:55 PM
                0 responses
                8 views
                0 likes
                Last Post ETFVoyageur  
                Started by janio973, Today, 07:24 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by aligator, 01-06-2022, 12:14 PM
                4 responses
                250 views
                0 likes
                Last Post john_44573  
                Working...
                X