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

IsFirstTickOfBar -- Sequencing Certainty?

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

    IsFirstTickOfBar -- Sequencing Certainty?

    Question regarding the sequencing certainty of IsFirstTickOfBar called within OnBarUpdate()... Is it theoretically possible for this event to be "missed" in the sense that the frequency of changes as specified by the Calculate parameter of OnBarUpdate() are "too fast" and the calling method is invoked AFTER the first tick of the bar, thereby missing IsFirstTickOfBar event?

    Example:
    Assume an range bar with bar size equal to n. On the (n+1)th tick up/down from the open of the current bar, a new bar is formed as per the definition of a range bar. The first execution that forms the new bar coincides with IsFirstTickOfBar. In the case of a range bar the Calculate parameter (whether OnBarClose, OnPriceChange, or OnEachTick) shouldn't matter because the IsFirstTickOfBar occurs at the same update event across all three calculation frequencies.

    Questions:
    1) In practice, does the above hold true? Meaning that the IsFirstTickOfBar event is truly calculation frequency independent in the case of a range bar?
    2) Is there a nuance/best practice that would prioritize the utilization of OnMarketData() over OnBarUpdate() to GAURANTEE that IsFirstTickOfBar is always processed and never missed?

    Thx.

    #2
    Hello TheFil,

    Thank you for your post.

    I have moved this to our General Development forum as it is specifically regarding NinjaScript development.

    IsFirstTickOfBar would only be useful when a strategy is calculating OnEachTick or OnPriceChange - it will always return true when the bar calculates as it closes. However, for either OnEachTick or OnPriceChange - the very first tick that forms that new bar will make IsFirstTickOfBar true.

    OnMarketData is called after OnBarUpdate on real time data. It is not called on historical data unless Tick Replay is active, but if Tick Replay is active it will still come after OnBarUpdate.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks NinjaTrader_Kate,

      That's interesting that OnMarketData() is called after OnBarUpdate()...

      By that logic then, what would be the difference, if any, between running a NinjaScript Strategy with Calculate frequency set to OnEachTick versus an explicit call to OnMarketData()?

      Secondly, could you confirm/reject the possibility of the IsFirstTickOfBar being "skipped" in ultra high-frequency data throughput periods (i.e. CPI print release, for example)?

      Thanks again.

      Comment


        #4
        Hello TheFil,

        Thank you for your reply.

        If you're talking in terms of getting tick updates, it would be a negligible difference in speed. IsFirstTickOfBar would not be skipped if data comes in more quickly, as it will all be processed in the order it came in.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X