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
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.