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

Exits

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

    Exits

    I am using LongExit() and ShortExit(). Both of these open or close a position once my criteria is met but on the open of the following day. How do I get these exits to fire immediately upon reaching a certain price level?

    #2
    Hello cfree5119,

    Thank you for your post.

    Using 'CalculateOnBarClose = false' you can ensure your exit condition is sent immediately. CalculateOnBarClose is called within the Initialize() method.
    When using 'CalculateOnBarClose = true' if your condition is met the order is submitted to the next bar after the condition.

    For information on CalculateOnBarClose please visit the following link: http://www.ninjatrader.com/support/h...onbarclose.htm

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

    Comment


      #3
      What if I wanted to enter my long position the following day but exit the position immediately? How would I distinguish between the two?

      Comment


        #4
        Or does it have to apply to both entries and exits?

        Comment


          #5
          Hello cfree5119,

          Thank you for your response.

          You can separate your logic to either calculate on bar close or on every incoming tick. For a reference sample please visit the following link: http://www.ninjatrader.com/support/f...ad.php?t=19387

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

          Comment


            #6
            I am running into issues with CalculateOnBarClose = false; It is not exiting my position immediately. Does this work for historical trades placed? See my attached setup. It is false in my code as well.
            Attached Files

            Comment


              #7
              Hello cfree5119,

              Thank you for your post.

              Unfortunately, CalculateOnBarClose = false will not work with historical data. When indicators or strategies are running on historical data, OnBarUpdate() is only called on the close of each historical bar even if this property is set to false. This is due to the fact that with a historical data set, only the OHLCVT of the bar is known and not each tick that made up the bar.

              For more information on CalculateOnBarClose please visit the following link: http://www.ninjatrader.com/support/h...onbarclose.htm

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

              Comment


                #8
                With that information is has knowledge of the range. If the stop is within a given range is there a way for it to execute at it's stop price regardless the incoming tick or how it would normally be executed with present market conditions? SO the stop would fire at the price so long as it is contained in the range. I am just trying to make my backtests as accurate as possible. Thank you.

                Comment


                  #9
                  cfree5119, to simulate this with more accuracy, you would need add a finer intraday series here that would offer more testing resolution, you could then submit your orders to this finer series in backtesting - http://www.ninjatrader.com/support/f...ead.php?t=6652
                  BertrandNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by arvidvanstaey, Today, 02:19 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post arvidvanstaey  
                  Started by mmckinnm, Today, 01:34 PM
                  3 responses
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by f.saeidi, Today, 01:32 PM
                  2 responses
                  5 views
                  0 likes
                  Last Post f.saeidi  
                  Started by alifarahani, 04-19-2024, 09:40 AM
                  9 responses
                  55 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by Conceptzx, 10-11-2022, 06:38 AM
                  3 responses
                  60 views
                  0 likes
                  Last Post NinjaTrader_SeanH  
                  Working...
                  X