0

Using Pine v6, I get an error on line 2 that I don't understand.

float bar_hh = ta.highest(2) float bar_h1 = ta.dev(bar_hh, 2) ? na : bar_hh 

bar_hh is float.

Still, the error I get is complaining about some boolean that doesn't exist : "Cannot call "operator ?:" with argument "expr0"="call "ta.dev" (series float)". An argument of "series float" type was used but a "simple bool" is expected."

The Pine doc says that ta.dev expects a float as parameter.

Please, what am I doing wrong?

1
  • 3
    The error message is referring to the left side of the ? operator. It expects a Boolean, but the result of ta.dev is a series of floats. Commented Oct 3 at 19:00

1 Answer 1

0

ternary operator ? : expect a bool expression before "?"
ta.dev(bar_hh, 2) - returns float, not a bool
so make smth like that

float bar_h1 = ta.dev(bar_hh, 2) > 0 ? na : bar_hh 

or

float bar_h1 = ta.dev(bar_hh, 2) != 0 ? na : bar_hh 

or any bool expression you need

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.