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 geotrades1, Today, 10:02 AM
        0 responses
        1 view
        0 likes
        Last Post geotrades1  
        Started by rajendrasubedi2023, Today, 09:50 AM
        0 responses
        10 views
        0 likes
        Last Post rajendrasubedi2023  
        Started by ender_wiggum, Today, 09:50 AM
        0 responses
        4 views
        0 likes
        Last Post ender_wiggum  
        Started by bmartz, Today, 09:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by geddyisodin, Today, 05:20 AM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X