1

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

FDL
  • 115
  • 8

1 Answers1

1

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 the message argument.

Something like this:

if barstate.islast and ta.cum(volume) == 0
    runtime.error("No volume is provided by the data vendor.")
vitruvius
  • 15,740
  • 3
  • 16
  • 26