Close open positions before the weekend

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #212169 quote
    phoentzs
    Participant
    Master
    if time >= 220000 and dayofweek=5 then
    sell at market
    exitshort at market
    endif

    I use this code on all my systems to close open positions on Friday evening. From time to time, however, systems with open positions are still held over the weekend. So, for whatever reason, the code didn’t work. Positions are then closed at market open on Sunday evening and systems halted. I still haven’t figured out why that is. It doesn’t matter which TF. It affects M1, M5 and M15 systems. Always completely sporadic.

    Is there another way to close open positions?

    Or is it the time? Maybe too close at the market close?

    #212172 quote
    JS
    Participant
    Senior

    I think it’s indeed due to the time, right on the closure… It can (sporadically) happen that you can no longer even lose your market orders…

    Taking into account your longest time frame, for example 15 minutes, you can try:

    If Time >= 214500 and …

    phoentzs thanked this post
    #212173 quote
    PeterSt
    Participant
    Master
    What if there are no buyers during that one hour remaining ? Edit : Oh, I see that JS just said similar.
    phoentzs thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Close open positions before the weekend


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
phoentzs @phoentzs Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by PeterSt
2 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/27/2023
Status: Active
Attachments: No files
Logo Logo
Loading...