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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X