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

Adding Day bars to an indicator that is running on a Day chart.

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

    Adding Day bars to an indicator that is running on a Day chart.

    I have a indictor that is a SMA of Daily Pivots, I have added day bars to index location 1 with

    Add(PeriodType.Day, 1); //Add Day Bars to Index location 1

    I then tied a data series to day bars using,

    private DataSeries ppDS;

    and

    if(ppDS == null) // Only to sync the ppDS DataSeries to Day Bars
    {
    ppDS = new DataSeries(SMA(BarsArray[1], 2));
    }

    I also have a logic test for dars required,

    if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
    return;

    Just now when I was debugging a problem using visual Studio and running the script on a Day chart, so CurrentBars[0] and CurrentBars[1] are both day bars, I noticed that CurrentBars[0] is stuck at -1 during the whole run?

    This must be something to do with that fact that I have added day bars to my script and am running on a Day chart or is this behaviour unusual.

    Should I get round it with a logic check to see if the Primary data series is Day Bars?

    #2
    GKonheiser,

    Thank you for your post.

    I tested this out on my end with a simplified version but still meeting the logic requirements and didn't see this occur. CurrentBars will always start at 0.

    Could you elaborate how you tested for the CurrentBars[0] was at -1?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      I am stepping thou the program with Visual Studio. I just noticed now it is CurrentBars[1] that is fixed at -1.

      I have attached screen shots of Visual Studio where you can see CurrentBars[0] progressing as expected and CurrentBars[1] stuck at -1.
      Attached Files

      Comment


        #4
        Originally posted by GKonheiser View Post
        Hi Cal,

        I am stepping thou the program with Visual Studio. I just noticed now it is CurrentBars[1] that is fixed at -1.

        I have attached screen shots of Visual Studio where you can see CurrentBars[0] progressing as expected and CurrentBars[1] stuck at -1.
        That is implied by the literature on the subject. It is probably used as an internal mechanism to ensure that CurrentBars[1] are never processed. This will be in concert with this note:
        If a multi-series script adds an additional Bars object that already exists on the chart, the script will use the preexisting series instead of creating a new one to conserve memory. This includes that series' session template as applied from the chart. If the Bars object does not exist on the chart, the session template of the added Bars object will be the session template of the primary Bars object. If the primary Bars object is using the "<Use instrument settings>" session template then the additional Bars objects will use the default session templates as defined for their particular instruments in the Instrument Manager.
        (emphasis mine)
        located in the fourth folded section on this page: http://www.ninjatrader.com/support/h...nstruments.htm

        If I may say so, a lot of the questions that you ask are already documented in the NT Help. You might want to look there first.

        Comment


          #5
          Thanks for your replay. I will look more at the documentation. If it is true thou that this is intended then the initial bar check will never be true?

          if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired ||CurrentBars[2] <= BarsRequired)
          return;

          As CurrentBars[1] is fixed at -1?

          Comment


            #6
            No, -1 is less than the BarsRequired.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Cal View Post
              No, -1 is less than the BarsRequired.
              Ya, so it is not possible to write a multi series script that can be applied to any chart as you need to be mindful of duplicate series or CurrentBars logic for the duplicate series will not be processed.

              Is there a way around this or do you just have to make sure your not applying your script to a chart that has the same timeframe as one you have added in the script?

              Comment


                #8
                Originally posted by GKonheiser View Post
                Ya, so it is not possible to write a multi series script that can be applied to any chart as you need to be mindful of duplicate series or CurrentBars logic for the duplicate series will not be processed.

                Is there a way around this or do you just have to make sure your not applying your script to a chart that has the same timeframe as one you have added in the script?
                Stick in a check for equality, and branch to set the BIP as necessary.

                Comment


                  #9
                  GKonheiser,

                  I have tested this out on my end and not seeing the same results.

                  Would you please send me an email to support[at]ninjatrader[dot]com

                  I will need to the script you are working with as well as any other information such as screenshots you can send me.

                  Please put ATTN Cal in the subject and reference this post in the body.
                  Cal H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pechtri, 06-22-2023, 02:31 AM
                  10 responses
                  124 views
                  0 likes
                  Last Post Leeroy_Jenkins  
                  Started by judysamnt7, 03-13-2023, 09:11 AM
                  4 responses
                  59 views
                  0 likes
                  Last Post DynamicTest  
                  Started by ScottWalsh, Yesterday, 06:52 PM
                  4 responses
                  36 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by olisav57, Yesterday, 07:39 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post olisav57  
                  Started by trilliantrader, Yesterday, 03:01 PM
                  2 responses
                  22 views
                  0 likes
                  Last Post helpwanted  
                  Working...
                  X