Login Page - Create Account

Support Board


Date/Time: Mon, 19 May 2025 16:42:34 +0000



[User Discussion] - Automatic date exclusion of Rollover week from Charts

View Count: 721

[2024-01-27 18:49:08]
User61168 - Posts: 442
Hello SC users,

I am wondering if anyone has a solution to automatically exclude the Monday-Friday dates of rollover >> expiration week. Per this link from CME https://www.cmegroup.com/trading/equity-index/rolldates.html , I do not want to trigger trades from Monday to Friday whenever the rollover date kicks and until the contract is expired.

p.s. I am aware of the manual "exclude dates" feature of SC. I am hoping to include a universal logic in my automated strategy (either via simple alert or spreadsheet formula) to stop trading for these specific 5*4 days each year.

Edit: Basically, I am trying to have any positive or negative effects of "Continuous Contract" setting of SC by excluding these days in my backtest results.
Date Time Of Last Edit: 2024-01-27 18:50:49
[2024-01-27 19:04:06]
User61168 - Posts: 442
Here's a pseudo code in Excel:

=IF(AND( OR(MONTH(NOW())=3,MONTH(NOW())=6,MONTH(NOW())=9,MONTH(NOW())=12),"check if current week is 3rd week of the month"), "Do not Trade","Continue to Trade")

Trying to figure out how to code this in SC platform??
Date Time Of Last Edit: 2024-01-27 19:04:15
[2024-01-28 02:17:20]
Sawtooth - Posts: 4217
This will return the week number in each month:
=WEEKNUM(A3)-WEEKNUM(DATE(YEAR(A3),MONTH(A3),1))+1

This will return the month of the year:
=MONTH(A3)

This will return TRUE in the 3rd week of the months of Mar, Jun, Sep, Dec:
=AND(OR(MONTH(A3)=3,MONTH(A3)=6,MONTH(A3)=9,MONTH(A3)=12),WEEKNUM(A3)-WEEKNUM(DATE(YEAR(A3),MONTH(A3),1))+1=3)
[2024-01-28 02:42:52]
User61168 - Posts: 442
Thanks Tom. What should I use for A3 ?
[2024-01-28 02:53:18]
Sawtooth - Posts: 4217
What should I use for A3 ?

I would put the formula in J28, so when it's TRUE, autotrading is disabled.

Why not use A3?
A3 is the bar's datetimestamp, but if you want something more granular, use J41 instead.

J41 is the last chart update's datetimestamp.
[2024-01-28 03:03:19]
User61168 - Posts: 442
Thanks. I am using only simple alerts :-) BARDATE should work I think in place of A3
Date Time Of Last Edit: 2024-01-28 03:06:38
[2024-01-28 03:07:09]
Sawtooth - Posts: 4217
Thanks. I am using only simple alerts :-)
Oh, sorry.

Use BARDATE, or BARDATETIME

There is no Simple Alerts equivalent for J41.
[2024-01-28 03:08:33]
User61168 - Posts: 442
Thanks Tom. I appreciate your help as always!
[2024-01-28 03:23:04]
User61168 - Posts: 442
Sorry Tom. I have one more question. How do I check the symbol name in spreadhsheet formula study? something like... IF(LEFT(??,2)="ES",0,IF(LEFT(??,2)="NQ",....
Date Time Of Last Edit: 2024-01-28 03:23:21
[2024-01-28 04:31:19]
Sawtooth - Posts: 4217
How do I check the symbol name in spreadhsheet formula study?
These are the only available Base Graph Identifiers in Simple Alerts:
Study/Chart Alerts And Scanning: Available Main Price Graph Identifiers/Variables
The symbol is not one of them.
Additionally, the Spreadsheet Formula study cannot return text.
(Despite its name, the Spreadsheet Formula study is not a spreadsheet study, and furthermore not all spreadsheet functions are supported.)

All 3 spreadsheet studies have the symbol in cell J40.
Based on your questions in the thread, the level of sophistication of your system is pushing the limits of Simple Alerts.
This might be a good time to move up to the Spreadsheet System for Trading study.

But if you want a workaround, you could number each symbol:
- Add the Spreadsheet Study study, and Hide the study.
- Set the Number of Rows to 40.
- Put something like this in cell K3:
=IF(LEFT($J$40,2)="ES",1,IF(LEFT($J$40,2)="NQ",2,...
- Then reference SG1 of this spreadsheet study.
(Column K is SG1)
[2024-01-28 04:37:16]
User61168 - Posts: 442
Thanks Tom. This workaround would work for me. I appreciate it.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account