'How can I display a label on the bar at the same time the day before with PineScript? (1-minute data)
How can I display a label on the bar at the same time the day before with PineScript?
BTCJPY (BITFLYER) and XAUUSD (oanda) 1-minute data are used.
There is no error when adding this indicator to the chart. image 1
However, when the 1-minute data is updated, the following script error occurs. image 2
"Pine cannot determine the referencing length of a series. Try using max_bars_back"
Please help me how to solve it.
//@version=5
indicator(title="after same time the day before", overlay=true)
var int targetBars = 0
MS_IN_1D = 1000 * 60 * 60 * 24
sameTimeTheDayBefore = timenow - time < MS_IN_1D
targetBars := sameTimeTheDayBefore ? targetBars + 1 : targetBars
bgcolor(sameTimeTheDayBefore?#0050FF40:color(na), offset=-1)
v1 = label.new(bar_index-targetBars, high, yloc=yloc.abovebar, color=color.yellow, text="Same time the day before")
// if barstate.islast
// v1
// label.delete(v1[1])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
