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



    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 Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Started by Waxavi, Today, 02:10 AM
              1 response
              21 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Working...
              X