Auto find time when exchange open and close?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #234593 quote
    George_Lager
    Participant
    New

    Hi

    Doing some back testing and always running into summer, winter time and holidays problems, as I do my buy and sell with time when he exchange opens or closes for the day.

    Is there any automatic function in PRT so I can buy exactly when the exchange opens and sell before it closes?

    Also I check values from previous period, aka the day before when doing the buy, so the script must run exactly the first period it opens otherwise I dont get the value from the previous day.

     

    Thank you all

    #234636 quote
    Iván González
    Moderator
    Master

    Hi,
    You could work with intradaybarindex variable or with time.
    For example, with 5 minutes timeframe in USA stocks you have 77 bars each day. You can ask the system open new position if your conditions are met when intradaybarindex=77. With this sentence the system will open in the next bar open (next day).
    You can instead use time.

    if not onmarket and time>153000 then
    buy 1 contract at market
    endif
    
    if onmarket and time=215500 then
    sell at market
    endif 

    Note: Exit at the end of the day is not possible because PRT evaluate the conditions at the close of the bar. the solution is to work with smaller timeframes.

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

Auto find time when exchange open and close?


Platform Support: Charts, Data & Broker Setup

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
1 year, 7 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 06/30/2024
Status: Active
Attachments: No files
Logo Logo
Loading...