3

I'm trying to create a new study in tradingview using Pine Script.

isCurrentMonth = month(timenow) == month(time)
plot(isCurrentMonth ? close : na)

This piece of code could help me display for current month, but I want to display only for current day.

Thanks for any help!

PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
Pugazh
  • 9,453
  • 5
  • 33
  • 54

1 Answers1

13

I managed to come up with a solution. Hope it could help someone.

isToday = false

if year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time) 
    isToday := true
Pugazh
  • 9,453
  • 5
  • 33
  • 54
  • You can also use the built-in time() function. Here is the ref: https://www.tradingview.com/pine-script-docs/en/v4/essential/Sessions_and_time_functions.html – Pugazh Mar 12 '20 at 00:26