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() 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.

    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.

          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.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by royhagerman, Today, 04:30 AM
                0 responses
                1 view
                0 likes
                Last Post royhagerman  
                Started by haas88, 03-21-2024, 02:22 AM
                18 responses
                208 views
                0 likes
                Last Post haas88
                by haas88
                 
                Started by Board game geek, Today, 02:20 AM
                0 responses
                6 views
                0 likes
                Last Post Board game geek  
                Started by knighty6508, Today, 01:20 AM
                2 responses
                15 views
                0 likes
                Last Post knighty6508  
                Started by franatas, Today, 01:53 AM
                0 responses
                5 views
                0 likes
                Last Post franatas  
                Working...
                X