例
//@version=5
indicator('plot date', overlay=true)
p(t) =>
if time < timestamp(t) + 60*60*18*1000 and timestamp(t) + 60*60*18*1000 < time + 60*60*24*1000
label.new(bar_index, high, "", color=color.new(color.white, 90))
p("2023-05-02")
p("2023-05-03")
- マウスカーソルをのせたときにツールチップを表示する場合
//@version=5
indicator('plot date', overlay=true)
p(t, tooltip) =>
if time < timestamp(t) + 60*60*18*1000 and timestamp(t) + 60*60*18*1000 < time + 60*60*24*1000
label.new(bar_index, high, "", color=color.new(color.white, 90), tooltip = tooltip)
p("2023-05-08", "ツールチップ1")
p("2023-05-03", "")
- 矢印の形を変える
indicator('plot date', overlay=true)
p(t, buysell, hovermessage) =>
if time < timestamp(t) + 60*60*18*1000 and timestamp(t) + 60*60*18*1000 < time + 60*60*24*1000
if buysell == "L"
label.new(bar_index, low, buysell, color=color.new(color.lime, 80), textcolor=color.new(color.white,90), tooltip = hovermessage, yloc=yloc.belowbar, style=label.style_arrowup)
else
label.new(bar_index, high, buysell, color=color.new(color.red, 80), textcolor=color.new(color.white,90), tooltip = hovermessage, yloc=yloc.abovebar, style=label.style_arrowdown)
p("2023-05-08", "L", "ロングの根拠")
p("2023-05-03", "S", "ショートの根拠")
配列を使う場合
//@version=5
indicator('plot date', overlay=true)
t(my_array) =>
for i = 0 to array.size(my_array)-1 by 1
if time < array.get(my_array,i) and array.get(my_array,i) < time + 60*60*24*1000
label.new(bar_index, high, '', color=color.new(color.white, 95))
my_array = array.new_int(10, timestamp("2023-05-02"))
array.push(my_array, timestamp("2023-05-03"))
array.push(my_array, timestamp("2023-04-03"))
array.push(my_array, timestamp("2023-05-01"))
t(my_array)