Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to buy at the closing price on current bar?

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

    #31
    If you want to trade within a minute of the crossing, you need to backtest with minute bars. Daily bars only allow you to enter a position at the next day's opening price.

    Comment


      #32
      Yes Anagoge... I can see that. And - as Josh and Bertrand so kindly explained - that is the way to go. The problem is that daily historical bars are commonly provided for the last 10+ years and here the the longest 5 min historical data I can get is around two years. Well... searching for perfection, specially in the markets and related issues, is a bit stupid - I admit. :>)))

      BTW, I feel perhaps I should apologize, specially for Josh and Bertrand. I got a bit over..... something. I have been very well treated by all the NT stuff. They have always swiftly answered all my questions and did they best to help me - be it through emails or here in the forum. They are doing a great job.
      So... sorry for any inconvenience. I am looking forward to further discuss and learn about the NT software.

      rgds

      -geo-

      Comment


        #33
        Anagoge, I don't have NT installed here and I wonder: when prices cross a Stop-Loss level in the present daily bar are you exited in the present bar or the next?

        Tx

        -geo-

        Comment


          #34
          Geo - Thank you for the kind words, we appreciate it! I think you are correct, but perfection and markets doesn't fit too well together, but as long as one is constantly improving the future should be bright.

          Your stop losses and targets will be executed intrabar.

          Comment


            #35
            Correct, Bertrand. Perfection does not seem to be a human trace. Someone somewhere said that perfection belongs only to the unmanfiest, quality-less, un-born, underlying ground. I don't know.

            Well, if stops and targets can be triggered intra-bar, I´ll find a way to program NT to trigger breakouts also. Its the same thing.

            I just can't tell when.... LOL

            The reason it is important for me is because my trades are 1-2 days long. I search setups that consists of 2-5 bars. My strategies are based on a statistical edge... so when a breakout is triggered waiting for the next bar for execution is too late and mainly inaccurate. It would not be even close to reality statistically.

            On a strictly technical field, if one goes into the matter, there are things that can and others that can not be determined in ONE BAR.

            Some indicator values that are calculated in the close of the bar can not. Highs and lows have their value but are undetermined in time. Two stops within the same bar can not. Single stop-loss can. Single profit target yes. Breakouts yes, but then an eventual stop trigger may be problematic for there is no way to know weather the breakout level is before or after some eventual stop-loss level. Some crossings yes, because although the calculation is made at close like an EMA, the value can be processed and compared to the bar's range..... and the list goes on....

            []s

            -geo-

            Comment


              #36
              Actually no. EMA of the close can not be determined before the close of the bar. Of the open yes. Pivot levels also can.

              Comment


                #37
                For trading on a breakout above a particular value, e.g. the Highest high of the previous 5 days, why not just Enter on a Stop, with the Stop value being the desired breakout level. This code is executed at the end of a bar but is active for the next bar.

                Isn't that what you're trying to achieve?

                Comment


                  #38
                  Originally posted by pkuskopf View Post
                  For trading on a breakout above a particular value, e.g. the Highest high of the previous 5 days, why not just Enter on a Stop, with the Stop value being the desired breakout level. This code is executed at the end of a bar but is active for the next bar.

                  Isn't that what you're trying to achieve?
                  Is that possible pk? Yes that is what i want. Could you say a few words about the nature of the enter stop code? Let's say prices triggered a level in the present [0] bar, will the entry stop put me in the trade in this bar [0]? This stop routine is pre-programed for a chosen determined level or could I code further conditions?

                  Tx

                  -geo-

                  Comment


                    #39
                    No, if you have CalculateOnBarClose = true or are backtesting, placing any type of Enter() order as well as Exit() order on bar [0] will be executed on the next bar.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #40
                      Josh,

                      I thought so...
                      But interestingly there seems to be an exception. Stops are executed on the same bar where they are triggered. If calculations are executed on bar-close (backtesting)....how come?

                      -geo-

                      Comment


                        #41
                        geovani,

                        If you are referring to the Set() methods, those execute intrabar if price crosses over their value anywhere in the bar. Reason for this is because Set() methods are generated the same time your entry order was filled. Therefore they are working on the bar you entered on. NinjaTrader will fill your stop even if your profit target could have been filled in the same bar. This is to prevent any overstating of strategy performance since NT does not know what is happening intrabar.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #42
                          Originally posted by geovani View Post
                          Is that possible pk? Yes that is what i want. Could you say a few words about the nature of the enter stop code? Let's say prices triggered a level in the present [0] bar, will the entry stop put me in the trade in this bar [0]? This stop routine is pre-programed for a chosen determined level or could I code further conditions?

                          Tx

                          -geo-
                          No, you couldn't have logic on the current bar which also triggers on the current bar. However, if your logic is a crossing above highest high of 5 bars, you can easily set a variable to the highest high of the current bar and the 4 previous bars, e.g. myHighest, then use:

                          EnterLongStop(myHighest); or possibly EnterLongStop(myHighest + TickSize);

                          This will enter during the next bar if the price touches (or crosses) myHighest during that bar.

                          Isn't that what you're trying to achieve?

                          In your case you are able to specify the required entry conditions at the end of the bar prior to the bar you wish to enter, hence there is no problem with the NinjaTrader rules.

                          Peter

                          Comment


                            #43
                            Peter,

                            Ah...but of course!! This is it. As my entry is level related to some previous bar it will trigger in the next bar - which is the [0] present bar. Of course! tonk....tonk...tonk (geo knocking himself out in the head)

                            I think this will open a whole set of possibilities.
                            You see.. if you are going to explore a few hundreds of instruments for the next trading day it is very usefull to have practical tools to find the best suited short term setups.

                            Take the basic idea of prices crossing a MA. You don't have to wait for the next bar to enter. Simple mathematics can specify a range for the next bar. Although it is not a 100% pinpoint price it can fall quite close on average.

                            I can not test it with NT yet - for poor scripting skills...

                            Tx

                            -geo-

                            Comment


                              #44
                              Peter,

                              Consider the crossing of price tomorrow from bellow a 20 periods SMA:

                              SMA[1]-X/20 = C[1]+X/20
                              X = (SMA[1]-C[1])/10

                              Where:

                              SMA[1]: value of SMA yesterday at close
                              C[1]: close yesterday
                              X: amount of price move up today from yesterdays close

                              If I did not make any mystake X is the exact price of crossing today[0] that can be set() yesterday[1].

                              -geo-

                              Comment


                                #45
                                Originally posted by geovani View Post
                                Peter,

                                Consider the crossing of price tomorrow from bellow a 20 periods SMA:

                                SMA[1]-X/20 = C[1]+X/20
                                X = (SMA[1]-C[1])/10

                                Where:

                                SMA[1]: value of SMA yesterday at close
                                C[1]: close yesterday
                                X: amount of price move up today from yesterdays close

                                If I did not make any mystake X is the exact price of crossing today[0] that can be set() yesterday[1].

                                -geo-
                                I didn't check the mathematics, but if you know the internal calculation of an indicator, it is usually possible to calculate the move in tomorrows Close that would trigger a cross of the indicator. The only difference is that if you calculate this ahead of time, and enter on a stop, then you may enter intraday but the the price will retrace before the end of day so that if you were only trading EOD you wouldn't have taken that trade. Having said that, it's perfectly valid to trade either way, just make sure that you backtest it and apply the rules mechanically. The intraday method may respond to more market noise but on the other hand you may get additional or earlier trades.

                                Regards
                                Peter

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                63 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                139 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                75 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                45 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                50 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X