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 Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          4 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Started by alifarahani, Today, 09:40 AM
          6 responses
          40 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          19 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X