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

Most frequent update event

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

    Most frequent update event

    Hello fellow humans,
    What is the event method which is most frequently called inside an indicator?
    I'm developing one which places orders and needs to be aware of their status. Currently I'm using OnBarUpdate() to check on the orders but depending on the instrument & data series settings it can take sometimes seconds until a bar receives an update. I'd like to avoid subscribing or providing callback methods to the orders directly regardless of whether this would be possible, because I have also have a broader, non order specific logic which however needs to be checked on whenever any open orders are updated.
    For more context: I'm using Calculate = OnEachTick, but that's also only called whenever a bar receives an update, most of the time it being a price change.

    This is probably something simple I'm just not aware about.

    #2
    Hello Human#102,

    Thanks for your post.

    The OnBarUpdate() method is called depending on the Calculate mode the script is set to use.

    When using Calculate.OnBarClose, OnBarUpdate() will process at the close of each bar.

    When using Calculate.OnPriceChange, OnBarUpdate() will process for each change in price.

    When using Calculate.OnEachTick, OnBarUpdate() will process for each incoming tick.

    See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

    If you want to track orders for each time the order changes state, you could subscribe to Account OrderUpdate events.

    OrderUpdate: https://ninjatrader.com/support/help...rderupdate.htm
    Account: https://ninjatrader.com/support/help...ount_class.htm

    If you want to do an action based on a set amount of time, a timer could be implemented into your script using TriggerCustomEvent.

    TriggerCustomEvent: https://ninjatrader.com/support/help...ustomevent.htm
    SampleCustomEvents: https://ninjatrader.com/support/help...to_output_.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi BrandonH,
      Thank you for this response. The Account OrderUpdate events should do the trick. ^^
      One more thing I'd like to be verified, if possible:
      Should the OnEachTick calculation mode trigger the OnBarUpdate method every tick, or only if the incoming tick provides any new data/update for the bar? Because as far as I've been testing it (with prints etc.), most of the time, the OnBarUpdate method is only triggered when the price changes. Sometimes it is also triggered when the price does not change, but still not as often as I would expect and definitely not in regular intervalls.

      Comment


        #4
        Hello Human#102,

        Thanks for your notes.

        Calculate.OnEachTick means OnBarUpdate() is called for each tick that occurs. A print that prints out the Time[0] could be added to OnBarUpdate() to confirm when this method is being called.

        From the Calculate help guide:

        Determines how often OnBarUpdate() is called for each bar. OnBarClose means once at the close of the bar. OnEachTick means on every single tick. OnPriceChange means once for each price change.

        Calculate: https://ninjatrader.com/support/helpGuides/nt8/calculate.htm?zoom_highlightsub=calculate​
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the clarification!

          Comment


            #6
            If you want regular time-based intervals, you cannot depend on OnBarUpdate.

            Even with OnEachTick, even with a secondary data series, it is not 'regular'.

            Use an actual timer instead.

            Comment


              #7
              hi bltdavid i see the indicator Blttriggerlines... Do you know of someone who already has input parameters with this indicator or a pdf where they explain?

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Harry, 05-02-2018, 01:54 PM
              10 responses
              3,203 views
              0 likes
              Last Post tharton3  
              Started by cre8able, Yesterday, 01:16 PM
              3 responses
              11 views
              0 likes
              Last Post cre8able  
              Started by ChartTourist, Today, 08:22 AM
              0 responses
              6 views
              0 likes
              Last Post ChartTourist  
              Started by LiamTwine, Today, 08:10 AM
              0 responses
              2 views
              0 likes
              Last Post LiamTwine  
              Started by Balage0922, Today, 07:38 AM
              0 responses
              5 views
              0 likes
              Last Post Balage0922  
              Working...
              X