Pine 脚本编码。我正在使用一个变量 long_above ,它在 if 块内是 defiend 。我收到错误 - 未声明的标识符 'long_above'

问题描述 投票:0回答:1

我的代码如下。任何人都可以编辑我的代码以便我可以编译

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nibedit2irtmtc

//@version=5
indicator("My script", overlay = true)

if high[2] > high[3]
    if low[3] > low[2]
        long_above=high[2]

if high[2]>high[1]
    if low[2]<low[1]
        short_below=low[2]

plotshape(ta.crossover(close, long_above),style = shape.triangleup)
pine-script pine-script-v5 trading algorithmic-trading
1个回答
0
投票

 //@version=5
indicator("My script", overlay = true)
float long_above = na
float short_below= na
if high[2] > high[3]
    if low[3] > low[2]
        long_above:=high[2]

if high[2]>high[1]
    if low[2]<low[1]
        short_below:=low[2]

plotshape(ta.crossover(close, long_above),style = shape.triangleup)
© www.soinside.com 2019 - 2024. All rights reserved.