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 benmarkal, Yesterday, 12:52 PM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by helpwanted, Today, 03:06 AM
        1 response
        19 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        11 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        244 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        388 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X