Compilation errorCE10101

Fix CE10101: `if` condition must evaluate to `bool`

Make the `if` condition return an explicit Boolean value. Pine Script v6 does not implicitly convert numeric values to `bool`, so an integer returned by `ta.change(dayofmonth)` cannot control the block directly. Compare it with zero, use another Boolean expression, or apply the appropriate `na` test. Here, `change != 0` states the intended new-day condition without relying on legacy conversion.

This link opens the Pine Script AI Coding Agent overview. It does not run or change code on this page.

Before and after

Make the smallest reviewable change

Both artifacts include the version declaration and the code needed to inspect the stated problem. The diff lists the lines that change between them.

Broken code.pine
//@version=6
indicator("Boolean condition demo")
int change = ta.change(dayofmonth)
bool isNewDay = false
if change
    isNewDay := true
plot(isNewDay ? 1 : 0)
Fixed code.pine
//@version=6
indicator("Boolean condition demo")
int change = ta.change(dayofmonth)
bool isNewDay = false
if change != 0
    isNewDay := true
plot(isNewDay ? 1 : 0)
Diff.pine
--- broken.pine
+++ fixed.pine
@@
-if change
+if change != 0

Root causes

  • A numeric value is used directly where Pine v6 requires a `bool`.
  • A v5 script relied on implicit numeric-to-Boolean conversion before migration.
  • A function returns `int`, `float`, or another type instead of the intended condition.

How the fix was verified

Method
Pineify UAT grammar checker via check-pine-script-grammar.mjs
Broken result
Returned the Boolean-condition diagnostic at line 5.
Fixed result
Returned no grammar diagnostics.
Limit
The comparison compiles and expresses a nonzero change. Confirm that this is the intended event condition.

Bring the actual script, not just the message

Open the Coding Agent overview to paste editable Pine Script, explain the intended behavior, and request a review. Compile and test the result in TradingView before using it.

Paste your code to fix this error