• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Always Exits on Close regardless of settings

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

    Strategy Always Exits on Close regardless of settings

    Hi,

    I Have a simple ninja trader 8 script generated from a template.

    In OnStateChange() function I set IsExitOnSessionCloseStrategy to false.

    However in the strategy analyzer it always closes my position at the end of the session. I do not want this. I want the position to remain in effect even if the ninja trader strategy is not running. (will this be different in real time settings versus backtesting?)

    Also a way to stop running the strategy while not closing positions in code would also be helpful.

    Thanks!

    #2
    Thanks for your post TrevorC and welcome to the forums!

    In OnStateChange() under State.SetDefaults, the default value for the IsExitOnSessionCloseStrategy property can be set. Upon enabling the strategy, the user can set this property as they wish.

    When testing with the SampleMACrossover strategy in the Strategy Analyzer, we can see that when we test with Exit On Session Close set to true, we get multiple exits on the session close. With the property set to false, we can see that there is one Exit On Session close to close the open position at the end of the backtest. We can expect to see this one Exit On Session close when the Strategy Analyzer backtest ends with an open position.

    It is possible to close a strategy programmatically and it is also possible to override the CloseStrategy() behaviors. If you override this method and do not call base.CloseStrategy(), the strategy positions will not be closed. Publicly available documentation on CloseStrategy() can be found below.

    CloseStrategy() - https://ninjatrader.com/support/help...sestrategy.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ralett, Today, 07:29 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by bboyle1234, Today, 10:46 PM
    0 responses
    1 view
    0 likes
    Last Post bboyle1234  
    Started by swcooke, Today, 04:29 PM
    0 responses
    4 views
    0 likes
    Last Post swcooke
    by swcooke
     
    Started by bboyle1234, Today, 04:27 PM
    0 responses
    2 views
    0 likes
    Last Post bboyle1234  
    Started by swcooke, Today, 03:31 PM
    2 responses
    11 views
    0 likes
    Last Post swcooke
    by swcooke
     
    Working...
    X