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

High of Highest Bar - Two Bars Back?

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

    High of Highest Bar - Two Bars Back?

    Hi all,

    In my current code (thanks to the fine folks at NT with the assist), I usually track the highest value of the highest bar in my COBC=false, OnBarUpdate section by using the following:

    Code:
    Math.Round(High[HighestBar(High, 5)],2)
    However, there's a variation I want to do where I get the highest high from the past five bars, starting with High[2] and not High[1] (where it seems to be starting now).

    The goal is to measure the value of High[1] against values High[2] to High [7]. Just not sure how the above code changes to reflect that.

    Anyone have any ideas on how to achieve this?
    Thanks in advance for any responses.

    Yours,
    Spider
    Last edited by Spiderbird; 10-05-2012, 05:49 AM. Reason: (grammatical mistakes)

    #2
    Hello Spiderbird,
    You can use the MAX function to find out the highest bar 2 bar back. Please refer to this code which further demonstrates it.
    Code:
    if (CurrentBar < 2) return;
    Plot0.Set(MAX(High, 5)[2]);
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks JoyDeep! Just to clarify in your code, Plot0 is your example variable?

      Meaning, I would put the variable of my choice (say trade_ProfitTarget) in that slot, so it would look like:
      trade_ProfitTarget.Set(MAX(High, 5)[2]);

      Is that correct? or should it be...

      trade_ProfitTarget = Plot0.Set(MAX(High, 5)[2]);

      Yours,
      Spider

      Comment


        #4
        Hello Spiderbird,
        Plot0 is the Plot data series which one adds in the Initialize section of an indicator.

        to put it as an variable please use the below code

        Code:
        double trade_ProfitTarget = MAX(High, 5)[2];
        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Great! Thanks for that clarification. Much appreciated JoyDeep!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Haiasi, Today, 06:53 PM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottWalsh, Today, 06:52 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottW, Today, 06:09 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ftsc2022, 10-25-2022, 12:03 PM
          5 responses
          256 views
          0 likes
          Last Post KeyonMatthews  
          Started by Board game geek, 10-29-2023, 12:00 PM
          14 responses
          244 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X