Announcement

Collapse
No announcement yet.

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.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          582 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          338 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X