Declares the script as a library: a collection of exported functions, types and constants other scripts import.
Put library() at the top of a script that other scripts will import, once. A library plots nothing. It holds code marked with export, which a script brings in with import user/Library/1 as lib.
Every exported item needs to be documented with // comment lines above it. Libraries can export functions, user-defined types and enums, and can import other libraries.
Syntax
library(title: const string, overlay: const bool (optional), dynamic_requests: const bool (optional)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| title | const string | required | Name of the library, which becomes its published name. |
| overlay | const bool | false | Whether the library's own test plots draw on the main chart. |
| dynamic_requests | const bool | false | Allows request.* calls to take series arguments. |
Returns
Nothing.
Remarks
- On Sidechair: a pasted library stops with the message "This is a library; paste an indicator that uses it instead.", and an import compiles but each call through the alias warns and returns na.
Example
//@version=6
library("MathTools")
// Distance between two values as a percentage of the first.
export pctDiff(float a, float b) =>
(b - a) / a * 100See also
Runs on Sidechair