简体   繁体   English

如何使用 pine-script 中的时间戳函数获取昨天的日期

[英]how to get yesterday date using timestamp function in pine-script

endDate=timestamp("UTC+5:30",year,month,dayofmonth, 15,30,00) endDate=timestamp("UTC+5:30",year,month,dayofmonth, 15,30,00)

this line gives me an output of"current year - current month - today date 15:30:00".这一行给了我“当前年份 - 当前月份 - 今天日期 15:30:00”的输出。 how can I get yesterday date, so that it will keep on update yesterdays date dynamically in future also?我怎样才能获得昨天的日期,以便它将来也能动态地更新昨天的日期?

study("temp",overlay=true)
startDate=input(title="Start 
Date",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 this code runs my result is [enter image description here][1] [1]: https://i.stack.imgur.com/qFn6O.png but I don't want to print the label for the current day(i just want to print the label up to the previous day only)how can I achieve that如果此代码运行我的结果是[在此处输入图像描述][1] [1]:https://i.stack.imgur.com/qFn6O.png 但我不想打印当天的标签(我只想将标签打印到前一天)我怎样才能做到这一点

new_day = change(time("D")) != 0

yyear = valuewhen(new_day, year[1], 0)
ymonth = valuewhen(new_day, month[1], 0)
yday = valuewhen(new_day, dayofmonth[1], 0)

yesterdays_ts = timestamp(yyear, ymonth, yday, 15, 30)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM