Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating an early bar close

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

    Creating an early bar close

    I'm currently developing a strategy that trades based on daily indicator values. The problem I'm having is that I want to enter as soon as I have new information (i.e., when each daily bar closes), but unfortunately by the time I have that information the market is closed.

    My first thought of a workaround was to create a separate temporary time series based on the daily bars, but artificially insert the minute bar ten minutes before the close as the "daily close", and then calculate indicators on that. This would allow me ten minutes to enter before the market closes, while still being reasonably near to the actual close value for the day.

    This would be trivial with arrays, but since time series are stored as DataSeries objects I've been having trouble. My understanding is that DataSeries objects will always have the same number of indices as there are bars loaded in memory, which means I couldn't add an additional entry myself.

    Is there some workaround I could use for this? Would it be possible to pass arrays to all the indicators I'm using, or even cast the DataSeries objects into arrays and vice versa? I'm open to any method which would make the day's bar available before the close. Thanks in advance!

    #2
    Hello Konoakapen,

    Thank you for your post.

    You can use the Add() method to add additional DataSeries to the Strategy for a more intraday period.

    Add(PeriodType.Minute, 1);

    This will create a 1 minute DataSeries of the primary DataSeries, with its timestamps and will update with incoming data.

    You would then be able to use BarsArray[1] to pass the specific data series to all your indicator as such

    SMA(BarsArray[1], 14);

    http://www.ninjatrader.com/support/h...nstruments.htm

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply.

      I could definitely use that method and do something like Add(PeriodType.Minute, 390) to make approximately daily bars just before the close. But the number of bars varies each day, so running the strategy over multiple years, these time points can start to vary significantly from the actual close.

      I'm looking for something a little more robust than that. Ideally I could pass all of the daily bars to an indicator such as SMA, but then tack on the most recent bar from my minute DataSeries as "today's close", so when the indicator method looks for Close[0] it will find the value I inserted.

      Daily bars are the perfect time series for what I need, I just need a new data point a few minutes earlier than the daily bar close.

      Comment


        #4
        Originally posted by Konoakapen View Post
        Thanks for your reply.

        I could definitely use that method and do something like Add(PeriodType.Minute, 390) to make approximately daily bars just before the close. But the number of bars varies each day, so running the strategy over multiple years, these time points can start to vary significantly from the actual close.

        I'm looking for something a little more robust than that. Ideally I could pass all of the daily bars to an indicator such as SMA, but then tack on the most recent bar from my minute DataSeries as "today's close", so when the indicator method looks for Close[0] it will find the value I inserted.

        Daily bars are the perfect time series for what I need, I just need a new data point a few minutes earlier than the daily bar close.
        Just create another custom Session Template that closes early, and use that information when that session closes.

        Comment


          #5
          That's brilliant, thanks!

          Is it possible to still use the regular template in the same strategy? Or would I have to then make a separate strategy to do the actual trading in the regular session?

          Comment


            #6
            Originally posted by Konoakapen View Post
            That's brilliant, thanks!

            Is it possible to still use the regular template in the same strategy? Or would I have to then make a separate strategy to do the actual trading in the regular session?
            Only one session template can be loaded on the chart, but I do not see how that is an issue.

            You say that you want to get your end-of-day signal before the end of the regular trading day. All I have suggested is that you create an artificial end of day that overlaps the regular day. So, your special day ends, you get your signal and execute it. What does the regular sesion have to do with the matter?

            Comment


              #7
              Originally posted by koganam View Post
              Only one session template can be loaded on the chart, but I do not see how that is an issue.

              You say that you want to get your end-of-day signal before the end of the regular trading day. All I have suggested is that you create an artificial end of day that overlaps the regular day. So, your special day ends, you get your signal and execute it. What does the regular sesion have to do with the matter?
              I understand that I could then use that signal manually for trading, but could I have my strategy make the trade? My understanding is that it wouldn't be able to, since I would then be outside of the strategy session. Trades can only be entered during the session, correct?

              Comment


                #8
                Originally posted by Konoakapen View Post
                I understand that I could then use that signal manually for trading, but could I have my strategy make the trade? My understanding is that it wouldn't be able to, since I would then be outside of the strategy session. Trades can only be entered during the session, correct?
                The session is the session. The strategy trades on the session on which it is loaded. If you want your trades to be taken off your special EOD session, then load your Strategy onto a chart that is using that session.
                Last edited by koganam; 06-09-2014, 02:26 PM.

                Comment


                  #9
                  Originally posted by koganam View Post
                  The session is the session. The strategy trades on the session on which it is loaded. If you want your trades to be taken off your special EOD session, then load your Strategy onto a chart that is using that session.
                  Maybe I'm missing something here, but it seems like then we're back to the issue of only being able to have a single session. If I run the strategy on a chart with normal hours, then I get my signal only after the market closes. If I run the strategy on a chart with my special, slightly earlier hours, I get the signal before market close, but the strategy is again unable to enter the market itself, because the session ended.

                  With what you suggested above, I don't see any way to have the strategy compute a signal based on one session and then execute within another later session, which is what I would need. Really, I just need a way to algorithmically act on the information given by my special early EOD session.

                  Comment


                    #10
                    Originally posted by Konoakapen View Post
                    Maybe I'm missing something here, but it seems like then we're back to the issue of only being able to have a single session. If I run the strategy on a chart with normal hours, then I get my signal only after the market closes. If I run the strategy on a chart with my special, slightly earlier hours, I get the signal before market close, but the strategy is again unable to enter the market itself, because the session ended.

                    With what you suggested above, I don't see any way to have the strategy compute a signal based on one session and then execute within another later session, which is what I would need. Really, I just need a way to algorithmically act on the information given by my special early EOD session.
                    I guess it depends on what your session hours are. If the session definition is such that the new session starts before the regular session ends, then your trade is taken at the start of your session, which is before the regular session ends.

                    It is a matter of arranging your times so that things happen in the order that you want them to. In this context, exactly what session do you mean when you say "Regular Session".

                    Comment


                      #11
                      Originally posted by koganam View Post
                      I guess it depends on what your session hours are. If the session definition is such that the new session starts before the regular session ends, then your trade is taken at the start of your session, which is before the regular session ends.

                      It is a matter of arranging your times so that things happen in the order that you want them to. In this context, exactly what session do you mean when you say "Regular Session".
                      By "regular session" I mean the regular trading hours of the exchange. So we have a regular session that goes from 9:30-4 every day, and I make a custom session that goes 9:30-3:50. Now, when my custom session ends at 3:50, my indicators update and give me a buy/sell signal. If it was a buy signal, I then want to enter in the next 10 minutes on that same day, i.e., before the market closes.

                      I would like to do this automatically through the strategy, but the problem is a buy order generated then would only be filled the next morning at 8:30, when using the custom session.

                      Comment


                        #12
                        Originally posted by Konoakapen View Post
                        By "regular session" I mean the regular trading hours of the exchange. So we have a regular session that goes from 9:30-4 every day, and I make a custom session that goes 9:30-3:50. Now, when my custom session ends at 3:50, my indicators update and give me a buy/sell signal. If it was a buy signal, I then want to enter in the next 10 minutes on that same day, i.e., before the market closes.

                        I would like to do this automatically through the strategy, but the problem is a buy order generated then would only be filled the next morning at 8:30, when using the custom session.
                        So let your custom session be from 3:55 to 3.50 the next day. Then use a Time filter to delimit the actual hours within which trades may actually be taken. That way, you get your signal before 4:00, and it is triggered when then new session starts at 3.55.

                        Comment


                          #13
                          Originally posted by koganam View Post
                          So let your custom session be from 3:55 to 3.50 the next day. Then use a Time filter to delimit the actual hours within which trades may actually be taken. That way, you get your signal before 4:00, and it is triggered when then new session starts at 3.55.
                          This seems good, but unfortunately Session Manager won't let me do this for every day---a session that lasts all the way from Friday at 3:55 to Monday at 3:50 isn't allowed.

                          Any ideas?

                          Comment


                            #14
                            Originally posted by Konoakapen View Post
                            This seems good, but unfortunately Session Manager won't let me do this for every day---a session that lasts all the way from Friday at 3:55 to Monday at 3:50 isn't allowed.

                            Any ideas?
                            No session lasts over the weekend. The weekends are not trading days: sessions cover only potential trading hours.

                            If you must insist on doing such things, then you will have to go back to what we did in NT6.5, trading with the 24/7 session, (NT6.5 had no session manager), turn off "Exit on close", and use your own time filters to determine what times to be in and out. In other words, abandon the Session Manager completely, and code everything yourself.
                            Last edited by koganam; 06-12-2014, 03:39 PM.

                            Comment


                              #15
                              Originally posted by koganam View Post
                              No session lasts over the weekend. The weekends are not trading days: sessions cover only potential trading hours.

                              If you must insist on doing such things, then you will have to go back to what we did in NT6.5, trading with the 24/7 session, (NT6.5 had no session manager), turn off "Exit on close", and use your own time filters to determine what times to be in and out. In other words, abandon the Session Manager completely, and code everything yourself.
                              I guess I'm still confused. If I do what you said, and set up sessions each day from 3:55 till the next day at 3:50, I will get day bars which technically contain data from two days, but will be stamped with the ending day at 3:50, correct? I just want 5 of these uniform bars a week---naturally one would have to contain data from both Friday and Monday, and would be stamped Monday. How would I create that? I don't need the data from the weekend, I just wanted to have a singular day bar from Friday at 3:55 to Monday at 3:50.

                              By the way, thanks a lot for all your help...I can't seem to find information on what I'm trying to do anywhere.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              656 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              371 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              579 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X