Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Second Data Series based on the first one

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

    Adding Second Data Series based on the first one

    Hi,

    How do I add a second data series based on the first one?
    Like if the first data series that was selected for the strategy is 1 min, I want to add a second data series of 5 min to the strategy. If it's 5 min, I want to add 10 min.

    The additional data series is added in State.Configure, at which point we have no access to the BarsPeriod yet. I tried and it gave me a reference error.


    #2
    Hello admiralpanda,

    Thanks for your post.

    If you want to add a 5-Minute secondary data series to the script, you could simply call the code below.

    AddDataSeries(BarsPeriodType.Minute, 5);

    This would add a 5-Minute secondary data series to the script using the same instrument as the primary data series the script is running on.

    The code AddDataSeries(BarsPeriodType.Minute, 10); would add a 10-Minute secondary series to the script.

    Note that AddDataSeries() must be hardcoded into the script and not rely on any conditions, variables, user inputs, etc. This is noted in the help guide.

    From the help guide:

    "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.​"​

    See this help guide page for more information about AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    29 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    46 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X