• 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

BoolSeries

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

    BoolSeries

    Hello,
    I have a very vague question. What is the benefit of setting a BoolSeries for a condition vs just creating a flag for that condition?

    #2
    Originally posted by CaptainAmericaXX View Post
    Hello,
    I have a very vague question. What is the benefit of setting a BoolSeries for a condition vs just creating a flag for that condition?
    Well, by "flag" I assume you mean a single Boolean variable.

    The answer is simple.

    Is the condition logically associated with each bar?
    Is the condition subject to change on a per bar basis?
    Would it be useful for someone to be able to lookback, say, 5, 20, or 100 bars ago, and see what & how the condition has changed over time, on a per bar basis?

    The point is, if the condition is really a "flag" like condition subject to change on a per bar basis, and you want to retain the history of the flag's value for each bar, well, then you'll need a flag for each bar, right?

    Well, duh, there ya go, a BoolSeries, by definition, holds a flag for each bar.

    If, on the other hand, the "flag" is timeless and independent of all bars, that is, it represents the state of the total indicator (not past state of each individual bar) then a single Boolean variable is more appropriate.

    A DataSeries entire purpose in life is to maintain a small piece of information for each bar.

    Whether it be a BoolSeries, IntSeries, DataSeries, etc, the point is, each and every bar has a value stuffed into the series just for that bar.

    A BoolSeries is a like a gazillion True/False flags, where each bar only gets one flag.

    If you don't need that fine of granularity for your condition, then your condition is probably more associated with the indicator as a whole (not each bar) and therefore a single flag variable makes more sense.
    Last edited by bltdavid; 11-30-2017, 02:17 AM.

    Comment


      #3
      Hello CaptainAmericaXX,

      Thanks for your post.

      Member bltdavid has hit all the key points (thank-you).

      I would just add that as an example if you had several conditions that fed into another condition and that the several may have occurred some bars in advance of the last condition a boolseries would give you a bars ago means to lookback to see if the set of conditions were true x bars ago or within x barsago.

      So as member bltdavid advises a single flag would be the current status whilst a bool series would provide current status and historical status on each bar,
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by CaptainAmericaXX View Post
        Hello,
        I have a very vague question. What is the benefit of setting a BoolSeries for a condition vs just creating a flag for that condition?
        Does your processing need to be able to access the history of the bool flag?

        If "yes", use a bool series: if "no", use a current value flag?

        Comment


          #5
          Thank you all for your answers! Each was insightful to me. Let me see if I have this straight.
          If my condition is true from bars 10 - 20 and I set a bool to true during that period, once the condition is false the bool is set false and the program has no knowledge where that bool was ever true or the truth value of each bar, but I could use that bool for other purposes.
          If, on the other hand, when the condition is true I set the BoolSeries true, then each of the bars during that period will be marked true. If I then wanted to find the truth value of a bar during that period I could then ask: if(myBool[period]){}? Is this correct? I can see how this will be much more helpful than the flags I've been using.

          Comment


            #6
            Hello CaptainAmericaXX,

            Thanks for your post.

            Yes, you are correct.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              So after playing around with BoolSeries, IntSeries, etc I'm wondering if there is a way to easily access past values. With High, Low, Close, etc we can use barsago[]. This doesn't work the same with the 'Series' Class'. So far the best way I can see is to link a variable to the CurrentBar with the instance of the Series. Anyone have a trick?

              Comment


                #8
                Hello CaptainAmericaXX,

                Thanks for your reply.

                You should be able to use bars ago same as any other data series (High[], Low[], etc.)

                Reference: https://ninjatrader.com/support/help...ries_class.htm Note: Check the last example shown.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hey Paul,
                  Sorry I wasn't more specific. Let me give an example. If I have myIntSeries and I only want to find the values that were Set myIntSeries then I have to tie the CurrentBar to the instance. If I use barsAgo without knowing how many bars back a value was set to myIntSeries then [0] = 5, [1] = 0, [2] = 0, [3] = 0,.........., [20] = 4, etc.
                  I was hoping that each time a value was Set that instance would be its own barsAgo index. So instead of [0] = 5........[20] =4 it would be [0]= 5, [1] = 4.
                  This would actually probably get pretty confusing. I'm just trying to wrap my mind around the concept.

                  Comment


                    #10
                    Hello CaptainAmericaXX,

                    Thanks for your reply.

                    You are correct, that is confusing!

                    You can use the bars ago in the same way as any other data series. You can use methods like MAX() and MIN(), HighestBar() and LowestBar() to help you find data in the series.

                    Sounds like you have some testing to do.
                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Rashid Garuba, Today, 11:37 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post Rashid Garuba  
                    Started by elkhatabi, Today, 11:19 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post elkhatabi  
                    Started by hurleydood, Today, 10:07 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post hurleydood  
                    Started by Irukandji, Today, 09:43 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_ThomasC  
                    Started by TazoTodua, Today, 09:06 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post TazoTodua  
                    Working...
                    X