How to tell sunday trading is over - using expand last?

Dear users, TJ
I need your help on the following query:

I am using expand last to compress intraday (hourly) bars to daily bars. I also use start of the bar time stamp and use version 6.39 of Amibroker.

If I am trading S&P500 and the market closes at 21:00 London time, then I will be able to have new entry price at 22:00 since using expand last ensures that OHLC arrays are updated when there is a 21:00 bar in the database (in database settings, I am closing the day @ 21:00 and using day/night times to compress data).

The point to be careful is to ensure that there is a bar @ 21:00 for S&P500 so that Amibroker understands that the day is over.

The problem arises on the weekends when market opens at 23:00 on Sunday and there is no bar at 21:00 for S&P500 to remind Amibroker that the Sunday trading is closed at 21:00. The issue is happening only on weekends because on week days there is always a bar @21:00 to remind Amibroker market is closed but not on Sundays.

At the moment, entry prices are updated at 00:00 on Sundays when there is a bar in database for 23:00. The question is since S&P500 does not trade on Sundays, how can I tell Amibroker Sunday trading is over at 21:00?

One option is to enter a manual data bar at 21:00 on Sundays using OHLC as close price from Friday. This solves this issue but I wanted to have any suggestions you may have perhaps there is an easier solution I am missing here.

Many thanks,
Alp

It is hard to provide the answer to such formulated question (without formula, see: How to ask a good question)

I can only give you very general (and generic) answer, you can just detect in the code that there is a Sunday (using DayOfWeek function) and time is after 21:00 (using TimeNum function) and simply block any signal generation in that time.

block = DayOfWeek() == 0 /* it is sunday */  AND TimeNum() > 210000;
1 Like

Hello TJ,
This suggestion actually works well.
Many thanks,
Alp

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.