Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Highest Close of Green Bars only.

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

    Highest Close of Green Bars only.

    Using ormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> MAX(Close, 10)[0] returns the highest close over the last 10 bars.

    How would I get the highest close over the last 10 bars (provided however that it was a green bar (open higher than close)?

    Thanks

    #2
    You will need to create your own loop condition and check for it manually.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Are there any examples to look at?

      Are there any examples that could help me with this?

      Comment


        #4
        Unfortunately there are no examples. You will just need to work through the logic and create yourself a loop to do this.

        Untested code.
        Code:
        while(x < 10)
        {
            if (Close[0] > Open[0])
            {
                 if (High[0] > lastHigh)
                      lastHigh = High[0];
            }
            x++;
        }
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Why the loop?

          After spending some time with this, what would be the point to set up a loop?

          Since OnBarUpdate executes every time a Bar is closed can I not just check for a close > open and if true set HighestClose to Close[0]?

          I actually did this and it appears to work. But being new to NT are there other things I am not aware of or things that I should consider?

          Also any performance issues I should consider?

          Thanks

          Comment


            #6
            Hello,

            The loop allows you to check back in history (10 bars in Josh's example).

            If I understand you correctly, your method would only check going forward. However if that is what you want then give it a try.
            DenNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            576 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X