Thomas
Thomas

Reputation: 388

Tradingview Pine Script Import Based on Conditions

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.

enter image description here

Upvotes: 1

Views: 1998

Answers (1)

elod008
elod008

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

Related Questions