Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trades opening after ExitOnSessionCloseSeconds

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

    trades opening after ExitOnSessionCloseSeconds

    I discovered in certain cases when a position is closed due to the ExitOnSessionCloseSeconds setting, it appears that sometimes an opening trade condition happens to be true and so the strategy immediately opens a new trade the very next second. I'd rather it waited till the next session. Is that not enforced by ExitOnSessionClose behind the scenes?

    I've tried controlling it myself with logic that looks like this:

    /// Market Hours Filter
    //
    DateTime t = DateTime.Now;
    bool tradeable = t > Convert.ToDateTime("4:00:00 PM") || t < Convert.ToDateTime("2:00:00 PM") ? true : false; /// 2pm - 2:30pm closing only
    if (!tradeable) Print("Prepping day end. Closing only"); /// control in openTrades section

    ​But it seems that doesn't work when running replay I believe perhaps because DateTime.Now grabs the current time instead of the time from the market replay. Is there another way?

    Mark
    Last edited by markdshark; 06-12-2023, 12:03 PM.

    #2
    Hello, thanks for writing in. The session time is always defined by the Session Template, so it would be possible for the strategy to enter another order after exiting from the session close signal. The DateTime.Now will not work because this will always reference your computer's clock. The Time[] array would need to be used to read the timestamps coming from the Playback connection. One would need to make a time filter so that the strategy only trades during a certain time. There is an example on how to make this here:

    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by defa0009, 12-13-2024, 09:19 AM
    21 responses
    209 views
    1 like
    Last Post marcus2300  
    Started by ttrader23, Today, 04:48 PM
    0 responses
    6 views
    0 likes
    Last Post ttrader23  
    Started by wisdomspoon, Today, 03:50 PM
    3 responses
    15 views
    0 likes
    Last Post rockmanx00  
    Started by Mountain_cast, 02-10-2025, 11:14 PM
    2 responses
    19 views
    0 likes
    Last Post Mountain_cast  
    Started by Robotman, Today, 01:06 PM
    2 responses
    37 views
    0 likes
    Last Post Robotman  
    Working...
    X