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

Working with Multiple DataSeries

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

    Working with Multiple DataSeries

    Hi guys,

    In my strategy I am working with 2 DataSeries which I have loaded in State.Configure as follows:
    Code:
    if (State == State.Configure)
        {
            AddDataSeries(BarsPeriodType.Minute, 120);
            AddDataSeries(BarsPeriodType.Minute, 1);
        }
    During OnBarUpdate(), I need to get the value of 'CurrentBar' for the 1-min DataSeries. However if I assign CurrentBar to a variable, the variable takes on the value of the CurrentBar of the 120-min DataSeries. How can I access the value of the 1-min CurrentBar?

    #2
    Hello Bluebeep,

    Thanks for your post.

    In a multi Timeframe script, each added data series will also call OnBarUpdate(). You can determine which data series is calling OnBarUpdate() by checking the BarsInProgress value. BarsInProgress will be 0 for the chart/primary bars, 1 for your 120 minutes series and 2 for your 1-minute bar.

    Note, the "value" of CurrentBar is the bar number. In a multi-timeframe script, you can use CurrentBars[] where the index would be the BarsInProgress. To get the current bar number of the 1 minute data series you would use CurrentBars[2].

    We highly recommend you review the help guide section in sequence here: https://ninjatrader.com/support/help...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by benmarkal, Yesterday, 12:52 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    20 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    12 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Working...
    X