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

What determines the secondary and tertiary bar series order?

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

    What determines the secondary and tertiary bar series order?

    My strategy currently has 2 bar series, a 5 minute and 30 minute in that order defined in the Strategy Builder Additional Data section. When I View Code they appear in the order added in the Additional Data section. When I run the strategy I generally run it with a Base Period Value of 30, so that will be the primary series 0, and therefore the 5 minute would become series 1 (I assume). What will happen now when I add a third series for ticks? What determines the secondary and tertiary bar series order?
    Thanks

    #2
    Hello cupir2,

    Thank you for the post.

    The data series on the chart will always be the primary series (the 0th series). Additional series will be added in the order they are added to the script, so you are exactly correct when you say the 5 minute series will be series 1, the 30 minute will be series 2, and the newly added tick series will be series three.

    If you have not already, please see this help guide page on multi-time frame scripts:

    Please let me know if I can assist further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      Thanks for your reply.

      So in my example were there is a 30m series defined in Additional Data and appears second , it is series 2. But the Base Period Value is set to 30 in the Strategy Analyzer, does this mean it is actually being used as 0? When I View Code, all the indicators that use the 30m data appear to be set to 2, so i am not sure what series 0 is looking at.

      On the chart itself, I have two Data Series defined for the 30m and 5m series and they overlap in panel 1. When I run the strategy from the chart, the Input series is set to 30m data series.
      Thanks

      Comment


        #4
        When adding bars series AddBarSeries the order is in the config so for example

        chart bars in progress == 0

        AddSeries(minutes,5) // barsin progress == 1
        AddSeries(minutes,15) bars in progress == 2
        AddSeries(minutes,30) bars in progress == 3

        Comment


          #5
          Hello cupir2,

          Thanks for the reply.

          If you select a 30 minute series for the period in the Strategy Analyzer, the primary series will be 30 minute bars a.k.a BarsInProgress == 0. You would need to specify for the strategy to use the secondary series. For example, this is how I would get the SMA of the secondary series:

          SMA(BarsArray[1], 20)[0];

          Or in the strategy builder, you would need to specify the secondary series to be used in the "Input series" of an indicator.

          The reason the 30 minute series is used in the chart with the 5 minute series laid on top of it is because that was the series added to the chart first, that will always be the primary series.

          Please let me know if I can assist further.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Image 01 shows the three DataSeries defined as Additional Data. Below that are the indicators used throughout the strategy. In all but one indicator I am using the 30m data as seen by the use of "2". Only MCAD2 uses the 5m data identified by "1".
            Click image for larger version

Name:	01 AddDataSeries.png
Views:	276
Size:	49.6 KB
ID:	1035742

            Image 02 shows how the strategy is defined when assigned to a chart (left green circle) and when used in the Strategy Analyzer (right green circle).
            Click image for larger version

Name:	02 AddDataSeries.png
Views:	261
Size:	118.6 KB
ID:	1035741
            In testing and running the strategy the Base Period Value is 30 minutes which I believe makes it the primary series "0".
            What are the ramifications of defining a 30m series as "2" via the Additional Data section, while also specifying the primary "0" series as 30 minutes when running and testing the strategy?
            Are there special considerations to be made for the order in which additional data series are evaluated? Best practices?
            If I run the strategy using 30 minutes, should I remove the 30m data series from the Additional Data section?
            Attached Files

            Comment


              #7
              Hello cupir2,

              Thanks for the reply.

              I would recommend removing the additional 30-minute series to avoid redundancy. You already have the data available as the primary series. You will know what series OnBarUpdate is being called for with the BarsInProgress index context.

              EX:

              Code:
               protected override void OnBarUpdate()
                      {
                          if(BarsInProgress == 0)
                          {
                              //This code will run when OnBarUpdate is being called for the primary series
                          }
              
                          if(BarsInProgress == 1)
                          {
                              //This code will run when OnBarUpdate is being called for the secondary series
                          }
              
                          if(BarsInProgress == 2)
                          {
                              //This code will run when OnBarUpdate is being called for the tertiary series
                          }
                      }

              The order in which they are called depends on your Calculate property. With Calculate.OnBarClose, the OnBarUpdate for each series will be called for their respective period (every 30 minutes, 5 minutes, etc). With Calculate.OnEachTick, each series will run an OnBarUpdate for each incoming tick. In historical processing, the primary series will always be called first, unless you turn on Tick Replay.

              Please let me know if I can assist further.
              Last edited by NinjaTrader_ChrisL; 10-15-2018, 01:24 PM. Reason: Added link
              Chris L.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Shansen, 08-30-2019, 10:18 PM
              24 responses
              938 views
              0 likes
              Last Post spwizard  
              Started by Max238, Today, 01:28 AM
              0 responses
              3 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by rocketman7, Today, 01:00 AM
              0 responses
              1 view
              0 likes
              Last Post rocketman7  
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              27 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Working...
              X