Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Buy or Short on Market Open Price

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

    How to Buy or Short on Market Open Price

    I'm trying to do very simple backtesting using Strategy Analyzer.

    What I want to do is EnterLong (or EnterShort) at Market Open Price for specific stock (any popular one).

    Tried everything that I can but always return a minute (or 2 to 3) after price data.

    Is it possible in NT backtesting?

    Any idea?
    Last edited by logosguru; 12-16-2014, 09:15 AM.

    #2
    Hello Logosguru,

    Thank you for your post.

    What are you using for the code to submit these orders?

    Are you using the Strategy Wizard or custom coding this?

    Can you provide a screenshot of what it is you are seeing?
    To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file. Click Reply -> Go Advanced -> Click the Paperclip Icon in the Toolbar

    For detailed instructions please visit the following link

    http://take-a-screenshot.org/
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Screen capture

      Thanks for your quick reply.

      I'm using custom coding to do testing.

      I've attached screen shot for my code, result and actual open price from yahoo finance.

      I also attached my backtest parameters screen shot too.
      Attached Files

      Comment


        #4
        Logosguru,

        Can you give me an export of the Strategy? File -> Utilities -> Export NinjaScript -> Select your Strategy

        You will need to attach the .Zip which be located in (My) Documents -> NinjaTrader 7 -> bin -> Custom -> ExportNinjaScript

        The full code you have posted would not expect to work as I do not see any indication of the BuySellSignal being set other than 0
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Please see attached file.

          Thanks
          Attached Files

          Comment


            #6
            Logosguru,

            I am getting expected behavior with the backtest.

            This is due to the setting for CalculateOnBarClose always being set to true in the Historical data, because we only know the Open, High, Low, Close, and Volume data points and not what happened intrabay.

            With this setting when a bar closes, it will run OnBarUpdate(), process any orders such as your market orders which are filled at the open price of the next bar. This is why you are seeing them one bar "late". Additionally, if the bar is two or more bars later then this would be with with the logic of the code not being true to submit orders.

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

            Comment


              #7
              Thanks for your reply.

              So for the historical backtesting, there is no way in NT to simulate buy or sell on market open price ?

              Is it correct?

              Comment


                #8
                Logosguru,

                There is.

                You need to use an Intrabar Granularity technique to the code.
                Essentially adding an underlying data series for 1 tick.

                I have attached a link below on how to use this Intrabar Granularity for backtesting.
                http://www.ninjatrader.com/support/f...ead.php?t=6652
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  I Got it.
                  One more question for intrabar Granularity.

                  So.. What is the bar combination for market open price?
                  For example, 1 tick for primary and 1 minute for secondary bar?

                  Comment


                    #10
                    Logosguru,

                    You would want to have the 1 tick as the secondary. Any primary time interval you select in the Strategy Analyzer will add an underlying data series for 1 tick.

                    This is so you have the strategy use the regular time interval but calculate on each tick.
                    Cal H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    110 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    59 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    37 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    41 views
                    0 likes
                    Last Post TheRealMorford  
                    Started by Mindset, 02-28-2026, 06:16 AM
                    0 responses
                    78 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Working...
                    X