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 burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          14 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          14 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,983 views
          3 likes
          Last Post jhudas88  
          Working...
          X