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

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

        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.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Christopher_R, Today, 12:29 AM
            0 responses
            9 views
            0 likes
            Last Post Christopher_R  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            166 responses
            2,235 views
            0 likes
            Last Post sidlercom80  
            Started by thread, Yesterday, 11:58 PM
            0 responses
            3 views
            0 likes
            Last Post thread
            by thread
             
            Started by jclose, Yesterday, 09:37 PM
            0 responses
            8 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,415 views
            0 likes
            Last Post Traderontheroad  
            Working...
            X