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

Align time of events with bars

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

    Align time of events with bars

    Hello,

    I am trying to align Market Data events with the bar where they occur, and, if it is the first event in the bar, then do some initializations. I could do that in OnBarUpdate, but only if I could be sure that OnBarUpdate event always comes first that the asociated Market Data event for the same tick. It is possible to assume any fixed secuence in the occurence of these events? If yes, which comes first?

    Thank you for any help.

    #2
    OnMarketData() comes first. Ultimately its the same event though so not sure why you really need to make a distinction?

    In OnBarUpdate() you could just go if (FirstTickOfBar) and then do whatever it is that you need to do on the first tick.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your quick reply,

      I´m calculating cumulative volumes for each bar, thats why I need to initialaize all variables at the beginning of each bar, if I do it using FirstTickofBar, I will lose the volume info related with the MarketData event which produce that first tick for the bar. Am I right?

      I need to do it on OnBarUpdate because from OnMarketData I don´t have access to Bars object or Time object.

      Comment


        #4
        telbentel,

        You could grab the volume info directly off the OnBarUpdate() method. When FirstTickOfBar == true, checking Volume[0] on that event = the volume of that tick. You can then keep a variable that keeps track of the prior event's volume and then on each subsequent event check Volume[0] and subtract prior volume from it to get the current tick's volume.

        currVol = Volume[0] - prevVol;
        prevVol = Volume[0];
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fitzsimmonsxz, Today, 10:44 PM
        0 responses
        10 views
        0 likes
        Last Post fitzsimmonsxz  
        Started by FAQtrader, Today, 10:05 PM
        0 responses
        3 views
        0 likes
        Last Post FAQtrader  
        Started by Damocoleman, 03-30-2022, 09:49 AM
        17 responses
        1,235 views
        0 likes
        Last Post Mykro
        by Mykro
         
        Started by junkone, Yesterday, 02:19 PM
        5 responses
        70 views
        1 like
        Last Post junkone
        by junkone
         
        Started by reynoldsn, Today, 07:19 PM
        0 responses
        9 views
        0 likes
        Last Post reynoldsn  
        Working...
        X