Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using assert in pinescript

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/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Something like this:

if barstate.islast and ta.cum(volume) == 0
    runtime.error("No volume is provided by the data vendor.")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading