Skip to content
Algo Trade Analytics Docs

import - Pine Script Keyword

Used to load an external library into a script and bind its functions to a namespace. The importing script can be an indicator, a strategy, or another library. A library must be published (privately or publicly) before it can be imported.

import {username}/{libraryName}/{libraryVersion} as {alias}
  • Using an alias that replaces a built-in namespace such as math.* or strategy.* is allowed, but if the library contains function names that shadow Pine Script®‘s built-in functions, the built-ins will become unavailable. The same version of a library can only be imported once. Aliases must be distinct for each imported library. When calling library functions, casting their arguments to types other than their declared type is not allowed. An import statement cannot use ‘as’ or ‘import’ as username, libraryName, or alias identifiers.
//@version=6indicator("num_methods import")// Import the first version of the username’s "num_methods" library and assign it to the "m" namespace",import username/num_methods/1 as m// Call the “sinh()” function from the imported libraryy = m.sinh(3.14)// Plot value returned by the "sinh()" function",plot(y)