Turn of month

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #212674 quote
    HannesA
    Participant
    Senior

    Hello

    I wounder if someone could help with code for this turn of month strategy?

    Does multitimeframe solve the problem to buy at close with daily bars?

    Entry conditions for TOM
    Buy from the 18th trading day of the month and 4 days ahead if the closing price is lower than yesterday.

    Exit condition for TOM
    The strategy sells on the first day after the end of the month if the profit is at least 1%, alternatively on the 6th trading day regardless of the profit.

    Thanks for a great forum!

    #213307 quote
    robertogozzi
    Moderator
    Master

    You want to buy on or after the 18th trading day of each month AND 4 days ahead or IF 4 days ahead… (provided the closing price of the 4th prior day is lower than the closing price of the 5th prior day)?

    #213319 quote
    HannesA
    Participant
    Senior

    I want to buy on or after the 18th trading day of each month and 4 days ahead if the closing price is lower then yesterday.
    Example 18th trading day, close today higher then yesterday, no entry.
    19th trading day, close today lower than yesterday, entry.

    #213331 quote
    robertogozzi
    Moderator
    Master

    There you go:

    DEFPARAM CumulateOrders = False
    ONCE DayCount = 0
    ONCE Tally    = 0
    IF Month <> Month[1] THEN
       DayCount = 0
       Tally    = 0
       IF OnMarket AND ((PositionPerf * 100) >= 1) THEN
          SELL at Market
       ENDIF
    ENDIF
    DayCount = DayCount + 1
    IF (DayCount = 6) AND OnMarket THEN
       SELL at Market
    ENDIF
    IF DayCount = 18 THEN
       Tally = Tally + 1
    ENDIF
    IF Not OnMarket AND (Tally > 0) AND (Tally <= 4) THEN
       BUY 1 Contract at Market
    ENDIF
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Turn of month


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
HannesA @hannesa11 Participant
Summary

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

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