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:

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X