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

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 yertle, Yesterday, 08:38 AM
            7 responses
            28 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by bmartz, 03-12-2024, 06:12 AM
            2 responses
            21 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by funk10101, Today, 12:02 AM
            0 responses
            4 views
            0 likes
            Last Post funk10101  
            Started by gravdigaz6, Yesterday, 11:40 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by MarianApalaghiei, Yesterday, 10:49 PM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X