How to debug Pine Script in TradingView
Save a personal copy in Pine Editor and add it to the chart. Open Pine Logs from the editor or script menu after adding log calls. Work on a small bar interval so the relevant messages remain easy to find. This workflow starts after compilation succeeds; a compiler error requires a syntax fix before these observations are available.
- Record the exchange-qualified symbol, timeframe, chart type, session, inputs, Pine version, and failing bar timestamp with its timezone.
- State the expected value or condition on that bar and the actual value. A missing marker alone does not identify the failed calculation.
- Expose every operand of the final condition. For a compound condition, inspect each boolean separately as 1 or 0.
- Change one cause, rerun the same case, and retain the original observation for comparison. Recheck after reload and on a live open bar when timing matters.
| Probe | Useful evidence | Constraint |
|---|---|---|
| Pine Logs | Values, branch decisions, and local-scope state in execution order | Personal scripts can generate logs; published scripts cannot. Filter calls in code to avoid excessive output. |
| Data Window plots | A named numeric value on the bar under the cursor | Keep plot calls in global scope. Convert booleans to 1 or 0 explicitly. |
| Chart markers | Where a condition becomes true | Check display settings and offsets before concluding that the condition failed. |