Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

HighestHigh / LowestLow between 2 arbitrary bars

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

    HighestHigh / LowestLow between 2 arbitrary bars

    Hi there,

    I need to find the value of the Highest-High / Lowest-Low between 2 arbitrary bars.

    My first attempt was using MAX & MIN in a similar way to that described here

    however, because I need to do this between arbitrary bars, the period passed as argument to MAX / MIN keeps changing, as a result Ninja keeps creating new MIN / MAX objects which consumes memory until my PC rans out of it.

    So I need a different way of doing that ... I looked at HighestBar() in the help, it seems to be always working from the CurrentBar back, but I need a version of it that would start nBarsAgo ... does this exist, or am I left to write a little function to do what I need?
    (I am afraid my little function would end-up pretty slow, so if this is my only way, what are the possibilities to get a lighting-fast execution of it?)

    Thanks in advance
    Dominique

    #2
    Hello,

    You can use Count to determine on which bar you would like to start the calculation.

    if (CurrentBar > (Count - 50))

    This would start the calculation on the 50th bar on the chart, rather than going through each current bar.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Please, please, please,

      Re-read my 1st post, what you suggested has nothing to do with my question.

      Comment


        #4
        Hello,

        You would need to program in your own little function in this case since this action is counter intuitive to how we do caching and optimization of our indicators.

        You can open up the code in Min and Max to take a look at how we are going it. You most likely can copy this and then a single calc inside your own OnBarUpdate() would probably be the best way to go about doing this, however if its just two bars your comparing a simple bar to bar comparison Bar1 High > Bar 2 High would be easiest after using GetBar() to get the index you need to so you know which bars to compare.

        -Brett
        BrettNinjaTrader Product Management

        Comment


          #5
          Hi Brett,

          Thank you - this is what I did.

          I have a question re. performance in general ... once a Ninjascript is "compiled" in NinjaTrader, does it run as machine-code or is it interpreted?

          Have a great week-end

          Comment


            #6
            dom993, NinjaScript uses compiled DLLs that run native, not interpreted, which provides you with the highest performance possible.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            599 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            344 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
            558 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            557 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X