Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData() versus "OnBarUpdate() + COBC = false"

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

    OnMarketData() versus "OnBarUpdate() + COBC = false"

    I have been thinking about this recently, and wondering whether apart from registering an extra event, the end-of-bar tick in the latter case, is there really any difference between using,
    1. OnBarUpdate() with COBC = false
    2. OnBarUpdate() with COBC = true, and OnMarketData() for tick processing

    I do understand that MarketDataEventArgs exposes tick times even on fixed-time-interval based charts, where OnBarUpdate() shows only the time of the end-of-bar.

    Given such, might it not make more sense to use the latter as the programming paradigm.

    #2
    Good morning,

    Not sure I understand exactly the question so let me know if the below does not answer.

    However the only difference between the two is that OnMarketData only works in realtime(Not historical) and is direct access to the streaming data.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      from the help files
      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.


      as such FirtTickOfBar wont be registered in OnMarketData.

      OnMarketData is very useful when COBC is set to true but you still need to calculate/tract some stuffs in RT (say stops/targets in a strategy).

      Comment


        #4
        Originally posted by NinjaTrader_Brett View Post
        Good morning,

        Not sure I understand exactly the question so let me know if the below does not answer.

        However the only difference between the two is that OnMarketData only works in realtime(Not historical) and is direct access to the streaming data.

        Let me know if I can be of further assistance.
        Well, that is certainly a difference.

        Given that answer then, does it mean that it will produce no usable results if a strategy the uses OnMarketData() for order generation is run through the Strategy Analyzer for backtest or optimization?

        Comment


          #5
          Correct, right would not run in historical. Only runs in live only mode.
          BrettNinjaTrader Product Management

          Comment


            #6
            Originally posted by bukkan View Post
            from the help files
            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.


            as such FirtTickOfBar wont be registered in OnMarketData. ...
            Yes, I did read that. That will be handled by a boolean flag set on the close of the bar, and turned off when OnMarketData() is done. If the flag is not set, OnMarketData() will return with no action. A pretty handy way to force precedence.

            Comment


              #7
              Originally posted by NinjaTrader_Brett View Post
              Correct, right would not run in historical. Only runs in live only mode.
              How then would one go about optimizing such a strategy? Hand optimization by manually adjusting parameters per each run, hardly seems workable. Or are you saying that such a strategy cannot be optimized, as there is no way to run any kind of backtest, with a reasonable permutation of parameters?

              Comment


                #8
                Hello,

                You can't optimize or backtest a strategy that uses live data stream access.
                BrettNinjaTrader Product Management

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                648 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                574 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X