• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ericson, Today, 08:14 PM
    0 responses
    2 views
    0 likes
    Last Post ericson
    by ericson
     
    Started by user1986, Today, 07:28 PM
    1 response
    6 views
    0 likes
    Last Post user1986  
    Started by jertrade, Today, 06:57 PM
    0 responses
    5 views
    0 likes
    Last Post jertrade  
    Started by Emma1, Today, 02:42 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_DrewO  
    Started by fx.practic, Today, 03:10 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X