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

AddDataSeries - Remove added DataSeries

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

    AddDataSeries - Remove added DataSeries

    NT Team,

    AddDataSeries
    - should ONLY be called during State.Configure.
    - should include the AddDataSeries calls any hosted scripts will require.
    - should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g. Instrument).

    Instrument
    - should NOT be accessed before State.DataLoaded

    Given the above, where a script requires Instrument.FullName to determine which DataSeries to add, how have people approached this? Is the approach complicated when a script hosts other scripts.

    Is a potential solution to add a selection of alternate DataSeries (hardcoded) and remove any DataSeries superfluous to requirements during State.DataLoaded
    (when Instrument.FullName is known)? How would you remove superfluous DataSeries?

    Thanks
    Shannon
    Last edited by Shansen; 12-13-2017, 03:30 PM.

    #2
    Hello Shansen,

    The ability to add a data series dynamically is a known limitation in NinjaTrader 8 and is currently unsupported. It is also not possible to remove the data series, but you can prevent calculations from occurring for that BarsInProgress iteration.

    The advised solution would be to hard code that data series into the NinjaScript. You can also add parameters to control the logic by checking the BarsInProgress index that OnBarUpdate() should iterate on.

    For example, if you have 3 data series, you could have a parameter set an integer "BIPToCheck" 0 - 2 to be used in a BarsInProgress check.

    if(BarsInProgress == BIPToCheck)
    {
    // logic to be executed on this data series
    }

    For the thread's reference, I will include a link to the publicly available Multi Series NinjaScript documentation for adding additional data series and using BarsInProgress - https://ninjatrader.com/support/help...nstruments.htm

    We are tracking interest to improve this functionality in a feature request and I will submit a vote for this request on your behalf. The ticket ID is SFT-882.

    As with other feature requests, we cannot present an ETA as they are fulfilled based on the development team's schedule and priorities. Upon implementation the ticket ID can be found publicly on the Release Notes page of the help guide. I'll provide a link below.

    Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

    Please let me know if I may be of further assistance.
    Last edited by NinjaTrader_Jim; 12-13-2017, 09:09 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim,

      Expanding on my original question, please confirm the attached scripts conform to NT8 specifications for hosted scripts. The file includes three files: StratA, IndA & IndB where:
      - IndA includes AddDataSeries
      - IndB hosts IndA
      - StratA hosts IndA and IndB (which in turn also hosts IndA).

      Noting, AddDataSeries
      - should ONLY be called during State.Configure
      - should include any AddDataSeries calls any hosted scripts will require.
      And, NinjaScript best practices
      - To improve performance, instances of Indicators should be saved during State.Historical.

      Please confirm the three scripts conform to the NT8 guide.

      Again, thanks
      Shannon
      Attached Files
      Last edited by Shansen; 12-13-2017, 04:36 PM.

      Comment


        #4
        Hello Shansen,

        Most of that looks fine.

        The only thing I would note is that the indicators would have to add a plot so the indicator can be referenced by the calling NinjaScript. Setting a the Values Series<double> for the plot wouldn't be necessary, but the plot will need to be added so the calling NinjaScript can call the indicator with "double dbl = IndA(BarsArray[1])[0];" in OnBarUpdate(). The assignment wouldn't matter either so long as the calling NinjaScript references the indicator in OnBarUpdate().

        When developing, I would suggest to place a print for the secondary data series in your indicators so you can verify that the data series is applied and used appropriately.

        Please let me know if you have any questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Where:
          - a hosted script requires two BarsArrays, and
          - the hosting script adds both BarsArrays.

          In the hosting script, is it OK to save the instance of the hosted script during State.Historical using just one BarsArray? i. .e _indB = IndB(BarsArray[1]);

          Comment


            #6
            Hello Shansen,

            What you have in State.Historical would be valid.

            I've made some modifications to your sample and created a video discussing the modifications further. An indicator will have to be called in OnBarUpdate() to get updates.

            Demo: https://www.screencast.com/t/worAE5KSE

            double dbl = _indA[0]; would also be valid syntax.

            You can play with the sample on your end to observe the expected behavior and see how adding the plot and referencing the indicator in OnBarUpdate() makes a difference.

            If you have any additional questions, please don't hesitate to write back.
            Attached Files
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kevinenergy, 02-17-2023, 12:42 PM
            115 responses
            2,699 views
            1 like
            Last Post kevinenergy  
            Started by prdecast, Today, 06:07 AM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by Christopher_R, Today, 12:29 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by chartchart, 05-19-2021, 04:14 PM
            3 responses
            577 views
            1 like
            Last Post NinjaTrader_Gaby  
            Started by bsbisme, Yesterday, 02:08 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X