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

First bar of additional BarsArray objects

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

    First bar of additional BarsArray objects

    If I were to add a bunch of additional bars objects, is there a guarantee that the first bars time of these additional objects will be at or after the first bar of the primary bars time? I am speaking strictly about the first bar. I have created this little script as a test and it does not print out anything so I am guessing there not a way for any of these bars objects' first bar time to be before the primaries. I could not find anything in the doc's on this topic. Here is the test I ran:

    Code:
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Indicator here.";
                    Name                                        = "ObaTest";
                    Calculate                                    = Calculate.OnPriceChange;
                    IsOverlay                                    = false;
                    DisplayInDataBox                            = true;
                    DrawOnPricePanel                            = true;
                    DrawHorizontalGridLines                        = true;
                    DrawVerticalGridLines                        = true;
                    PaintPriceMarkers                            = true;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    IsSuspendedWhileInactive                    = true;
                }
                else if (State == State.Configure)
                {
                    AddDataSeries("XLK",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLY",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLF",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLP",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLV",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLI",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLE",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLRE",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLU",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("XLB",BarsPeriodType.Minute,BarsPeriod.Value);
                    AddDataSeries("BKNG",BarsPeriodType.Minute,BarsPeriod.Value);
                }
            }
            protected override void OnBarUpdate() 
            { 
    
                //Check if the time of the first bar in any of the additional data series, 
                // is earlier the first bar of the primary data series
                if (BarsInProgress == 1)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLK is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 2)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLY is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 3)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLF is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 4)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLP is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 5)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLV is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 6)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLI is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 7)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLE is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 8)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLRE is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 9)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLU is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 10)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of XLB is earlier than the Primary");
                        }
                    }
                }else if (BarsInProgress == 11)  
                { 
                    if(CurrentBar == 0){
                        if(Time[0] < Times[0][0]){
                            Print("first bar of BKNG is earlier than the Primary");
                        }
                    }
                }        
            }

    #2
    Hello swcooke,

    Thank you for the post.

    In this specific test I couldn't really say if that is caused because the conditions are not becoming true, or because they are not being processed. Have you at this point verified that OnBarUpdate is running for all instruments and that the conditions are being hit and checked? It is possible if one of the instruments fails to load data, the test would be inconclusive.

    You may try a more general print just to clarify and make sure this is running first:


    Code:
    protected override void OnBarUpdate() 
    { 
        if(CurrentBar == 0)
        {
              Print("BIP: " + BarsInProgress + " " + Time[0] );
         }
    }

    In my personal test of this concept using just the ES primary and NQ secondary I do see the secondary being listed before the primary due to timestamps like the following:
    BIP: 1 10/9/2018 4:01:00 PM
    BIP: 0 10/10/2018 7:31:00 AM

    The condition you listed would not equate to true in this situation and it would cause an error if I were to check the primary time versus this secondary series time on bar 0 because it was processed first before the primary.

    As for your question of guarantee, I don't believe in this case there would be anything specific noting that this should be guarnteed. During historical data processing, NinjaTrader updates the series strictly according to their timestamps. You can locate the overview of how multi series data is processed in the following page but there are no specific scenarios such as the one you listed displayed in that page. This would be more of a general overview of how bar data is referenced and processed. https://ninjatrader.com/support/help...lightsub=multi

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

    Comment


      #3
      Jesse,

      I really appreciate your time. Most of my development efforts are focused on studying relationships between instruments. Just about every post I have opened since May when I moved my development efforts over to NT, has been met with a feeling that the NT API for this type of analysis is just not built for studying multiple instruments. I do my best to rip my scripts down to bare bones to demonstrate my questions in a simple way. Yet the post always ends with me not having the answers I need. Is there any way to spend a half hour with someone there to get some questions answered?

      Comment


        #4
        Hello swcooke,

        To directly answer your question, any time you inquire with us we are following through to the end of your question and we are trying to get the answers you request. We want to work with you to find a solution toward the question you asked, so yes we, will spend the time to answer your questions.

        We are happy to provide individual assistance on the forum or through email for NinjaScript items, that is not a problem. If you are asking for specifically phone support or a more direct contact method, this is not something we generally offer for NinjaScript specifically as that is not the best medium for programming questions. We can, however, schedule a call to further vocally explain concepts in question if that would help although it is not suggested. We do not provide actual programming services over the phone so this is why we generally suggested email or the forum. If you would like to further clarify your concern vocally you would need to email our support directly.

        In regard to your prior experiences, I can't really comment on the prior inquiries or the samples with those tickets that you have had. All I can really say here is that is the correct process to use. Our NinjaScript support is email based and we work best by example for NinjaScript requests. I can also say that we will try our best to work with you with respect to your personal coding style. We do however ask that you try and make the most simple example to explain your question that you can for the best result. The sample you provided in this thread is simple enough and was explanatory for the purpose of the question, thank you.

        NinjaScript is partially focused around using multiple instruments but the way it processes and works may not fit into every design goal. The multi-series processing in NinjaTrader does work in a very specific way so if you are coming from a different platform, or even from just a trading idea you may be met with logical walls you need to overcome based on how data is being processed. With that being said, Can I answer further questions you had surrounding the question of the original post or can you provide further details in regard to what is not clear at this point?



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

        Comment


          #5
          I sent an additional post today that I am still trying to get an answer on. The example is as simple as I can make it:
          I've used AddDataSeries() to add an additional instrument to my chart. If that additional instrument is missing a bar that the primary instrument has, how can

          Comment


            #6
            Hello swcooke,

            Thank you for the reply.

            Yes, it appears that one of the other techs has been able to reply to that thread. From my perspective, it appears that there is missing data for one of the instruments which would cause a gap when plotting another instrument in the same chart which does have a bar in that slot. This would have no effect on the BarsAgo used as that slot is not being utilized for the series missing the data. I don't want to pollute this thread with information from the other thread so I will leave it at this. If you have further questions surrounding the other thread, please ensure to reply back to that post directly to keep the information surrounding that question in one place.

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Waxavi, Today, 02:10 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            2 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            4 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            4 views
            0 likes
            Last Post gentlebenthebear  
            Working...
            X