I would like to use assert in pinescript for bug detection. assert statement is available in python and C/C++. I hope there is an easy way to use assert in pinescript.
There’s a library available but it looks complicated to me.
https://www.tradingview.com/script/Ddd3hMq8-assert/
I am using pine-script v5
>Solution :
There is no assert in pinescript.
The library you linked is actually pretty good.
Alternatively, there is runtime.error which you can use conditionally.
When called, causes a runtime error with the error message specified
in themessageargument.
Something like this:
if barstate.islast and ta.cum(volume) == 0
runtime.error("No volume is provided by the data vendor.")