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

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
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by alifarahani, Today, 09:40 AM
    6 responses
    39 views
    0 likes
    Last Post alifarahani  
    Started by Waxavi, Today, 02:10 AM
    1 response
    18 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    15 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