• 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

Keeping track of Highs and Lows

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

    Keeping track of Highs and Lows

    Programming question: In my new strategy, I'd like to keep track of the highs and lows made by an indicator. For example: Let's say that I'm using a set of Stochastics, and I want to keep track of the highs and lows made by the %K line (by measuring the slope to catch inflections, let's say.)

    I'd like to have some kind of array, or DataSeries, that I could refer to in the strategy. For example, let's say I have an array of "Lows", so I could see if I've been making higher lows.

    This seems like it should be straightforward, but then I had an "a-ha" moment: I'm comfortable creating my own custom indicators using DataSeries objects, but a DataSeries always adds a new value for every minute/candle/tick. If I have a series of 100 Tick bars, they may only contain, say, five highs and five lows.

    So I suppose, in general, my question becomes: I want to create a DataSeries/Array that only adds a new value occasionally and irregularly. Is this a problem?

    #2
    Hello pbailey19,

    Thank you for your post.

    There are multiple ways that you could accomplish this.

    You could have a variable that contains the current low, if there is a new lower low, you can add this value to a list (array) of low values then set the variable to that new low.
    http://www.dotnetperls.com/list

    You could also use LowestBar(Low, CurrentBar-1)[0]. The [0] would be the lowest low, [1] would be the second lowest low, etc.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Whoa! I didn't know that LowestBar (or HighestBar, I assume) would do that. I mean, I thought it was a single value, not an array/list. Of course, before I get too excited ... it sounds like it's sorting the highs and lows by value, instead of keeping them in order, chronologically. So I would always be getting an array of sorted lows and highs.

      Yeah, I think maintaining a list of highs and lows is the way to go, for me. Unless there's a way to keep LowestBar and HighestBar from sorting?

      Comment


        #4
        Hi pbailey19,

        LowestBar will return a bars ago value of where that bar was.
        http://www.ninjatrader.com/support/h.../lowestbar.htm

        To print the low from using that you would call Low[Lowestbar(Low, CurrentBar-1)[0]].

        That would return the price of the lowest low.

        However, it looks like it would be better for you to store the lows to a list.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by pbailey19 View Post
          Programming question: In my new strategy, I'd like to keep track of the highs and lows made by an indicator. For example: Let's say that I'm using a set of Stochastics, and I want to keep track of the highs and lows made by the %K line (by measuring the slope to catch inflections, let's say.)

          I'd like to have some kind of array, or DataSeries, that I could refer to in the strategy. For example, let's say I have an array of "Lows", so I could see if I've been making higher lows.

          This seems like it should be straightforward, but then I had an "a-ha" moment: I'm comfortable creating my own custom indicators using DataSeries objects, but a DataSeries always adds a new value for every minute/candle/tick. If I have a series of 100 Tick bars, they may only contain, say, five highs and five lows.

          So I suppose, in general, my question becomes: I want to create a DataSeries/Array that only adds a new value occasionally and irregularly. Is this a problem?
          You will need to use either an ArraList or a generic List.

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello pbailey19,

            Thank you for your post.

            There are multiple ways that you could accomplish this.

            You could have a variable that contains the current low, if there is a new lower low, you can add this value to a list (array) of low values then set the variable to that new low.
            http://www.dotnetperls.com/list

            You could also use LowestBar(Low, CurrentBar-1)[0]. The [0] would be the lowest low, [1] would be the second lowest low, etc.
            More about ...http://csharp.net-informations.com/collection/list.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by StealthM93, Today, 07:58 PM
            0 responses
            2 views
            0 likes
            Last Post StealthM93  
            Started by Mykro, Today, 11:01 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by bauerjj10, Today, 12:24 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Newtrader101, Today, 06:01 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_EricB  
            Started by Steve L, Today, 03:50 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X