• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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, 04: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]);
    http://www.ninjatrader.com/support/h...aximum_max.htm
    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 lavalampmj, Today, 05:25 PM
          0 responses
          3 views
          0 likes
          Last Post lavalampmj  
          Started by Antares66, Today, 05:19 PM
          0 responses
          2 views
          0 likes
          Last Post Antares66  
          Started by jmneto, Today, 05:18 PM
          0 responses
          4 views
          0 likes
          Last Post jmneto
          by jmneto
           
          Started by Bobbyj78, Today, 02:21 PM
          2 responses
          14 views
          0 likes
          Last Post bltdavid  
          Started by EnveousColnago, Today, 02:10 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Ariana  
          Working...
          X