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 cmtjoancolmenero, Yesterday, 03:58 PM
    9 responses
    35 views
    0 likes
    Last Post cmtjoancolmenero  
    Started by DayTradingDEMON, Today, 09:28 AM
    4 responses
    23 views
    0 likes
    Last Post DayTradingDEMON  
    Started by geddyisodin, Yesterday, 05:20 AM
    9 responses
    50 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by George21, Today, 10:07 AM
    1 response
    15 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by Stanfillirenfro, Today, 07:23 AM
    9 responses
    24 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X