Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Re: How to buy the open and sell the close

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

    Re: How to buy the open and sell the close

    Hello,
    I new to the forum and NinjaTrader. I'm trying to create a strategy that simply buys at the daily open and sells at that same daily bar's close. I'm aware that "EnterLong()" executes a market order that buys at the following day's opening price, but I don't know how to sell at that same bar's closing price. If I use "ExitLong" it exits the long position at the "next" day's open and not at the same day's closing price.

    #2
    JayNice, I've already responded in your other thread here. If you have another question, just ask.
    AustinNinjaTrader Customer Service

    Comment


      #3
      I want to exit at the close of the same day the order was entered. If I entered a long position 2 wks ago with no particular sell conditions "ExitOnClose=true" would liquidate at "today's" close which would be 2 wks later. I want to liquidate the position at the close of the same day the order was executed...
      Last edited by JayNice; 07-07-2009, 11:39 AM.

      Comment


        #4
        I'm not sure we're on the same page. What type of charts are you using? If you're running this on Daily bars, ExitOnClose cancels all open orders and closes positions before the day ends.
        AustinNinjaTrader Customer Service

        Comment


          #5
          I'm running this in Strategy Analyzer. All I want to do is back test a strategy that buys at the open and sells at the close of the "same bar". It makes no difference what the buy and sell conditions are. Again, the only thing I'm interested in is buying at open and selling at the close of the same bar.
          Last edited by JayNice; 07-07-2009, 12:48 PM.

          Comment


            #6
            JayNice, you can try adding detail to your strategy and backtesting it with intraday granularity.
            Last edited by NinjaTrader_Austin; 07-07-2009, 01:15 PM.
            AustinNinjaTrader Customer Service

            Comment


              #7
              Here's the code that I'm running in Strategy Analzyer. When this code is ran it goes long at the opening price of the first bar that meets the criteria of condition statement, then it exits the long position at the final day of the price series. I want to exit at the close of the same day that the long position was established.

              protected override void OnBarUpdate()
              {
              // NOTE: I'm using daily price when I run this in Strategy Analyzer.
              // If today's close > perious days high buy tomorrow at the market.
              // I want to exit at the close of the same bar that the trade was entered.

              if(Close[0]>High[1])
              {
              EnterLong();
              }

              }

              ps. I have "ExitOnClose=true" within the Initialize() method...

              Comment


                #8
                We just posted at the same time, please see my post #6.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  yeah sure, your a world of help! thanks for everything, typical tech support!!!!!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by judysamnt7, 03-13-2023, 09:11 AM
                  4 responses
                  59 views
                  0 likes
                  Last Post DynamicTest  
                  Started by ScottWalsh, Today, 06:52 PM
                  4 responses
                  36 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by olisav57, Today, 07:39 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post olisav57  
                  Started by trilliantrader, Today, 03:01 PM
                  2 responses
                  21 views
                  0 likes
                  Last Post helpwanted  
                  Started by cre8able, Today, 07:24 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post cre8able  
                  Working...
                  X