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

OnMarketData

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

    OnMarketData

    I am using multi instruments in my code. My question is, Will the OnMarketData() method fire everytime ANY instruments bid/ask data changes, or will it only fire when the main instruments bid/ask data changes?

    #2
    It will whenever any instrument has a change.

    Here is info from the help guide that will be useful for you.

    1. With multi-time frame and instrument strategies, OnMarketData will be called for all unique instruments in your strategy. Use the BarsInProgress to filter the OnMarketData() method for a specific instrument.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I wasn't clear on this either. Thanks Josh.

      Comment


        #4
        Multi Instrument Strategy

        Rekindling an old thread here,... but which is preferable for multi instrument strategies?
        OnBarUpdate or OnMarketData? and why..... Regards and thx

        Comment


          #5
          Hello everington_f,

          Thanks for your post.

          Josh's link from 2008 is outdated, here is the updated link: http://ninjatrader.com/support/helpG...nstruments.htm

          In review of the helpguide section of OnMarketData: http://ninjatrader.com/support/helpG...marketdata.htm you will find the following notes and tips:

          This is a real-time data stream and can be CPU intensive if your program code is compute intensive (not optimal)

          This method is not called on historical data (backtest)

          With multi-time frame and instrument strategies, OnMarketData() will be called for all unique instruments in your strategy. Use the BarsInProgress to filter the OnMarketData() method for a specific instrument. (BarsInProgress will return the first BarsInProgress series that matches the instrument for the event)

          Do not leave an unused OnMarketData() method declared in your NinjaScript object. This will unnecessarily attach a data stream to your strategy which uses unnecessary CPU cycles.

          Should you wish to run comparisons against prior values you will need to store and update local variables to track the relevant values.

          With NinjaTrader being multi-threaded, you should not rely on any particular sequence of events like OnMarketData() always being called before OnBarUpdate() or vice versa.
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Aviram Y, Today, 05:29 AM
          0 responses
          2 views
          0 likes
          Last Post Aviram Y  
          Started by quantismo, 04-17-2024, 05:13 PM
          3 responses
          25 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          7 responses
          34 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cls71, Today, 04:45 AM
          0 responses
          6 views
          0 likes
          Last Post cls71
          by cls71
           
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          217 views
          1 like
          Last Post PaulMohn  
          Working...
          X