wookoii
wookoii

Reputation: 11

I want to compare the values in Pinescript

aaaaa= (close>= open[1] and close [1] < open[1] and close [1] < open[1]> (close>= open[1] and close [1] < open[1]) 

I want to write code so that this code is established.

//@version=5
indicator('test', overlay=true)
bullishCandle = close >= open[1] and close[1] < open[1]  //and high >= high[1] and low <= low[1]
bearishCandle = close <= open[1] and close[1] > open[1]  //and high > high[1] and low < low[1]

aaaaa = (close >= open[1] and close[1] < open[1])[1] > (close >= open[1] and close[1] < open[1])
//Error Message : Cannot call 'operator >' with argument 'expr0'='call 'operator SQBR' (series bool)'. An argument of 'series bool' type was used but a 'simple float' is expected.

Upvotes: 0

Views: 190

Answers (1)

vitruvius
vitruvius

Reputation: 21342

You should use some parentheses so that it is more readable for you and anyone else.

You have this below statement:

(close >= open[1] and close[1] < open[1])[1] > (close >= open[1] and close[1] < open[1])

By looking at the parentheses, we can group this statement into two.

A = (close >= open[1] and close[1] < open[1])[1]

and

B = (close >= open[1] and close[1] < open[1])

So, you are essentially doing A > B.

Now, the result of A will be a bool. And the result of B will also be a bool.

So, the expression bool > bool does not make any sense and that's what the compiler is telling you. You cannot compare two bool variables.

Upvotes: 1

Related Questions