Login Page - Create Account

Support Board


Date/Time: Wed, 05 Feb 2025 22:47:45 +0000



Study Alert Question

View Count: 733

[2020-04-06 07:52:06]
kasabo - Posts: 27
Is it possible to reference the first week of the current month via Spreadsheet formula or preferably by color bar based alert condition study?
I could not construct it by using WEEKNUM function defined here https://www.sierrachart.com/index.php?page=doc/SpreadsheetFunctions.html#SerialDateTimeValues.
Thank you.
Date Time Of Last Edit: 2020-04-06 07:56:28
[2020-04-06 12:55:33]
Sawtooth - Posts: 4167
This returns the week number of the 1st of the month, and its value is persistent until the 1st of the subsequent month:
WEEKNUM(DATE(YEAR(BARDATE),MONTH(BARDATE),1))

So to get the 1st week of the month, compare it to the previous bar:
=WEEKNUM(DATE(YEAR(BARDATE),MONTH(BARDATE),1))<>WEEKNUM(DATE(YEAR(BARDATE[-1]),MONTH(BARDATE[-1]),1))

The spreadsheet formula would look like this:
=WEEKNUM(DATE(YEAR(A3),MONTH(A3),1))<>WEEKNUM(DATE(YEAR(A4),MONTH(A4),1))

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

Login

Login Page - Create Account