Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple BarSeries and assigned #?

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

    Multiple BarSeries and assigned #?

    How does one know, beyond a shadow of a doubt, which Bar Series is which?

    Especially, if inside Indicator code, the Initialize() adds a new bar series. The help tends to assume it is #1 (the original underlying chart being #0). But is that ALWAYS true?

    What if a chart has two bar series already, before the indicator is added to the chart?
    Which is #1 and which is #2?

    How can code KNOW, in OnBarUpdate(),which bar series # was just added by the Initialize() ? What if multiple indicators each add a new series -- would not the assigned bar series # depend on the order in which the indicator were added (or called)? In which case, restricting the Indicator code to #1 would NOT work!

    I don't suppose the Add() function returns the assigned series #? That would be too clean!
    Last edited by Lost Trader; 07-28-2010, 02:01 PM.

    #2
    Lost Trader,

    Bars series do not exist in Initialize(). You will not be able to run any logic off of bars from Initialize().

    When the bars are made you can figure out which series you are in by using checks for BarsInProgress.

    Code:
    if (BarsInProgress == 0)
        // Do something;
    else if (BarsInProgress == 1)
        // Do something else;
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I know that, Josh. That isn't the question. Please read the post again.

      The Add(BarsPeriod.Id, BarsPeriod.Value*2); stmt does go in Initialize()

      How does code know, for certain, what the series # of that added bar series is? Regardless of how many bar series have been placed on the chart or inside other indicators, before or after this one?

      I know I can filter in OnBarUpdate(). How does code KNOW, without a doubt, which # to use as the filter?

      Comment


        #4
        Not following you. There is no series number in Initialize(). It does not exist yet.

        BarsInProgress 0 = always the one chosen on UI or the one on chart
        BIP1 = always the first Add()
        BIP2 = always the second Add()
        BIP3 = always the third Add()
        etc.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh,
          How can code in OnBarUpdate() KNOW which bar series # was added by the Initialize() ? What if multiple indicators each add a new series -- would not the assigned bar series # depend on the order in which the indicator were added (or called)? In which case, restricting the Indicator code to #1 would NOT work!

          What if a chart has two bar series already, before the indicator is added to the chart?
          How can code in OnBarUpdate() know which series is #1 and which is #2, in order to filter the CORRECT BIP # ?!!!

          It comes down to how can an indicator which wants to use its own series that was added by its own Initialize() function find out the actual series sequence so it can use the correct BarsInProgress #, without making assumptions.

          Surely, someone thought this out when designing it?

          Comment


            #6
            Please use BarsInProgress.

            It does not matter how many series are on a chart. They are irrelevant. An indicator only knows the series the indicator is actually attached to (BIP0) and the series the indicator itself adds. There is no cross referencing other series on the chart or other series added from other indicators.

            First series added with Add() is bar series #1 denoted by BarsInProgress == 1.
            Second series added with Add() is bar series #2 denoted by BarsInProgress == 2.
            Third series added with Add() is bar series #3 denoted by BarsInProgress == 3. etc. BarsInProgress == 0 is bar series #0 which is the one chosen on the UI or chart.

            If you now have another script that Add()s as well, on the other script the Add()s for that script will take the place for BIP1, 2, 3, etc. for that script only. Everything is relative to the script.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              An indicator only knows the series the indicator is actually attached to (BIP0) and the series the indicator itself adds. There is no cross referencing other series on the chart or other series added from other indicators.
              Thank you!! That is clearly stated -- I don't know that it has been clearly stated anywhere else.
              It explains many things in the help text that read like assumptions but apparently are based on knowing this.

              Begs another question tho: If a strategy uses this indicator, is the indicator's internal series visible or does the strategy need to add its own (duplicate) series to use it?

              Comment


                #8
                A strategy does not inherit any BIPs from an indicator it uses. You will need your own in the strategy.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by naanku, Today, 07:25 PM
                0 responses
                6 views
                0 likes
                Last Post naanku
                by naanku
                 
                Started by milfocs, Today, 07:23 PM
                0 responses
                5 views
                0 likes
                Last Post milfocs
                by milfocs
                 
                Started by PaulMohn, Today, 06:59 PM
                0 responses
                7 views
                0 likes
                Last Post PaulMohn  
                Started by bortz, 11-06-2023, 08:04 AM
                48 responses
                1,755 views
                0 likes
                Last Post carnitron  
                Started by Jonker, 04-27-2024, 01:19 PM
                3 responses
                24 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X