Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Second Time Series/Time Frame

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

    Second Time Series/Time Frame

    I would like to know if this is possible.

    Can I add a Second Timeframe / Bar Series where I can make the period variable, like below.

    BarSeries1SMA = SMA(BarsArray[1], iSMAPeriod);

    To put a use case to it, I would like to confirm trend on a longer timeframe, but trade on the shorter timeframe and I would then be able to set the period in Optimization.

    I am guessing no since I tried and got this message:
    Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.

    ​If this is not supported, how is this best accomplished?

    #2
    I can't seem to edit this with my current browser. The code I meant to past was this:
    AddDataSeries(Data.BarsPeriodType.Minute, iMyTimeFrame);

    Comment


      #3
      Hello ATMtrader0001,

      Thank you for your post.

      You can pass in a secondary series to an indicator and use a user input for the period (to be able to optimize this period input).

      Please see the attached sample script.

      Regarding this error, this can happen if you try to load data series dynamically. 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.​"



      Using an a variable for an AddDataSeries() parameter would be considered trying to load the data series dynamically, which is not supported.

      Please let me know if you have any further questions.
      Attached Files
      Last edited by NinjaTrader_Gaby; 03-08-2024, 09:19 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      128 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      117 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X