Vignesh A
Vignesh A

Reputation: 1

how to plot labels up to yesterday not for current day in pine-script

study("temp",overlay=true)
startDate=input(title="StartDate",type=input.time,defval=timestamp("01 Jan 2000 09:15:00 
  UTC+5:30"))
// newDay=change(time("D"))!= 0
// _year=valuewhen(newDay,year[1],0)
// _month = valuewhen(newDay, month[1], 0)
// yday = valuewhen(newDay, dayofmonth[1], 0)
// yesterdays_ts = timestamp(_year, _month, yday, 15, 30)
endDate=timestamp("UTC+5:30",year,month,dayofmonth, 15,30,00)
labelSession=input(title="Time session to analysis",type=input.session,defval="0915-1525")
inSession(sess)=> na(time(timeframe.period,sess + ":23456")) == false 
  and time >= startDate and time<= endDate 
  dayLow()=>security(syminfo.ticker,"D",low,lookahead=true)
if inSession(labelSession) and not inSession(labelSession)[1]  
   label.new(bar_index,dayLow()-20,"Hello",style=label.style_label_left,
   textalign=text.align_left,color=#d0cec2,textcolor=color.black)

if I run my code I am getting output like this"out put image" but I want to print the label up to yesterday only how to achieve that

Upvotes: 0

Views: 340

Answers (1)

Bharat Gawande
Bharat Gawande

Reputation: 21

isToday = true
if year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time) 
    isToday := false

Upvotes: 2

Related Questions