Reputation: 388
What's the proper way to use import based on different conditions in Tradingview Pine Script?
I tried:
if (condition)
import name/library/version as alias
But it generated a compilation error. It seems like the import
statement can't be nested.
Upvotes: 1
Views: 1998
Reputation: 1362
The error message says it.
Why not import the libraries you need and use the appropriate functions based on your needs?
...
import name/library/version1 as lib1
import name/library/version2 as lib2
testVar = if condition
lib1.fn()
else
lib2.fn()
...
Upvotes: 0