Search code examples
pine-scriptpine-script-v5

Maximum number of output series (64) was reached or not but with the same number of plot functions? How to understand this?


I have ~64 plot functions and practically don't add more. But their the colors are connected to Boolean variables. For example if the Boolean variable is true then the color is red but if false then its green (or sometimes transparent, fill functions have the main role then).

The interesting is,

  • If I say BooleanVariable = false then we don't exceed that limit of 64.
  • If I say BooleanVariable = true then again, we don't exceed that limit of 64.
  • But if I say BooleanVariable = some_boolean_math_expression the result of which is sometimes true, sometimes false, then whoops; limit is exceeded.

I am confused because the expression may return with true or false, one of the other cases when the limit is not exceeded. It's like the script hates math (returning with true or false values) but accepts direct declarations of true or false values.

Is it a bug? Or a strange but understandable logic somehow?


Solution

  • Using boolean expressions results in the output being an additional output series. For example if you use a boolean expression to define the color of a plot then it results in two of the 64 limit being used, even though only one plot() is used.

    c = close > open
    plot(close, color = c ? color.green : color.red)