Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate on bar close on range bars

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

    Calculate on bar close on range bars

    Hello

    1. I have a strategy that runs on range bars with COBC=true. When exactly is OnBarUpdate() called ? is it run on the first tick of the new bar, for the old bar ?

    2. I need this strategy to run with COBC=false and get some info every tick, yet I do not want it to go through all the end of bar calculations. How do I do that programatically ? Should I use "FirstBarOfTick" and if true go through the end-of-bar-calculations, else go trough tick calculations ? Is there a better way ?

    3. If I need this strategy to read OnMarketUpdate event, how can I programatically know if it is the start/end of a range bar ? The documentation for FirstTickOfBar says it is only available in OnBarUpdate().

    Thanks

    #2
    Hello tickling,

    1. COBC is called on the first tick of the new bar, which is also where the previous bar ended.

    2. Yes, you have to calculate it at the FirstBarOfTick. Please refer to this sample code which demonstrates it further http://ninjatrader.com/support/forum...ad.php?t=19387

    3. OnMarketData and OnBarUpdate runs on different threads. As such FirstBarOfTick cannot be accessed from OnMarket Data. Unfortunately there are no native methods in OnMarketData to obtain that information.

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by tickling View Post
      Hello

      1. I have a strategy that runs on range bars with COBC=true. When exactly is OnBarUpdate() called ? is it run on the first tick of the new bar, for the old bar ?

      2. I need this strategy to run with COBC=false and get some info every tick, yet I do not want it to go through all the end of bar calculations. How do I do that programatically ? Should I use "FirstBarOfTick" and if true go through the end-of-bar-calculations, else go trough tick calculations ? Is there a better way ?

      3. If I need this strategy to read OnMarketUpdate event, how can I programatically know if it is the start/end of a range bar ? The documentation for FirstTickOfBar says it is only available in OnBarUpdate().

      Thanks
      Use a boolean class variable that fires on FirstTickOfBar and off on the next tick, and query it from OnMarketData().

      As the OnBarUpdate() and OnMarketData() events sequence is not guaranteed, it being asynchronous, with no lock, it will not be perfect, but it should be close enough. If you need microsecond accuracy, then you are probably one of those mega rich High Frequency Traders, so NT is not your cup 'o tea anyway.
      Last edited by koganam; 09-21-2014, 07:08 PM.

      Comment


        #4
        Thanks ! The "close enough" solution is probably good enough ... will give it a try.
        No mega rich HFT here

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        573 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        575 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X