在我的 PineScript 中,我想绘制(每天 - 包括当前交易时段),如果盘中高点出现在盘中低点之前(反之亦然)。
您可以使用
varip
关键字来跟踪栏内操作。然后只需更新您的日内高点和低点即可。您可以使用 time
内置变量来查看该事件发生的时间,然后比较这些时间以查看哪个事件先发生。
//@version=5
indicator(title="bar color", overlay=true)
is_new_day = timeframe.change("D")
varip day_high = high
varip day_high_time = time
varip day_low = low
varip day_low_time = time
if (is_new_day) // Reset variables if it is a new day
day_high := high
day_high_time := time
day_low := low
day_low_time := time
else
if (high > day_high) // New high
day_high := high
day_high_time := time
if (low < day_low) // New low
day_low := low
day_low_time := time
// Compare day_high_time and day_low_time
// Plot whatever you want