Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Exit Code

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

    Time Exit Code

    I'm using the Strategy Builder with time limits. I want all open trades to exit at a specific time. How do I write that code? Thanks.

    #2
    Hello Fran888,

    Thanks for your post.

    You could create a Time Filter or Time Comparison in your script to limit when the strategy places trades.

    For example, you could create a Time Filter condition in your script and call your entry order methods so the script only places entry orders during that timeframe.

    Then, you could add a Time Comparison condition to to if the time is a specific time and check to see if you are in a Long market position and then call ExitLong(). Or, you could create a Time Comparison condition in your script and check to see if you are in a Short market position and then call ExitShort().

    The Exit On Session Close strategy property could also be used to have the strategy cancel all strategy generated orders on all strategy instruments and close all open strategy positions at the close of ANY session for multi-time frame/multi-instrument strategies.

    The Exit On Session Close property could be set in the 'Default properties' screen of the Strategy Builder under 'More properties'.

    IsExitOnSessionCloseStrategy determines if the strategy will cancel all strategy generated orders on all strategy instruments and close all open strategy positions at the close of ANY session for multi-timeframe/multi-instrument strategies. The number of seconds before the actual session end time is determined by the number of seconds set for ExitOnSessionCloseSeconds.

    ExitOnSessionCloseSeconds is calculated based on the Trading Hours End of Day property set in the strategy's Trading Hours template. Trading Hour Templates are set up to contain the session start and end times of a specific market or instrument.​

    See the help guide documentation below for more information.

    How to create Time Filters or Time Comparisons: https://ninjatrader.com/support/help...on_builder.htm
    Default Properties screen: https://ninjatrader.com/support/help...er_screens.htm
    Exit On Session Close: https://ninjatrader.com/support/help...sestrategy.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    33 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    64 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