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

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.
      Gaby V.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cre8able, Yesterday, 01:16 PM
      3 responses
      11 views
      0 likes
      Last Post cre8able  
      Started by ChartTourist, Today, 08:22 AM
      0 responses
      6 views
      0 likes
      Last Post ChartTourist  
      Started by LiamTwine, Today, 08:10 AM
      0 responses
      2 views
      0 likes
      Last Post LiamTwine  
      Started by Balage0922, Today, 07:38 AM
      0 responses
      5 views
      0 likes
      Last Post Balage0922  
      Started by JoMoon2024, Today, 06:56 AM
      0 responses
      6 views
      0 likes
      Last Post JoMoon2024  
      Working...
      X