dayofmonth - PineScript Variable
dayofmonth
Section titled “dayofmonth”Overview
Section titled “Overview”The day number of the month, in the exchange time zone, calculated from the bar’s opening UNIX timestamp.
intQualifier
Section titled “Qualifier”series
Remarks
Section titled “Remarks”- The value is based on the bar’s open. Overnight sessions may return the previous calendar day on the first session bar.
- Combine with
time_tradingdayto align bars to the trading day rather than the calendar timestamp. - Use numeric comparisons (
dayofmonth == 1) to detect monthly session boundaries.
Example
Section titled “Example”//@version=5indicator("Month boundary highlight", overlay=true)
isFirstDay = dayofmonth != dayofmonth[1]
bgcolor(isFirstDay ? color.new(color.purple, 82) : na, title="First day of month")
plotshape(isFirstDay, style=shape.labeldown, text=str.tostring(dayofmonth), color=color.new(color.purple, 0), textcolor=color.white)