We’re happy to announce that we’ve added support for multiple conditions using the else if construct in our Pine language.
Previously, you could only write if/else statements if they were embedded within each other. For example:
//@version=4 study("My Script") v = if close > open close else if open > close open else na plot(v)
Now, however, after adding the else if construct, you can simply write it out like this:
//@version=4 study("My Script") v=if close > open close else if open > close open else na plot(close)
Note that in order to use the else if construct, you must specify the fourth version of Pine in the first line of your code. To do this, simply add in the following:
//@version=4
You can learn more about if and else if expressions in our Pine Script Tutorial and Pine Script Reference pages. We hope you find this update useful. As always, feel free to send in your comments, feedback, and suggestions — we love building for you.