Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Highest High Lowest Low N bars back

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

    Highest High Lowest Low N bars back

    Hi,
    Im trying to code a simple indicator that would draw Fib. retracement based on the highest high and lowest low of N bars back. I found one indicator that draws the fib based on the range of a specific time an another one that draws it based on the high and the low of the day. I need N bars back only, very simple.

    Im trying to adjust an existing indicator but can't seem to get the highest high and lowest low for the especific 50 bars back

    Can you help me here?

    Will greatly appreacite any comments.
    Thanks.

    protectedoverridevoid OnBarUpdate()
    {
    if(CurrentBar<50) return;

    {
    if(FirstBar<0) FirstBar=CurrentBar;

    if(HighestHigh<0.0)
    { HighestHigh = High[
    0];
    LowestLow = Low[
    0];
    }
    else
    { if(High[0]>HighestHigh)
    { HighestHigh = High[
    0];
    HighBar=CurrentBar;
    if(showHighAndLow) DrawHorizontalLine("High",false,HighestHigh,Color.Gray,DashStyle.Solid,1);
    }
    if(Low[0]<LowestLow)
    { LowestLow = Low[
    0];
    LowBar=CurrentBar;
    if(showHighAndLow) DrawHorizontalLine("Low",false,LowestLow,Color.Gray,DashStyle.Solid,1);
    }
    }

    #2
    Hello,

    Sure, If it was me I would use the MAX() function.




    And MIN().



    This will do exactly what your looking for.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Hi Brett, thanks for getting back to be so fast.

      I follow your advice and used the MAX and MIN, and and I was able to get the highest high and lowest low I was looking for.

      Now I wanted to get only the current value, and I am getting that for the lowest low but the highest high seems to keep plotting all the previous values. I can't find the error, can you help me?

      And also I'm having problems when trying to get the value of the highest high and lowest low to draw the fib. Is there any other sample I may follow?

      I really appreciate all your help.

      Thank you I have a good day.

      protected override void OnBarUpdate()
      {
      double highestHigh = MAX(High, 100)[0];
      double lowestLow = MIN(Low, 100)[0];


      if(ShowHigh)
      {
      if (!PlotCurrentValue || highestHigh != High[0])
      HighestHigh.Set(highestHigh);
      else
      for (int idx = 0; idx < HighestHigh.Count; idx++)
      HighestHigh.Set(idx, highestHigh);
      }

      if (ShowLow)
      {
      if (!PlotCurrentValue || lowestLow != Low[0])
      LowestLow.Set(lowestLow);
      else
      for (int idx = 0; idx < LowestLow.Count; idx++)
      LowestLow.Set(idx, lowestLow);
      }

      }

      Comment


        #4
        Hello,

        What do you mean by highest high keeps plotting? Can you please send a screenshot of what your seeing.

        To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.


        Also, I not sure what your refering too for this: value of the highest high and lowest low to draw the fib

        Lowest low and highest high of what? The day?

        I look forward to assisting you further.
        BrettNinjaTrader Product Management

        Comment


          #5
          Hi,

          I was able to solve the issue , but thanks for your help.

          Comment


            #6
            Data Box

            Hi,

            I have an indicator which values I don't want to see plotted on the chart, but I do want to see them in the data box. I changed the color of the indicator to transparent, but this takes it away from the data box. I know this is supposed to happened in NT7, and I was wondering if there is a way to having the indicator be transparent and still show in the data box.
            thanks

            Comment


              #7
              Hello,

              Glad to hear,

              Also on your secondary question I unfortunately do not know of a way to do this currently.

              Let me know if I can be of further assistance.
              BrettNinjaTrader Product Management

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              602 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              347 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              560 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              559 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X