How does PineScript parse 'if series1 > series2'?

Viewed 86

I'm trying to figure out how some of the code I've found written in PineScript works.

It's like this:

C_BlackBody = open > close
C_EngulfingBearish = C_UpTrend and C_BlackBody [...]
if C_EngulfingBearish
    [do something...]

What I wanted to do was put out the value of close. open and close are both series, meaning that C_BlackBody and C_EngulfingBearish are too. However, C_EngulfingBearish can successfully be used in an if statement, so it's acting like a single boolean. Yet if I try to concatenate it into a string, it says it's still a series:

debugInfo := "Close: " + close

Gives the error:

Cannot call 'operator +' with arguments (literal string, series[float]);

So what is close, C_EngulfingBearish, and other series being evaluated as when used in an if statement, and how can this be transferred into a string so I can output it in a label as debug info?

1 Answers

C_EngulfingBearish is a series of Boolean values so it can be used in the condition of the operator if. Use the function tostring to convert to string.

debugInfo := "Close: " + tostring(close)

Read Tips for Debagging

Related