Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Restore closed position on market open

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

    Restore closed position on market open

    Hi Support!

    I am looking to avoid associated costs of holding a position overnight but still want a position to be in the direction of the last signal.

    In the pic below you will see that the strategy exits on session close. How can I get the strategy to automatically reenter the position as soon as the market reopens, based on the last signal?

    #2
    Hello TrendFollowingCapital,

    Thanks for your post.

    You could use a bool variable that is true or false that you set when you place your orders. For example, call the bool LastTradeLong. When you place a long order set the bool to true. When you place a short order set the bool false. The last placed order would provide the direction that the bool is set.

    Then using the system bool Bars.IsFirstBarOfSession to detect the first bar and using the bool LastTradeLong, place your entry order, for example:

    if (Bars.IsFirstBarOfSession)
    {
    if (LastTradeLong)
    {
    EnterLong();
    }
    else
    {
    EnterShort();
    }
    }


    Reference: https://ninjatrader.com/support/help...rofsession.htm

    Comment


      #3
      Any updates?

      Comment


        #4
        Hello JonasZweig,

        Thanks for your post.

        Can you clarify what update you are looking for?

        Did you post in the wrong thread?

        Comment


          #5
          Hi Paul

          Thank you for your response, now as this is an AUTOMATED strategy it's not as if I choose if there is a long or short entry at session close, it is just the last signal given before session close that will determine whether a long or short position is valid on session open, so how do I make sure that the last signal, whether long or short, will open on session open?

          Comment


            #6
            Hello TrendFollowingCapital,

            Thanks for your reply.

            The reply I provided in post 2 was based on your using a strategy, perhaps I was adding confusion by saying "When you place a long order set the bool to true. When you place a short order set the bool false." What I should have stated was, when the strategy places a long order, in the same code block as the order, set the bool to true. When the strategy places a short order, set the bool to false. The last entry placed by the strategy then controls the state of the bool.

            In Post 2 I showed example code that the strategy could use to enter a new trade at the first bar of the new session and would be in the same direction as the last trade of the prior session.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            50 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            127 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            69 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X