Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Prevent to enter new positions after ExitOnSessionCloseSeconds

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

    Prevent to enter new positions after ExitOnSessionCloseSeconds

    Hello,

    There is an example here but it calculates OnEachTick.

    NinjaTrader Community, A common inquiry is that the Exit on close didn't work in a NinjaScript Strategy because there is a position after the exit on close should have occurred. When viewing the log we often find that the Exit on close does indeed exit the position shortly before the end of the session (based on the Exit on


    Can anyone provide an example of how this should be implemented OnBarClose in a simple manner ?

    For instance how can this be done if a variable stores the CurrentBar or resets a bool when ExitOnSessionCloseSeconds is called, so that no new orders can be open after this bar is reached or the bool is reset? Or if it's easier, how to reset a bool just before X seconds prior session close? Some examples will be appreciated.


    #2
    Hello roblogic,

    Thanks for your post.

    You can use a time filter in your code that only places trades within a specified time period, thus avoiding the issue entirely. The following example is written with Calculate.OnBarClose.

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    29 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    46 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X