Support Board
Date/Time: Mon, 23 Jun 2025 08:37:44 +0000
[Programming Help] - ASCIL - excluding Saturday, Sunday and/or weekend data
View Count: 835
[2022-03-01 10:26:57] |
User92573 - Posts: 563 |
Dear Support Is there a simple way "function" that will allow me to exclude weekend data from a study such as in the Daily OHLC study which offers: a) Exclude Saturday data b) Exclude Sunday data I note that several years ago a thread said this was being considered. Ideally something like the "Daily OHLC" Study but with the addition of a Start time and End Time for intraday. Many thanks. Date Time Of Last Edit: 2022-03-01 10:47:08
|
[2022-03-01 11:49:08] |
1+1=10 - Posts: 270 |
Yes, use SCDateTime::GetDayOfWeek Working with the SCDateTime Variables and Values: GetDayOfWeek() You probably need something like what is below: if(sc.BaseDateTimeIn[sc.Index].GetDayOfWeek() == SATURDAY || sc.BaseDateTimeIn[sc.Index].GetDayOfWeek() == SUNDAY ) { return; // Don’t process any weekend bars } Date Time Of Last Edit: 2022-03-01 11:49:50
|
[2022-03-01 15:41:04] |
User92573 - Posts: 563 |
Hi, thank you for the reply. That's what I'm using in my Auto-loop code but for some reason I just cannot seem to get it to work in the same way in the Manual-loop version. Clearly it's me, as IsSaturday, IsSunday and the above otherwise works fine. Thank you for the assistance, I'll have to explore manual looping further. |
[2022-03-01 15:57:37] |
User92573 - Posts: 563 |
It just a study to show the High/Low for the current selected timeframe using a start-time, end-time and an option to exclude weekend data. I've used the "HighLowForTimePeriod" study as a template so should be very straightforward but for some reason I'm struggling with the Weekend section even though my Autoloop test using "if(sc.BaseDateTimeIn[sc.Index].GetDayOfWeek() == SATURDAY || sc.BaseDateTimeIn[sc.Index].GetDayOfWeek() == SUNDAY)" works fine. |
[2022-03-01 16:38:47] |
1+1=10 - Posts: 270 |
HighLowForTimePeriod implements manual looping using the for-loop below. Inside that for-loop you need to put the if statement, along with the other relevant code; you likely need: NOTE: "Index" in below for loop refers to the bar index being processed by your code. In automatic looping a different bar, referred to by sc.Index is processed for every call of your study. In manual looping on the other hand you need a loop such as below and you can process as many bars as you want for each call of your study. Yes, check out the docs: Working with ACSIL Arrays and Understanding Looping: Manual Looping/Iterating for (int Index = sc.UpdateStartIndex; Index < sc.ArraySize; Index++) { // Other code if (YourInputToControlExcludingWeekendData.GetYesNo()) { if(sc.BaseDateTimeIn[Index].GetDayOfWeek() == SATURDAY || sc.BaseDateTimeIn[Index].GetDayOfWeek() == SUNDAY ) { continue; } } // Other code } Date Time Of Last Edit: 2022-03-01 16:39:48
|
[2022-03-01 18:04:41] |
User92573 - Posts: 563 |
Thank you I'll sit down with it again tomorrow and see if I can solve it. That's very helpful. Many thanks |
[2022-03-01 18:25:26] |
1+1=10 - Posts: 270 |
Good luck!
|
To post a message in this thread, you need to log in with your Sierra Chart account: