Skip to content

dayofmonth - PineScript Variable

The day number of the month, in the exchange time zone, calculated from the bar’s opening UNIX timestamp.

int

series

  • 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_tradingday to align bars to the trading day rather than the calendar timestamp.
  • Use numeric comparisons (dayofmonth == 1) to detect monthly session boundaries.
//@version=5
indicator("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)