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

Multi Instrument Strategy Questions

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

    Multi Instrument Strategy Questions

    I have several strategies that run against roughly 500 stocks. Up until now I have run each of them individually side by side but have recently moved to running them through one single strategy via the AddDataSeries call.

    The problem is that since doing this I have been running into some weird issues, let me preface this with saying that everything calculates on each tick and thus during the market open things move VERY fast especially when managing 500 instruments.

    1) OnBarUpdate uses Instrument.FullName to store data in a dictionary based on the current instrument being processed. It almost seems like if I am not done processing another instruments tick that this value will change to the new event that fired. For example:

    AAPL -> Incoming Tick -> OnBarUpdate()
    - Do some processing reference Instrument.FullName = AAPL
    - NVDA -> Incoming Tick -> OnBarUpdate()
    - Do Some processing reference Instrument.FullName = NVDA
    - AAPL Continues processing, reference Instrument.FullName again = NVDA

    I don't know if this is correct but this is what it seems like is happening. I can put some code together to verify this or am I missing something here, should I be using something else? I assume Instrument is a reference to an object that is changing in fast environments whereas the BarsInProgress is a primitive type passed by value and thus things like Closes[BarsInProgress][0] works without flaw etc.

    As I mentioned I'm making some assumptions here that could be incorrect but this is what I am currently lead to believe. Can you shed any light onto whether or not I am referencing the current object in the right way?

    #2
    Hello fxRichard,

    The script will be processing OnBarUpdate sequentially in one thread. This means its unlikely for this to be the case.

    However, if you can create a script to demonstrate that the BarsInProgress index does not match the Instrument name for that BarsInProgress we can submit this to our development.

    In the example script please do not include any code that is not absolutely necessary to demonstrate the behavior.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thasks Chelsea, so I have figured out the problem. It has to do with my integration with Sterling trader for order execution. My callbacks happen on another thread disassociated with what is going on in Ninja.

      Comment


        #4
        Hi !


        I am working in something close to this and my issue is that I couldnt find anything using multi-intruments and Unmanaged Orders together. Is that possible? Any sample code to look at?


        Thank you
        mcosta72
        NinjaTrader Ecosystem Vendor - Quant-Wise

        Comment


          #5
          Hello mcosta72,

          Thank you for the post.

          I am unaware of a sample that we provide for these two concepts to be combined. Generally, we don't provide much in the form of samples for unmanaged as it is very specific to your logic and how you have made it to work. I frequently suggest reviewing the Managed approach samples that involve storing orders as variables as this is often used with unmanaged. Outside of the managed samples showing the general workflow for orders, much of unmanaged orders would be up to you to experiment with and ensure it works for the purpose you are trying to achieve.



          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Kaledus, Today, 01:29 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frankthearm, Yesterday, 09:08 AM
          13 responses
          45 views
          0 likes
          Last Post frankthearm  
          Started by PaulMohn, Today, 12:36 PM
          2 responses
          16 views
          0 likes
          Last Post PaulMohn  
          Started by Conceptzx, 10-11-2022, 06:38 AM
          2 responses
          53 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by yertle, Yesterday, 08:38 AM
          8 responses
          37 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Working...
          X