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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X