Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detecting the last tick of the day

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

    Detecting the last tick of the day

    Hi,

    I'm sure there'll be something about this in the forums already, but I didn't find it (searching on end, day, bar etc is difficult)

    I have a one minute strategy, calculating on bar close only. I have an instrument (Z) with end of day at 9pm, UK time.

    The problem is that the strategy runs constantly, but I need somehow, within a reasonable amount of time, to detect the last tick of the day and do something in the strategy. Currently, the strategy will not call onbarupdate until the first tick of the next bar, which is 8am the following day.

    Does anyone have any workarounds or solutions for this issue?

    One thing that occured to me was to add another bar series for daily timeframe. At least then I could get the strategy to execute some code.

    Related to this, could I have some info about how calling update() works? Can you set the barsinprogress for the call? If so, could I call update from the daily onbarsupdate and set barsinprogress to the minute bars series?

    Lastly, I want to try and come up with a solution that doesn't require setting calculateonbarclose to false!

    thanks for any ideas
    Dave

    #2
    Dave, the Update() would only be used to ensure certain internal indicator calculations are updated prior to the OnBarUpdate() call.

    In your situation I would suggest using a time filter to do your end of day calculations, would that work for you?

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. So Update() doesn't really call OnBarUpdate() ?

      By time filter, do mean take all ticks in and reject all those not with a particular time? If so, that doesn't really work for me, as I really want to avoid having OnBarUpdate() fire for every tick of the day.

      Comment


        #4
        You would force an OnBarUpdate() call of the indicator with this, but you can't force a new bar to be started, this is event based, so the tick of the new bar has to come in to close the old one.

        With time filter I just meant to process your 'last tick of the day logic' very close to the expected closing of the Z market (for example at 20:59:30).
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I don't really see how that works, since there will be no code executed at 20:59:30 since there will be no onbarupdate until 8am. Unless you mean take in all ticks, but I've already covered that.

          thanks
          Dave

          Comment


            #6
            You could add a finer granularity to achieve this, for example a 30 second chart.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              But I'd still miss the last 30 secs worth of ticks, meaning closing price and volume would be incorrect. And I'd get twice as many updates, and I don't want more than 1min ones.

              Comment


                #8
                This depends on in which context you run your main code, the added 30 sec chart would just give you access to lower then 1min timestamps.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by kaywai, Today, 06:26 AM
                1 response
                6 views
                0 likes
                Last Post kaywai
                by kaywai
                 
                Started by ct, 05-07-2023, 12:31 PM
                6 responses
                205 views
                0 likes
                Last Post wisconsinpat  
                Started by kevinenergy, 02-17-2023, 12:42 PM
                118 responses
                2,780 views
                1 like
                Last Post kevinenergy  
                Started by briansaul, Today, 05:31 AM
                0 responses
                10 views
                0 likes
                Last Post briansaul  
                Started by traderqz, Yesterday, 12:06 AM
                11 responses
                28 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X