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

MultiSeries information

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

    MultiSeries information

    In my strategy I add a dataserie using the add command in the initialize section. For example: Add(PeriodType.Minute, 5).

    Now I call one of my own indicators. Is the information of the DataSerie I have added in the strategy available within that indicator? For example, can I use Closes[1][0] and get the close price of the added dataserie.

    I have tested, but it seems having problems using that info. I always getting that the index is out of range, even by skipping the fisrt bars using the required bars.

    Kind regards,
    Rene

    #2
    Hello Rene,

    Yes, you can get values of the secondary time series that you have added. You may just want to make sure that you have enough bars for the secondary time series that you are accessing. For Example:

    Code:
    protected override void OnBarUpdate()
    {
        // Check to make sure that there is 10 bars in both data series before calculating
        if (CurrentBars[0] < 10 || CurrentBars[1] < 10)
            return;
    
        // Rest of your code
    }



    You may view the following link to our Help Guide that goes over in detail how bars are referenced in a multiseries script.
    JCNinjaTrader Customer Service

    Comment


      #3
      That seems not to be the solution. If I use the command CurrentBars[1] in the strategy, no error msg occusr. If I use the command CurrentBars[1] in the indicator I call from with the strategy, I get the error msg that the index is out of range. The error occurs on bar 0. My first command in the indicator i the OnBarUpdate section is:
      if (CurrentBars[1] <= 100)
      So it seems that CurrentBars is working in the strategy code but not in the indicator I call from within the strategy. It looks like the the added dataserie is unknown in the indicator. The command CurrentBars[0] is functioning correctly in indicator. Any other suggestion?

      Kind regards,
      rene Kreileman

      Comment


        #4
        Hello Rene,

        You would only want to use the Check for the "CurrentBars[]" inside of the Strategy since that is the script that you are adding the multiseries script to. Here are a few examples on how you can access the different series.

        Code:
        protected override void OnBarUpdate()
        {
            // Check to make sure that there is 10 bars in both data series before calculating
            if (CurrentBars[0] < 10 || CurrentBars[1] < 10)
                return;
        
            // Get the SMA of a 14 period from the Close of the 5-Min Data Series that we added
            double smaClose5Min = SMA(Closes[1], 14)[0];
        
            // Get the current Close of the 5-Min Data Series
            double closeOf5Min = Closes[1][0];
        
        }
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rayyyu12, Today, 12:47 AM
        0 responses
        0 views
        0 likes
        Last Post rayyyu12  
        Started by ETFVoyageur, 05-07-2024, 07:05 PM
        17 responses
        133 views
        0 likes
        Last Post ETFVoyageur  
        Started by ETFVoyageur, Yesterday, 10:13 PM
        1 response
        8 views
        0 likes
        Last Post ETFVoyageur  
        Started by somethingcomplex, Yesterday, 10:36 PM
        0 responses
        8 views
        0 likes
        Last Post somethingcomplex  
        Started by sofortune, 05-10-2024, 10:28 AM
        5 responses
        22 views
        0 likes
        Last Post sofortune  
        Working...
        X