• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamically create data series during strategy

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

    Dynamically create data series during strategy

    How do I go about creating a new data series for each bar update?

    For example, during OnBarUpdate() do I just run the function AddDataSeries() and the strategy would destroy the object automically? Or is it similar to C++ with new?

    Thanks for any help in advance

    #2
    Hello Lumbeezl,

    Thank you for your note.

    AddDataSeries should only be used in State.Configure and it would not function in OnBarUpdate.

    Further, 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".

    https://ninjatrader.com/support/help...dataseries.htm

    What exactly are you trying to achieve? Perhaps I can point you in a better direction.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      I'd just like to be able to check values of a different bar type during the active strategy.

      For example, I'd like to be able to find the OHLC of a range bar type with value x where x could be any number, while I'm in a position.

      So dynamically create a bar type, check it's values, and then delete the object after the values have been checked

      Comment


        #4
        Hello Lumbeezl,

        Thank you for your reply.

        As it's not possible to dynamically include additional data series, you would need to include the data series from within State.Configure and then based on your calculations, check the OHLC of the desired bar.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          If you only want to check some bar values, maybe BarsRequest would suit your purpose BUT it does not return synchronously and I'd expect quite a performance hit.

          Comment


            #6
            Is it possible to dynamically change the values of a data series during OnBarUpate?

            For example, if the master instrument is 32 Range, I could change it to 48 range? Or must that be configured within State.Configure as well?

            Comment


              #7
              Hello Lumbeezl,

              Thank you for your reply.

              No, that may not be dynamically changed within OnBarUpdate, you would need to add a separate 48 range data series within State.Configure.

              Please let us know if we may be of further assistance to you.
              Kate W.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by WHICKED, Today, 01:01 PM
              0 responses
              1 view
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by polo0202, Today, 12:15 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_BrendanC  
              Started by GARZONJ, Today, 11:27 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by NtFan, Today, 11:08 AM
              0 responses
              6 views
              0 likes
              Last Post NtFan
              by NtFan
               
              Started by anamaria0589, Today, 09:39 AM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_Jermaine  
              Working...
              X