Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time exit not working

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

    Time exit not working

    Hello,

    On my automated strategies I usually have a time exit condition, to exit the trade shortly before market close. The problem I have is that sometimes it seems to work, and other times it does not, and uses the normal exit on close logic instead.

    For example, today I had a live strategy running on the 6B, with the following exit logic:

    // Condition set 5
    if (ToTime(Time[0]) == ToTime(13, 55, 0))
    {
    ExitLong("", "");
    }

    However when time reached 13:55+, the strategy did not exit as programmed. It was only at 13:59:30, 30 seconds before market close, that the strategy took itself out, which again was the normal "exit on close" logic, not the programming. What I don't understand is that all of these strategies use that same code, and sometimes it works, and sometimes it does not. Can you think of any reason why it wouldn't trigger randomly?

    Regards,

    Andrew

    #2
    Hi Andrew, what chart type / timeframe do you run this code on? Time[0] is the bar timestamp so there could be cases where the logic would not be triggered as for example on non time based charts the stamp would not be exactly this time to resolve.

    Comment


      #3
      These are on 1 minute charts/time frames.

      Comment


        #4
        I see, you could still not see a time stamp for this time, for example if there not sufficient trading to see a trade / tick, the bar would be staying open until that closing / new open tick happened. If you check your charts, is there a timestamp to trigger this condition?

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          I see, you could still not see a time stamp for this time, for example if there not sufficient trading to see a trade / tick, the bar would be staying open until that closing / new open tick happened. If you check your charts, is there a timestamp to trigger this condition?
          Okay I think I see what you're saying -- if I look at a chart now, there is a 13:54 bar and the next bar is 13:56, so no 13:55 bar....so I gather what you're saying is that if there are no trades during the 13:55 time period, then nothing appears in the system to actually register that time, or create a time stamp, and thus there is no 13:55 time stamp for the exit logic to operate on. Is that more or less correct?

          Comment


            #6
            That is correct in understanding Andrew, and the reason for your 'random' logic trigger.

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              That is correct in understanding Andrew, and the reason for your 'random' logic trigger.
              Ok that makes sense -- I didn't realize there had to be a trade and a time stamp for the logic to realize it was time to exit, but now I see why that would be the case. At least the exit on close logic still works when the time exit fails, to prevent holding overnight. Thanks for the clarification.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              103 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              52 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              34 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              36 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              73 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X