• 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

Save position overnight

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

    Save position overnight

    Dear support,

    I continue programming on ninjatrader and for the current moment I can't find the answer for my next question: Is it possible to open position at the END of trading day, and then close it at the START of the next trading day, and then continue execution of my main strategy logic depending of how much money I earned or lost after that night trade?
    Thank you for your help in advance!

    #2
    Hello AlexFdv,
    To assist you further may I know are you trying to backtest your straegy or testing it in real time/market replay.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_Joydeep,
      I'm going to trade real time, but it would be great to have possibility make some backtesting as well.

      Comment


        #4
        Hello AlexFdv,
        Thanks for the clarification.

        Yes, you can submit the entry order at the last bar of the session using the below unsupported code.
        Code:
        Bars.LastBarOfSession
        You can also find the session end time using the below code
        Code:
        Bars.Session.GetNextBeginEnd
        http://www.ninjatrader.com/support/h...xtbeginend.htm

        You can close your trade at the day open on the next day by using the below code.
        Code:
        if (FirstTickOfBar && Bars.FirstBarOfSession)
        {
           //do something
        }
        http://www.ninjatrader.com/support/h...ttickofbar.htm
        http://www.ninjatrader.com/support/h...rofsession.htm

        However you will not be able to backtest it, since in backtest the orders are submitted at the end of the bar. Thus the order evaluated on the end of the session will be submitted on the next days opening bar in backtest.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Joydeep,

          Thank you for great explanation.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by tecmisc1, Today, 09:57 AM
          0 responses
          2 views
          0 likes
          Last Post tecmisc1  
          Started by mbesha, Today, 09:26 AM
          0 responses
          1 view
          0 likes
          Last Post mbesha
          by mbesha
           
          Started by Brillo, Today, 08:58 AM
          0 responses
          4 views
          0 likes
          Last Post Brillo
          by Brillo
           
          Started by avrege, Today, 01:48 AM
          2 responses
          13 views
          0 likes
          Last Post avrege
          by avrege
           
          Started by markbb10, Today, 07:14 AM
          0 responses
          7 views
          0 likes
          Last Post markbb10  
          Working...
          X