Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Set time to close position

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

    Set time to close position

    Hello

    This is in reference to historical back testing.

    I would like to close my position at 12.30 (pacific time).

    I am using range candles and the time stamp used is the open of the bar. If the bar that signals the closing of the strategy opened at 11.30am but does not close till 1.00pm the next bar open time is 1pm so the close is at 1pm.

    I tried setting the closing time between 12.00pm and 12.30pm but there are still instances where the bar is outside that time frame.

    I have seen posts to hard code a secondary time series for the close time (1 min bar).
    Is there a way I can do this with the strategy builder?

    Is it possible to change the "exit on session close" parameters in the strategy analyzer? Changing the end session time for the instrument seems to affect the chart.

    I have also tried setting the strategy to "on each tick" I thought this might work since I have tick data available but it does not. The other problem with that solution is it would affect the entry.

    Thank you

    #2
    Hi sdauteuil, thanks for your post.

    Range bars will always have these unpredictable time stamps, so the extra series is required. Unfortunately, the code would need to be unlocked to access a secondary time frame in a strategy. We have an example strategy on limiting by time variables here:

    https://ninjatrader.com/support/help...to_limit_t.htm

    Kind regards,

    -ChrisL
    Last edited by NinjaTrader_ChrisL; 03-22-2020, 11:39 AM. Reason: spelling

    Comment


      #3
      Thanks

      In a live environment would the close order trigger based off the "clock" or would it still be looking for the time stamp on the bar?


      Comment


        #4
        Hi sdauteuil, thanks for your follow up.

        When the strategy is running in real-time (live or sim account) you can access DateTime.Now, and that will give you the PC time down to the millisecond. If the strategy is running OnBarClose you will the Time[0] timestamp will be the close time of the bar.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        25 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        120 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 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