buy at open in a specific day and sell after 2 days at close

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #182068 quote
    gGabbo
    Participant
    New

    Hallo everyone, I’m new to this program and I didin’t find the button to search into the forum.

    As the title I would like to buy on the 27 of every month at the opening and sell after 2 days at the end of the day.

    The other days I’ll go to fish 🙂

    thanks in advance

    #182069 quote
    robertogozzi
    Moderator
    Master

    The attached screenshot showswhere the search box is (it opens whenever you hover your pic).

    What shall it do when the 27th is on a holiday?

    And what if the next two days is past the end of the month?

    #182070 quote
    robertogozzi
    Moderator
    Master

    Moreover, ProOrder is the support forum for strategy, as from the basic rules highlighted in yellow below.

    I moved it from ProBuilder.

    Thank you 🙂

    #182072 quote
    robertogozzi
    Moderator
    Master

    I forgot the screenshot.

    x-10.jpg x-10.jpg
    #182076 quote
    gGabbo
    Participant
    New

    Thanks Roberto, the problem about the holiday, If so I don’t buy. If after 2 days ther is holiday or there is another month, I’ll prefer to skip this buy.

    #182539 quote
    robertogozzi
    Moderator
    Master

    There you go (I tested it on DAX, Daily TF):

    TimeFrame(Daily,UpdateOnClose)
    If OpenMonth <> OpenMonth[1] Then
       OM      = OpenMonth
       OD      = OpenDay
       ODW     = OpenDayOfWeek
       OY      = OpenYear
       LastDay = 31
       If OM = 4 or OM = 6 or OM = 9 or OM = 11 Then
          LastDay = 30
       Endif
       If OM = 2 Then
          LastDay = 28
          If OY mod 4 = 0 Then
             If OY mod 100 = 0 Then
                If OY mod 400 = 0 Then
                   LastDay = 29
                Endif
             Else
                LastDay = 29
             Endif
          Endif
       Endif
       EOM      = OD      //EOM=End Of Month
       EntryDay = 0       //Day to enter a trade
       ExitDay  = 0       //Day to exit the trade opened on EntryDay
       FOR i = OD + 1 To LastDay
          ODW = ODW + 1
          IF ODW = 7 THEN
             ODW = 0
          ENDIF
          IF ODW <= 5 THEN
             IF (i = 27) AND (i + 2) <= LastDay THEN
                EntryDay = i
             ELSIF (i >= (EntryDay + 2)) AND (ExitDay = 0)  AND (EntryDay <> 0) THEN
                ExitDay  = i
             ENDIF
          ENDIF
       NEXT
    ENDIF
    //
    Timeframe(default)
    IF ((OpenDay >= ExitDay) OR (OpenMonth <> OpenMonth[1])) AND LongOnMarket Then
       SELL AT Market
    Endif
    //
    If (OpenDay = EntryDay) AND (ExitDay > 0) AND Not OnMarket Then
       BUY 1 contract at Market
    Endif
    //graph OpenMonth
    //graph ExitDay
    //graph EntryDay
    //graph LastDay
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

buy at open in a specific day and sell after 2 days at close


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
gGabbo @ggabbo Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/22/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...