How to get the date time?

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

    Buy the stock a few trading days before the end of the month.

    Hold the position through the final trading days of the month and the first few trading days of the next month.


    How to get the date?



    #265844 quote
    thomas2004chthomas2004ch
    Participant
    Senior

    Close the position after the predefined trading window, then wait for the next month-end.

    #265847 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    To buy a stock a few days before the end of the month, say on the 20th, you must buy on the 20th, or one or more days later if the 20th was on a weekend or a holiday:

    IF Not Onmarket AND ((Day = 20) OR ((Day > 20) AND (Day[1] < 20))) THEN
       BUY at Market
       TradingStart = Day
    ENDIF
    // To exit AFTER 4 Days
    IF OnMarket AND ((Day - TradingStart) >= 4) THEN
       SELL at Market
    ENDIF
    


    Iván González and thomas2004ch thanked this post
    #265848 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    The code above closes the trade after 4 days have elapsed, but some of those days can be NON trading-days, such as weekends and holidays. To make sure it’s 4 trading days, days must be tallied this way:

    IF Not Onmarket AND ((Day = 20) OR ((Day > 20) AND (Day[1] < 20))) THEN
       BUY at Market
       TradingCount = 0
    ENDIF
    // tally days as they go by
    IF day <> day[1] THEN
       TradingCount = TradingCount + 1
    ENDIF
    // To exit AFTER 4 Days
    IF OnMarket AND (TradingCount = 4) THEN
       SELL at Market
    ENDIF
    
    thomas2004ch thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

How to get the date time?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
17 hours, 24 minutes ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/26/2026
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...