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
    4 responses
    23 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Brevo, Today, 01:45 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by rjbtrade1, 11-30-2023, 04:38 PM
    2 responses
    73 views
    0 likes
    Last Post DavidHP
    by DavidHP
     
    Started by suroot, 04-10-2017, 02:18 AM
    5 responses
    3,021 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Stanfillirenfro, Today, 07:23 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X