• 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

Exit on Close

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

  • NinjaTrader_Jesse
    replied
    Hello Kentoes,

    The OnStateChange override only triggers when the state happens, this will only happen a few times during the scripts life cycle (Use a Print to see this). Additionally the IsExitOnSessionCloseStrategy property can only be set during states SetDefaults and Configure:
    https://ninjatrader.com/support/help...nCloseStrategy

    If you were relying on a user input you could use State.Configure to gather the input and set the property like you have shown. If you are using later states, require price data or OnBarUpdate that will not work.


    I look forward to being of further assistance.

    Leave a comment:


  • Kentoes
    started a topic Exit on Close

    Exit on Close

    Some conditions in my strategy call for exiting on close, other times they don't.
    I'm starting out with
    Code:
    IsExitOnSessionCloseStrategy                = false;
    And I'm switching it on under OnStateChange()

    Code:
    if ( conditions )
                        {
                        IsExitOnSessionCloseStrategy = true;    
                        }
    My question is how reliable will this be as I'm unclear on when OnStateChange() will fire? I'm sure there are other coding workarounds to exit on close, but this seemed to be the simplest.

Latest Posts

Collapse

Topics Statistics Last Post
Started by DTSSTS, Today, 01:26 PM
0 responses
5 views
0 likes
Last Post DTSSTS
by DTSSTS
 
Started by RFrosty, Today, 01:20 PM
0 responses
13 views
0 likes
Last Post RFrosty
by RFrosty
 
Started by Newtrader101, Today, 12:59 PM
4 responses
12 views
0 likes
Last Post Newtrader101  
Started by Bmatarese, Today, 11:08 AM
1 response
17 views
0 likes
Last Post NinjaTrader_Heath  
Started by aligator, Today, 11:16 AM
3 responses
12 views
0 likes
Last Post NinjaTrader_Heath  
Working...
X