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

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 Stanfillirenfro, Yesterday, 09:19 AM
    7 responses
    51 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by TraderCro, 04-12-2024, 11:36 AM
    4 responses
    69 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Mindset, Yesterday, 02:04 AM
    1 response
    15 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by agclub, 04-21-2024, 08:57 PM
    4 responses
    18 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Irukandji, Today, 04:58 AM
    0 responses
    6 views
    0 likes
    Last Post Irukandji  
    Working...
    X