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

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
    Chris L.NinjaTrader Customer Service

    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.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X