【问题标题】:Pine Script outputting weird for loop errorPine 脚本输出奇怪的循环错误
【发布时间】:2023-03-27 21:58:01
【问题描述】:

除循环外,一切正常。它一直在输出奇怪的错误:

脚本无法翻译自:for i = 1 to 10

study("RSI Below 25.3", overlay=true)


rsiValue = rsi(close, 14)
rsiValLow= rsi(low, 14)
x =low[1]


//for i = 1 to 10
//    if x > low[i]
//        x := low[i]   
            

isDivergent = abs(x-low[0])/low[0]*100 < .05 and abs(x- rsiValLow[0])>=1.5

isRsiOS = rsiValue <= 25

//plot signals to chart
plotshape(isRsiOS, title="Oversold", location=location.belowbar, transp=0, style=shape.triangleup, text="Buy")
plotshape(isDivergent, title="Divergence", location=location.belowbar, transp=0, style=shape.triangleup, text= "Divergence" )

我已经为此工作了一段时间,但无法弄清楚为什么它不起作用。你能帮忙吗?

谢谢!

【问题讨论】:

  • 在这个问题上您还需要帮助吗?

标签: for-loop pine-script


【解决方案1】:

如果你需要找到最小值,那么最好用函数lowest替换循环。

//@version=4
study("Help (RSI Below 25.3)", overlay=true)


rsiValue = rsi(close, 14)
rsiValLow= rsi(low, 14)

//x = low[1]

// for i = 1 to 10
//     if x > low[i]
//         x := low[i]   

x = lowest(low[1], 10)  // to replace the cycle          

isDivergent = abs(x-low[0])/low[0]*100 < .05 and abs(x- rsiValLow[0])>=1.5

isRsiOS = rsiValue <= 25

//plot signals to chart
plotshape(isRsiOS, title="Oversold", location=location.belowbar, transp=0, style=shape.triangleup, text="Buy")
plotshape(isDivergent, title="Divergence", location=location.belowbar, transp=0, style=shape.triangleup, text= "Divergence" )
//plot(x)

【讨论】:

    【解决方案2】:

    我不见了:

    //@version=4

    仅此而已,没有其他问题了,问题就到此结束了

    【讨论】:

      猜你喜欢
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-13
      • 2014-01-06
      • 2016-03-07
      相关资源
      最近更新 更多