PineScript = 如何在 sell/buy 信号出现之前不显示第 2-n 次出现的 buy/sell 信号的 plotshape?
PineScript = How to not display the 2nd-nth occurrence of plotshape of buy/sell signal until the sell/buy signal occur?
只有那些用黄色圈起来的信号才是预期的
study(title="ALMA", overlay=true)
alma = alma(close, 9, 0.85, 6)
plot(alma, title="ALMA", color=color.yellow, linewidth=2)
ema50 = ema(close,50)
plot(ema50, title="EMA", color=color.fuchsia, linewidth=2)
A = close > alma
B = close < alma
var S_sell = false
var S_buy = false
if (A)
S_sell := true
S_buy := false
if (B)
S_Sell := false
S_buy := true
plotshape(A,text="Buy",style=shape.flag,size=size.small,offset=0,color=color.green,textcolor=color.green,location=location.belowbar)
plotshape(B,text="Sell",style=shape.flag,size=size.small,offset=0,color=color.red,textcolor=color.red,location=location.abovebar)
您可以使用 barssince() 函数设置为 1。
//@version=4
study(title="ALMA", overlay=true)
alma = alma(close, 9, 0.85, 6)
ema50 = ema(close,50)
plot(alma, title="ALMA", color=color.yellow, linewidth=2)
plot(ema50, title="EMA", color=color.fuchsia, linewidth=2)
A = close > alma
B = close < alma
plotshape(barssince(A)==1,text="Buy",style=shape.flag,size=size.small,offset=0,color=color.green,textcolor=color.green,location=location.belowbar)
plotshape(barssince(B)==1,text="Sell",style=shape.flag,size=size.small,offset=0,color=color.red,textcolor=color.red,location=location.abovebar)
只有那些用黄色圈起来的信号才是预期的
study(title="ALMA", overlay=true)
alma = alma(close, 9, 0.85, 6)
plot(alma, title="ALMA", color=color.yellow, linewidth=2)
ema50 = ema(close,50)
plot(ema50, title="EMA", color=color.fuchsia, linewidth=2)
A = close > alma
B = close < alma
var S_sell = false
var S_buy = false
if (A)
S_sell := true
S_buy := false
if (B)
S_Sell := false
S_buy := true
plotshape(A,text="Buy",style=shape.flag,size=size.small,offset=0,color=color.green,textcolor=color.green,location=location.belowbar)
plotshape(B,text="Sell",style=shape.flag,size=size.small,offset=0,color=color.red,textcolor=color.red,location=location.abovebar)
您可以使用 barssince() 函数设置为 1。
//@version=4
study(title="ALMA", overlay=true)
alma = alma(close, 9, 0.85, 6)
ema50 = ema(close,50)
plot(alma, title="ALMA", color=color.yellow, linewidth=2)
plot(ema50, title="EMA", color=color.fuchsia, linewidth=2)
A = close > alma
B = close < alma
plotshape(barssince(A)==1,text="Buy",style=shape.flag,size=size.small,offset=0,color=color.green,textcolor=color.green,location=location.belowbar)
plotshape(barssince(B)==1,text="Sell",style=shape.flag,size=size.small,offset=0,color=color.red,textcolor=color.red,location=location.abovebar)