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

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 Barry Milan, Today, 10:35 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post Barry Milan  
                    Started by DJ888, Yesterday, 06:09 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    3 responses
                    40 views
                    0 likes
                    Last Post jeronymite  
                    Started by bill2023, Today, 08:51 AM
                    2 responses
                    16 views
                    0 likes
                    Last Post bill2023  
                    Started by sidlercom80, 10-28-2023, 08:49 AM
                    167 responses
                    2,260 views
                    0 likes
                    Last Post jeronymite  
                    Working...
                    X