Trueglory
Trueglory

Reputation: 3

'while' is not a valid type keyword in variable declaration

I'm getting

'while' is not a valid type keyword in variable declaration

for the first while declaration and I have no clue why.

I'm trying to have a plot show until the price has crossed it (horizontal line) twice. So all of this as a condition of a valuewhen() statement. I've just started with pine script on trading view. It's hard to find ways of doing exactly what you want, so I'm just trying to learn the basics/syntax so I can do it my own ways. (which might not be most efficient at first)

while_loop(z) =>
    var bool x = true
    var bool y = true
    while y
        while x
            if close = z
                x := false
        if close = z
            y := false

Upvotes: 0

Views: 2214

Answers (1)

vitruvius
vitruvius

Reputation: 21139

while loops are added in v5 so make sure you are using v5.

Also, in your if checks, you want to do if close == z.

Upvotes: 1

Related Questions