Pinescript 条件语句绘图

Pinescript conditional statement plotting

我正在尝试根据以下条件为图表创建图表:

  1. 这是连续第二个在 9 日均线上方开盘的绿柱
  2. RSI 超卖

我有问题是什么顺序写条件,知道我需要多少个括号?

strategy(title="Swing Strat", pyramiding=1, overlay=true, default_qty_value=2, default_qty_type=strategy.fixed, initial_capital=100, currency=currency.GBP)


//plotting MA lines
MAPeriod9 = input(9, title="9 MA Period")
MA9 = sma(close, MAPeriod9)
MAPeriod180 = input(180, title="180 MA Period")
MA180 = sma(close, MAPeriod180)

plot(MA9, color=color.blue, linewidth=1)
plot(MA180, color=color.red, linewidth=1)

// creating the RSI
rsiSource = input(title="RSI Source", type=input.source, defval=close)
rsiLength = input(title="RSI Length", type=input.integer, defval=14)

rsiOverbought = input(title="RSI Overbought Level", type=input.integer, defval=70)
rsiOversold = input(title="RSI Oversold Level", type=input.integer, defval=30)

//get RSI value
rsiValue = rsi(rsiSource, rsiLength)
isOverbought = rsiValue >= rsiOverbought
isOversold = rsiValue <= rsiOversold

//checking to see if the bars close over 9 day MA line
MAcrossover = crossover(close, MA9)
entrypoint = barssince(MAcrossover)

//marking the second green bar to open above the SMA line
tradingsignal = ((entrypoint==1 and MA9<open and open<close and open[1]<close[1]) and isOversold)
plotshape(tradingsignal, title="Entry Trigger", location=location.abovebar, color=color.red, transp=0, style=label.style_xcross, text="Entry Point")

您的条件没有错误。在您的情况下,您可以删除所有括号。 将最后一行中的样式参数更正为以下style=shape.xcross。 如果您在图表上没有看到任何带有 Entry Point 的标签,请增加超卖参数的值。