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 qwertyjjj, Today, 06:52 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by NeverDownMoney, 09-25-2020, 09:40 PM
    1 response
    13 views
    0 likes
    Last Post NT-Roland  
    Started by wjadevries, Today, 04:21 AM
    1 response
    10 views
    0 likes
    Last Post wjadevries  
    Started by butt_toast, Yesterday, 01:16 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by jjanguda, 12-22-2017, 10:37 AM
    3 responses
    910 views
    0 likes
    Last Post NinjaTrader_Jason  
    Working...
    X