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.
    BertrandNinjaTrader Customer Service

    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?
        BertrandNinjaTrader Customer Service

        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.
            BertrandNinjaTrader Customer Service

            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 alifarahani, Today, 09:40 AM
              6 responses
              36 views
              0 likes
              Last Post alifarahani  
              Started by Waxavi, Today, 02:10 AM
              1 response
              17 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by Kaledus, Today, 01:29 PM
              5 responses
              14 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Waxavi, Today, 02:00 AM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by gentlebenthebear, Today, 01:30 AM
              3 responses
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X