fixed exit at the end of the month

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #257633 quote
    theunpredictable
    Participant
    New

    Hi,


    I am looking for a solution that allows me to display entries on a daily basis at the open and exits at the close. The close should always take place on the last day of the month. If it does not work on a daily basis, I can also switch to a smaller time unit. Are there any solutions for this?


    Thanks in advance


    Greets Björn

    #257647 quote
    robertogozzi
    Moderator
    Master

    This code will enter at the opening of each new day and will close at the end of the day.

    If you want to close at a different time, just let me know.

    It must be used on an intraday timeframe:

    Timeframe(Daily,default)
    IF abs(CountOfPosition) = 0 THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    //
    Timeframe(default)
    IF Day <> Day[1] THEN
       SELL AT MARKET
    ENDIF
    
    #257701 quote
    theunpredictable
    Participant
    New

    Thanks for your reply Roberto!


    If do it like that it doesn’t work:



    Timeframe(Daily,default)

    IF abs(CountOfPosition) = 0 and day >20 and day<26 THEN

    BUY 1 CONTRACT AT MARKET

    ENDIF

    //

    Timeframe(default)



    IF Day <> Day[1] THEN

    SELL AT MARKET

    ENDIF


    In the picture you can see that the exit is on 26. of January not at the end of mont per close.

    Do you have an idea why?


    Timeframe is 1H.


    Thank you.




    Timeframe(Daily,default)
    IF abs(CountOfPosition) = 0 THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    //
    Timeframe(default)
    IF Day <> Day[1] THEN
       SELL AT MARKET
    ENDIF
    







    #257852 quote
    robertogozzi
    Moderator
    Master

    Try this version:

    Timeframe(Daily,default)
    IF abs(CountOfPosition) = 0 and day >20 and day<26 THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    //
    Timeframe(Monthly,default)
    IF Month <> Month[1] THEN
       SELL AT MARKET
    ENDIF
    
    #258129 quote
    justisan
    Participant
    Junior

    hi Björn, can you define mathematically „end of the month“? so definition is valid 10 (or 1000) years into the past – and also into the future?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

fixed exit at the end of the month


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by justisan
3 hours, 43 minutes ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/07/2026
Status: Active
Attachments: No files
Logo Logo
Loading...