松树 - 将第二个柱标记为在 sma 线上方打开

Pine - labelling the second bar to open above the sma line

我是 pine 的新手,我正在尝试在 sma 线上方打开的第二个柱上放置一个标签。

这是我目前得到的:

study(shorttitle = "SMA - ST1", title="Simple Moving Average", overlay=true) 

MAPeriod = input(9, title="MA Period")
MA = sma(close, MAPeriod)

plot(MA, color=color.blue, linewidth=1)

MAcrossover = crossover(close, MA)
entrypoint = barssince(MAcrossover == 2)

if MAcrossover and entrypoint
    lun1 = label.new(bar_index, na, 'entrypoint', 
      color=color.red, 
      textcolor=color.red,
      style=label.style_xcross, size=size.small)
    label.set_y(lun1, entrypoint) 

任何关于使用最佳逻辑的建议都会很有帮助。

study(shorttitle = "SMA - ST1", title="Simple Moving Average", overlay=true) 

MAPeriod = input(9, title="MA Period")
MA = sma(close, MAPeriod)

plot(MA, color=color.blue, linewidth=1)

MAcrossover = crossover(close, MA)
entrypoint = barssince(MAcrossover)
//greenbarcount = barssince(close > open)

if entrypoint==2 and MA<open and open<close and open[1]<close[1]
    lun1 = label.new(bar_index, high, 'entrypoint', 
      color=color.red, 
      textcolor=color.red,
      style=label.style_xcross, size=size.small)