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

Getting the highest High of pass 3 days, for every bar.

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

    Getting the highest High of pass 3 days, for every bar.

    To illustrate it clearer, I would set a scenario:

    period: 1 day
    (assume trade 7 days a week)


    Date - Highest High in past 3 days
    1/12 - 2655
    1/13 - 2641
    1/14 - 2621
    1/15 - 2621
    1/16 - 2601
    1/17 - 2587
    1/18 - 2577
    1/19 - 2573 (current day)

    How I get highest High in past 3 days: MAX(High, 3)[0]

    Now, I am in current day (1/19). I would like to get Highest High on 1/18, 1/16, 1/14

    What I tried to get Highest in past 3 days for 1/18:
    MAX(Highs[1],3)[0]
    But apparently it is not working. Highs don't work that way.

    What other function I can use?

    Thanks.

    #2
    Hello,

    Thank you for the question.

    I see that you are running this on a 1 day chart, the code you have provided to get the highest in the last 3 days would be if you have added an additional data series to the chart.

    The following would be able to get the last 3 days from the daily chart.

    Code:
    int highestBar = HighestBar(High, 3);
    double price = High[highestBar];
    Take a look at the HighestBar in the help guide, this will tell you a little more about how this works: http://www.ninjatrader.com/support/h...=highest%2Bbar

    The Highest bar returns an amount of bars ago which is useful when using the DataSeries because you know which bar to get the data from this way so you are not limited to only the high data, if needed you can access the bars total information.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for replying.

      I had tried the HighestBar(), it does return the highest bar in between N period from current bar, but still it is not really helpful to retrieve the info I want.

      Unless I can save the index of HighestBar in 1/14, 1/16, 1/18, and retrieve it back in 1/19, then I can get from High[index].

      Comment


        #4
        Hello,

        If you are trying to store the bars ago values for each of these dates you could take a look into an IntSeries which will allow you to store inter values in a series similar to how the price values are being stored.

        Here is some documentation on this, http://www.ninjatrader.com/support/h...tsub=IntSeries

        If you are storing the barsAgo value or the bar number of the HighestBar event you could store it into a IntSeries and then use this later to recall only these specific bar numbers.

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by vhanded View Post
          To illustrate it clearer, I would set a scenario:

          period: 1 day
          (assume trade 7 days a week)


          Date - Highest High in past 3 days
          1/12 - 2655
          1/13 - 2641
          1/14 - 2621
          1/15 - 2621
          1/16 - 2601
          1/17 - 2587
          1/18 - 2577
          1/19 - 2573 (current day)

          How I get highest High in past 3 days: MAX(High, 3)[0]

          Now, I am in current day (1/19). I would like to get Highest High on 1/18, 1/16, 1/14

          What I tried to get Highest in past 3 days for 1/18:
          MAX(Highs[1],3)[0]
          But apparently it is not working. Highs don't work that way.

          What other function I can use?

          Thanks.
          That is because you are using the wrong syntax. You want to query MAX(High, 3) from barsAgo bars ago. So you index your method to barsAgo.
          Code:
          MAX(High, 3)[barsAgo];
          Given the dates that you have specified, that means for the 18th, MAX(High, 3)[1];.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Kaledus, Today, 01:29 PM
          5 responses
          12 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Waxavi, Today, 02:00 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          5 responses
          23 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by PhillT, Today, 02:16 PM
          2 responses
          7 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Working...
          X