Pine script coding. I am using a variable long_above which is defiend inside the if block. I am getting error-Undeclared identifier 'long_above'

Advertisements

My code is given below. Can anyone edit my code so that I can be compiled

    // 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)

>Solution :


 //@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)

Leave a ReplyCancel reply