Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Aligning Tick and Range Bars in indicators

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

    Aligning Tick and Range Bars in indicators

    Hi,

    I'm interested to understand some of the nuances and best practices around aligning single-tick bars with non-tick bars (range bars in this case) where the range bars are the primary series and the tick bars are the secondary series for the same instrument.

    I'm trying to understand how the OnBarUpdate event can fire in this scenario. I do understand there's no guarantee of the order in which the event will fire for any given tick - it might fire for the secondary series first or it might fire for the primary series first.

    However, I don't know for certain if they can both effectively be executing at the same time on different threads. Does anyone know the answer to that?

    Meanwhile, what I'm trying to do is I was looking to track the volume for each tick in each range separately. What I tried was using the FirstTickOfBar and BarsInProgress to try to reinitiatlize my volume tracking variables with each new bar. But I quickly saw that for the eight tick range bars I was using, sometimes I had captured eight ticks worth of data for a bar, other times 7, other times 9, and sometimes 6. So that didn't work.

    My thought is to try to use some kind of synchronization variable, but that approach would have to be thread safe. For a given tick, the OnBarUpdate event for the one-tick bar and for the range bar could conceivable try to check and modify its value at the same time.

    Thank you in advance for your ideas. If anyone is aware of a good code sample that would be great as well.

    Regards,

    Gordon

    #2
    Hi Gordon, you are correct in understanding, the approach is event based and thus no guaranteed sequence for this case would exist. Your NinjaScripts would run on the same thread though (this might change in the future). As far as example for synchronization go, I'm only aware of KDoren's works in our sharing implementing a synched series class basically - http://www.ninjatrader.com/support/f...=spread&desc=1

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X