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

what is the difference between these 2 methods?

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

    what is the difference between these 2 methods?

    Hello,

    What is the difference between using these 2 seemingly real time methods?

    1) placing code in the OnBarUpdate section while Calculate On Bar Close is set to false
    2) placing code in the OnMarketData section

    also, when is it preferable to use one over the other?

    thanks again

    #2
    Originally posted by gubbar924 View Post
    Hello,

    What is the difference between using these 2 seemingly real time methods?

    1) placing code in the OnBarUpdate section while Calculate On Bar Close is set to false
    2) placing code in the OnMarketData section

    also, when is it preferable to use one over the other?

    thanks again
    Not much, other than OnMarketData() is realtime only, so cannot be backtested or optimized.

    Comment


      #3
      thank you for the explanation

      Comment


        #4
        Hello gubbar924,

        Thank you for your post.

        OnBarUpdate() is called whenever the bar is updated. Where OnMarketData() is real-time only and is called whenever market data is updated. So updates to Bid, Ask, Last and Volume would be seen in OnMarketData() and only in OnBarUpdate() if the change updated the bar. OnBarUpdate() can also be restricted solely to when a bar closes by setting CalculateOnBarClose to True.

        OnMarketData(): http://www.ninjatrader.com/support/h...marketdata.htm
        OnBarUpdate(): http://www.ninjatrader.com/support/h...nbarupdate.htm
        CalculateOnBarClose: http://www.ninjatrader.com/support/h...onbarclose.htm

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        6 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        6 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        166 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        8 views
        0 likes
        Last Post cre8able  
        Started by RichStudent, Today, 04:21 PM
        0 responses
        5 views
        0 likes
        Last Post RichStudent  
        Working...
        X