• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

End of session

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

    End of session

    Hello,

    I would like to call ExitLongLimit() function 10 minutes before end of session.

    Is there any example for this?

    Sincerely,kobi

    #2
    Hello levikNT,

    Thank you for your note.

    You could use the following to exit through a market order x number of seconds before the close,
    https://ninjatrader.com/support/help...oseseconds.htm

    If you wanted to submit a limit order however, you would have to run the strategy with calculate set to OnEachTick, so that you compare the current time to the session close time minus 10 minutes. If you did not want to run the strategy with calculate set to OnEachTick, you could submit your exit call within OnMarketData, however that would be more complicated.

    I do not have any samples of what you’re looking to do however I can provide the following sample which will add a certain amount of seconds to the time an entry order is filled, then in OnBarUpdate, if the bar time is greater than the current time, exit the trade. You could create a datetime object which is equal to 10 minutes before the close and modify the attached sample, which should do what you're looking to do.

    Please let us know if you need further assistance or if you’d like us to reach out with a list of third parties that would be interested in building this for you.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_AlanP View Post
      Hello levikNT,

      Thank you for your note.

      You could use the following to exit through a market order x number of seconds before the close,
      https://ninjatrader.com/support/help...oseseconds.htm

      If you wanted to submit a limit order however, you would have to run the strategy with calculate set to OnEachTick, so that you compare the current time to the session close time minus 10 minutes. If you did not want to run the strategy with calculate set to OnEachTick, you could submit your exit call within OnMarketData, however that would be more complicated.

      I do not have any samples of what you’re looking to do however I can provide the following sample which will add a certain amount of seconds to the time an entry order is filled, then in OnBarUpdate, if the bar time is greater than the current time, exit the trade. You could create a datetime object which is equal to 10 minutes before the close and modify the attached sample, which should do what you're looking to do.

      Please let us know if you need further assistance or if you’d like us to reach out with a list of third parties that would be interested in building this for you.
      Hello Alan,

      What if the chart doesn't get any "ticks" few minutes before market closes, in this case - the only way to exit the market would be to use timer with custom event?

      Could you please show a sample how to use timer to properly exit let's say at 15:59:30 each day (even if the OnBarUpdate doesn't get triggered because of lack of ticks coming in)?

      Thanks

      Comment


        #4
        Hello music_p13,

        You could have the time checked in OnMarketData, which is triggered by any change in Bid/Ask or Last.

        I put together and attached a sample which allows the user to specify the close time, and upon starting the strategy a long position will be taken. After time has passed the user inputted time in the UI, the position will be closed.

        Whats nice about this sample is that you can run the strategy with Calculate On Bar Close, because the time if statement is in OnMarketData.

        Please see OnMarketData section of our helpguide,
        https://ninjatrader.com/support/help...marketdata.htm

        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_AlanP View Post
          Hello music_p13,

          You could have the time checked in OnMarketData, which is triggered by any change in Bid/Ask or Last.

          I put together and attached a sample which allows the user to specify the close time, and upon starting the strategy a long position will be taken. After time has passed the user inputted time in the UI, the position will be closed.

          Whats nice about this sample is that you can run the strategy with Calculate On Bar Close, because the time if statement is in OnMarketData.

          Please see OnMarketData section of our helpguide,
          https://ninjatrader.com/support/help...marketdata.htm

          Please let us know if you need further assistance.
          Thanks, that is a nice alternative instead of using timer since there is a very high chance that bid/ask/last data will change even if no tick has occurred.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sergey_z, Today, 03:42 AM
          2 responses
          8 views
          0 likes
          Last Post sergey_z  
          Started by U0000999, Today, 04:24 AM
          0 responses
          4 views
          0 likes
          Last Post U0000999  
          Started by lehula, 01-18-2019, 08:13 PM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Hiromichi, Yesterday, 08:55 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by imalil, Yesterday, 04:49 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X