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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X