Announcement

Collapse
No announcement yet.

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:	207
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 CarlTrading, 03-31-2026, 09:41 PM
                1 response
                43 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 04-01-2026, 02:41 AM
                0 responses
                20 views
                0 likes
                Last Post CarlTrading  
                Started by CaptainJack, 03-31-2026, 11:44 PM
                0 responses
                30 views
                1 like
                Last Post CaptainJack  
                Started by CarlTrading, 03-30-2026, 11:51 AM
                0 responses
                47 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 03-30-2026, 11:48 AM
                0 responses
                38 views
                0 likes
                Last Post CarlTrading  
                Working...
                X