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

Enter at bar Close and exit at Open

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

    Enter at bar Close and exit at Open

    Hello,
    I want to build bar of 1440 minutes with custom trading hours, then enter a trade at the Close of the bar and exit the trade on the Open of the next bar.
    I know that this wasn't possible in version 7, and I wonder if there's a simple way of doing it in 8, besides using multiple data series with time triggered exit.

    Thank you

    #2
    Hello orenshkol,

    The first tick of the bar is what closes a bar if you are trying to have this event occur in the same tick that would still not be possible.

    You could try to use IsFirstTickOfBar and Calculate.OnEachTick for this type of logic but you would then also likely need time-based logic to know when the close is.

    Depending on the overall goal you may still need to use a similar approach to what you currently are in NT7.




    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi,
      I don't run this strategy on NT but on Tradestation were this is very simple to do. I was hoping that with NT8 I'll be able to use your program for this.
      What you're telling me is that the current bar is closed only at the next bar Open? and until than I have no way of accessing the current bar Close? What if I use multi dataseries with 1 minute as the second dataseries and check the Close value of the main series a minute after the bar closed but before it's Open, what will I see?

      Comment


        #4
        Hello orenshkol,

        Thank you for your response.

        The secondary series would still need the same tick or close of 1 minute in your detail and therefore you would still be waiting for the tick after the close on the primary bar series.

        Jesse's example using IsFirstTickOfBar and Calculate.OnEachTick would be the means to achieve what you are asking.

        Please let me know if you have any questions.

        Comment


          #5
          I'm sorry but I don't understand how this helps me.
          I want to write a strategy that uses a 1440 minutes bars with session times 09:30 - 15:50 CT, and if a condition is met enters a position on bar close (meaning at 15:50, or just after it, and not at the next bar open which will be 09:30).
          If I understand what you are saying, the program will only recognize that the bar closed only at the start of the next bar at 09:30, so I don't understand how using the IsFirstTickOfBar helps to solve this.

          Thank you

          Comment


            #6
            There is something not clear ; if your session is 6 hours ( 9:30 ~ 15:30 ) = 360 Min, then your 1440 Mins Bar will contain 4 days ?

            If you want to enter at 15:50 and exit at 9:30 why not using a standard session template on a 1 min chart and wait for those times to enter and exit ?
            pmaglio
            NinjaTrader Ecosystem Vendor - The Indicator Store

            Comment


              #7
              No, what it will form are daily bars starting at 09:30 and ending at 15:50, you can easily plot this on a chart and see the bars. I do this because I want to use those formed bars to do calculation and use indicators on, to decide if I want to enter at the end of day, so just using 1 minute bars won't help me. The problem is, that unlike other trading program, for some reason NT close the bars only at the next bar Open, which is really problematic when using daily bars. I'm trying to figure out if anything changed in NT8, or if there's some new way of bypassing that limitation.

              Comment


                #8
                Hello orenshkol,

                My previous comments were related to adding an additional data series and items that may be helpful when using that setup. For what you are trying, I previously mentioned that the first tick of the bar is what closes a bar. Because of this, you would still need to use the same kind of logic that you were in NT7 or adding an additional a series and using logic to determine these two points.

                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse,
                  Please try to be more specific in answering my questions :

                  1)
                  My previous comments were related to adding an additional data series and items that may be helpful when using that setup.
                  Please specify what additional data series? I used 1 minute data series with 24 hours trading hours and the main data series and the 1440 with 09:30 - 15:50 CT as the secondary data series, then check the entry condition at 15:51, and it works as I wanted in back-test, but not in live trading, How can I get that to work live?

                  2)
                  For what you are trying, I previously mentioned that the first tick of the bar is what closes a bar
                  Does that mean that if uses a 1440 minutes bars with session times 09:30 - 15:50 CT, then NT will only recognize that the current bar closed only on 09:30 the next day, the Open of the next bar?

                  3)
                  Because of this, you would still need to use the same kind of logic that you were in NT7
                  As I wrote
                  I don't run this strategy on NT but on Tradestation were this is very simple to do. I was hoping that with NT8 I'll be able to use your program for this.
                  In past correspondences you told me that this logic is impossible in NT7, is there a way to do this without the added functionality of NT8?

                  4)
                  You could try to use IsFirstTickOfBar and Calculate.OnEachTick for this type of logic but you would then also likely need time-based logic to know when the close is.
                  Jesse's example using IsFirstTickOfBar and Calculate.OnEachTick would be the means to achieve what you are asking.
                  the link http://ninjatrader.com/support/helpG...b=first%2Btick only gives the the definition of IsFirstTickOfBar, but does not explain how I can use it to execute the logic I want, please explain how to do this and give an example.

                  Thank you.

                  Comment


                    #10
                    Hello Orenshkol:

                    There are some workarounds for the issue of not knowing who won the November Presidential election until the morning of the following January 20th. Particularly for swing strategies, one approach simulating take-action-on-close behavior is to simply log relevant data to a text file and then export to excel to recreate a "performance summary" reflecting the on-close price points.

                    Another approach is to implement similar logic as an indicator showing trade action and price points. A second indicator can build an equity curve.

                    Of course, if real-time with live trading, then just check each tick along the way. Today's fast computers can handle it.

                    Hope this is useful.

                    Comment


                      #11
                      Was there ever an answer to this buy on close question?

                      I am having the same issue, with other programs it is really simple to execute a trade at market close (Amibroker, Tradestation etc.), with NT I have not found anything on the forums or the help guide that easily solves the issue. It should be just a simple click of a button to get a strategy to buy at or near close? For example if I am trading the S&P mini on Globex it closes at 3 pm MT and I would like my strategy to buy or sell 1 minute prior to session close not next open. Session close on Globex is from 3PM MT to 4PM MT.

                      "The problem is, that unlike other trading program, for some reason NT close the bars only at the next bar Open, which is really problematic when using daily bars. I'm trying to figure out if anything changed in NT8, or if there's some new way of bypassing that limitation"

                      Originally posted by orenshkol View Post
                      No, what it will form are daily bars starting at 09:30 and ending at 15:50, you can easily plot this on a chart and see the bars. I do this because I want to use those formed bars to do calculation and use indicators on, to decide if I want to enter at the end of day, so just using 1 minute bars won't help me. The problem is, that unlike other trading program, for some reason NT close the bars only at the next bar Open, which is really problematic when using daily bars. I'm trying to figure out if anything changed in NT8, or if there's some new way of bypassing that limitation.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by CortexZenUSA, Today, 12:53 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post CortexZenUSA  
                      Started by CortexZenUSA, Today, 12:46 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post CortexZenUSA  
                      Started by usazencortex, Today, 12:43 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post usazencortex  
                      Started by sidlercom80, 10-28-2023, 08:49 AM
                      168 responses
                      2,266 views
                      0 likes
                      Last Post sidlercom80  
                      Started by Barry Milan, Yesterday, 10:35 PM
                      3 responses
                      13 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Working...
                      X