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

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


        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
        }



        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 cmtjoancolmenero, Yesterday, 03:58 PM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by benmarkal, Yesterday, 12:52 PM
          3 responses
          23 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by helpwanted, Today, 03:06 AM
          1 response
          19 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          11 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          244 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Working...
          X