从 pinescript 中的某个时间戳开始绘制系列

时间:2021-05-29 09:03:32

标签: pine-script

有没有办法从某个时间戳开始绘制系列(即 ema(close,some_period) )?
我知道 plot() 中有“show_last”参数,但我不知道如何计算从时间戳到现在 show_last 有多少条是整数?

谢谢!

1 个答案:

答案 0 :(得分:0)

这将从特定日期/时间开始绘制 EMA

//@version=4
study("My Script", overlay = true)

tz = 0 //timezone
timeadj = time + tz * 60 * 60 * 1000 //adjust the time (unix)
t1 = timeadj >= timestamp(2021, 04, 19, 0, 0) ? 1 : 0 //get the starting time

ema = ema(close, 50)
ema_1 = t1 ? ema :na //start ema from the timestamp
plot(ema_1)

barss = barssince(t1 != t1[1]) //get the bars since timestamp
// plot(barss)