openpinescript 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +332 -2
- package/dist/cli.mjs +108691 -0
- package/dist/index.cjs +108670 -0
- package/dist/index.mjs +108624 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/parser/v1/generated/PineV1Lexer.d.ts +66 -0
- package/dist/types/parser/v1/generated/PineV1Parser.d.ts +555 -0
- package/dist/types/parser/v1/generated/PineV1ParserVisitor.d.ts +318 -0
- package/dist/types/parser/v1/index.d.ts +39 -0
- package/dist/types/parser/v2/generated/PineV2Lexer.d.ts +67 -0
- package/dist/types/parser/v2/generated/PineV2Parser.d.ts +568 -0
- package/dist/types/parser/v2/generated/PineV2ParserVisitor.d.ts +325 -0
- package/dist/types/parser/v2/index.d.ts +2 -0
- package/dist/types/parser/v3/generated/PineV3Lexer.d.ts +67 -0
- package/dist/types/parser/v3/generated/PineV3Parser.d.ts +568 -0
- package/dist/types/parser/v3/generated/PineV3ParserVisitor.d.ts +325 -0
- package/dist/types/parser/v3/index.d.ts +2 -0
- package/dist/types/parser/v4/generated/PineV4Lexer.d.ts +86 -0
- package/dist/types/parser/v4/generated/PineV4Parser.d.ts +673 -0
- package/dist/types/parser/v4/generated/PineV4ParserVisitor.d.ts +367 -0
- package/dist/types/parser/v4/index.d.ts +2 -0
- package/dist/types/parser/v5/generated/PineV5Lexer.d.ts +95 -0
- package/dist/types/parser/v5/generated/PineV5Parser.d.ts +964 -0
- package/dist/types/parser/v5/generated/PineV5ParserVisitor.d.ts +521 -0
- package/dist/types/parser/v5/index.d.ts +2 -0
- package/dist/types/parser/v6/generated/PineV6Lexer.d.ts +98 -0
- package/dist/types/parser/v6/generated/PineV6Parser.d.ts +984 -0
- package/dist/types/parser/v6/generated/PineV6ParserVisitor.d.ts +528 -0
- package/dist/types/parser/v6/index.d.ts +2 -0
- package/dist/types/runtime/v1/Series.d.ts +61 -0
- package/dist/types/runtime/v1/broker/Broker.d.ts +325 -0
- package/dist/types/runtime/v1/broker/index.d.ts +158 -0
- package/dist/types/runtime/v1/broker/val.d.ts +28 -0
- package/dist/types/runtime/v1/constDefault.d.ts +11 -0
- package/dist/types/runtime/v1/context.d.ts +1705 -0
- package/dist/types/runtime/v1/footprint.d.ts +32 -0
- package/dist/types/runtime/v1/index.d.ts +7 -0
- package/dist/types/runtime/v1/language-spec.d.ts +12 -0
- package/dist/types/runtime/v1/openTrades.d.ts +12 -0
- package/dist/types/runtime/v1/palette.d.ts +18 -0
- package/dist/types/runtime/v1/session.d.ts +482 -0
- package/dist/types/runtime/v1/sessions.d.ts +31 -0
- package/dist/types/runtime/v1/stateClone.d.ts +19 -0
- package/dist/types/runtime/v1/stdlib/alerts.d.ts +31 -0
- package/dist/types/runtime/v1/stdlib/arrays.d.ts +133 -0
- package/dist/types/runtime/v1/stdlib/barmerge.d.ts +27 -0
- package/dist/types/runtime/v1/stdlib/barstate.d.ts +79 -0
- package/dist/types/runtime/v1/stdlib/cast.d.ts +81 -0
- package/dist/types/runtime/v1/stdlib/chart.d.ts +283 -0
- package/dist/types/runtime/v1/stdlib/color.d.ts +51 -0
- package/dist/types/runtime/v1/stdlib/core.d.ts +162 -0
- package/dist/types/runtime/v1/stdlib/dataset.d.ts +36 -0
- package/dist/types/runtime/v1/stdlib/display.d.ts +50 -0
- package/dist/types/runtime/v1/stdlib/drawings.d.ts +407 -0
- package/dist/types/runtime/v1/stdlib/errors.d.ts +21 -0
- package/dist/types/runtime/v1/stdlib/font.d.ts +20 -0
- package/dist/types/runtime/v1/stdlib/footprint.d.ts +76 -0
- package/dist/types/runtime/v1/stdlib/format.d.ts +57 -0
- package/dist/types/runtime/v1/stdlib/index.d.ts +71 -0
- package/dist/types/runtime/v1/stdlib/input.d.ts +14 -0
- package/dist/types/runtime/v1/stdlib/inputs.d.ts +60 -0
- package/dist/types/runtime/v1/stdlib/late_members.d.ts +97 -0
- package/dist/types/runtime/v1/stdlib/logging.d.ts +31 -0
- package/dist/types/runtime/v1/stdlib/maps.d.ts +55 -0
- package/dist/types/runtime/v1/stdlib/math.d.ts +71 -0
- package/dist/types/runtime/v1/stdlib/matrix.d.ts +201 -0
- package/dist/types/runtime/v1/stdlib/metadata.d.ts +14 -0
- package/dist/types/runtime/v1/stdlib/mtf.d.ts +15 -0
- package/dist/types/runtime/v1/stdlib/renames.d.ts +117 -0
- package/dist/types/runtime/v1/stdlib/renames5.d.ts +113 -0
- package/dist/types/runtime/v1/stdlib/renames6.d.ts +81 -0
- package/dist/types/runtime/v1/stdlib/request.d.ts +207 -0
- package/dist/types/runtime/v1/stdlib/scale.d.ts +19 -0
- package/dist/types/runtime/v1/stdlib/session.d.ts +113 -0
- package/dist/types/runtime/v1/stdlib/sort_field.d.ts +12 -0
- package/dist/types/runtime/v1/stdlib/sources.d.ts +24 -0
- package/dist/types/runtime/v1/stdlib/str.d.ts +117 -0
- package/dist/types/runtime/v1/stdlib/strategy.d.ts +314 -0
- package/dist/types/runtime/v1/stdlib/syminfo.d.ts +209 -0
- package/dist/types/runtime/v1/stdlib/ta.d.ts +409 -0
- package/dist/types/runtime/v1/stdlib/time.d.ts +158 -0
- package/dist/types/runtime/v1/stdlib/trades.d.ts +108 -0
- package/dist/types/runtime/v1/stdlib/ui.d.ts +196 -0
- package/dist/types/runtime/v1/stdlib/v6_members.d.ts +68 -0
- package/dist/types/runtime/v1/timeframes.d.ts +139 -0
- package/dist/types/runtime/v1/zones.d.ts +30 -0
- package/dist/types/transpiler/common/index.d.ts +51 -0
- package/dist/types/transpiler/common/libraries.d.ts +29 -0
- package/dist/types/transpiler/common/parseErrors.d.ts +38 -0
- package/dist/types/transpiler/common/passes/ScopeAnalysis.d.ts +158 -0
- package/dist/types/transpiler/common/passes/TypeRules.d.ts +26 -0
- package/dist/types/transpiler/common/profiles/index.d.ts +96 -0
- package/dist/types/transpiler/common/version.d.ts +40 -0
- package/dist/types/transpiler/v1/ToJsVisitor.d.ts +720 -0
- package/dist/types/transpiler/v2/ToJsVisitor.d.ts +72 -0
- package/dist/types/transpiler/v3/ToJsVisitor.d.ts +87 -0
- package/dist/types/transpiler/v4/ToJsVisitor.d.ts +263 -0
- package/dist/types/transpiler/v5/ToJsVisitor.d.ts +1101 -0
- package/dist/types/transpiler/v6/ToJsVisitor.d.ts +237 -0
- package/dist/types/transpiler/v6/rules.d.ts +94 -0
- package/dist/types/utils/v2/common.d.ts +4 -0
- package/package.json +92 -4
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime/v1/stdlib/core.ts
|
|
3
|
+
* Core functions for Pine Script v2 (Strict Compliance)
|
|
4
|
+
*/
|
|
5
|
+
export declare function na(x: any): boolean;
|
|
6
|
+
export declare function nz(x: any, y?: any): any;
|
|
7
|
+
export declare function iff(cond: any, t: any, f: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* `+` — numeric addition, or STRING CONCATENATION when either side is a string.
|
|
10
|
+
*
|
|
11
|
+
* Pine overloads `+` exactly as JavaScript does, and this used to coerce
|
|
12
|
+
* unconditionally: `"a" + "b"` came out as `NaN`, because `Number("a")` is NaN.
|
|
13
|
+
* Nothing caught it, because v1–v4 have almost no reason to build a string —
|
|
14
|
+
* `tostring` exists and is rarely used, and a plot cannot show one.
|
|
15
|
+
*
|
|
16
|
+
* v5 makes it central. Pine Logs are how this project collects golden data
|
|
17
|
+
* without a paid TradingView plan (see runtime/v1/stdlib/logging.ts), every
|
|
18
|
+
* generated harness builds its CSV row with `str.tostring(x) + "," + …`, and
|
|
19
|
+
* all seven of them logged the single string "NaN".
|
|
20
|
+
*/
|
|
21
|
+
export declare function safe_add(a: any, b: any): number | string;
|
|
22
|
+
export declare function safe_sub(a: any, b: any): number;
|
|
23
|
+
/**
|
|
24
|
+
* `a == b` and `a != b`, with both sides UNWRAPPED first.
|
|
25
|
+
*
|
|
26
|
+
* ── The bug this fixes ──────────────────────────────────────────────────────
|
|
27
|
+
*
|
|
28
|
+
* Every script variable is a Series OBJECT, and JavaScript compares two objects
|
|
29
|
+
* with `==` by REFERENCE. So
|
|
30
|
+
*
|
|
31
|
+
* x = 1.0
|
|
32
|
+
* y = 1.0
|
|
33
|
+
* equal = x == y // false
|
|
34
|
+
*
|
|
35
|
+
* Two variables holding the same number were never equal, at any version. It
|
|
36
|
+
* survived because the common shapes hide it: `x == 0` compares an object to a
|
|
37
|
+
* primitive, which coerces through `valueOf`, and `<`, `>`, `<=`, `>=` coerce
|
|
38
|
+
* unconditionally. Only `==` and `!=` between two variables reach the reference
|
|
39
|
+
* comparison, and then they are silently, permanently false.
|
|
40
|
+
*
|
|
41
|
+
* ── Why `==` and not `===` after unwrapping ─────────────────────────────────
|
|
42
|
+
*
|
|
43
|
+
* Because objects must still compare by reference once unwrapped. An ENUM
|
|
44
|
+
* member is a plain object with no `valueOf` of its own — deliberately, so that
|
|
45
|
+
* two enums with identically named and titled fields are not equal, which is
|
|
46
|
+
* the rule the manual states: "Scripts cannot compare members of different
|
|
47
|
+
* enums ... even if the fields have identical names and titles." Unwrapping
|
|
48
|
+
* leaves those objects alone, and `==` then does exactly the right thing for
|
|
49
|
+
* both cases.
|
|
50
|
+
*
|
|
51
|
+
* `na` needs no special handling: it is NaN, and NaN equals nothing including
|
|
52
|
+
* itself, which is what Pine reports for a comparison involving `na`.
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* TradingView treats two floats as equal when they differ by at most 1e-10
|
|
56
|
+
* (absolute, at any magnitude). Measured with Pine Logs; see
|
|
57
|
+
* dev-docs/tv-parity/ENGINE-BUGS.md section 5.
|
|
58
|
+
*/
|
|
59
|
+
export declare const FLOAT_TOLERANCE = 1e-10;
|
|
60
|
+
export declare function safe_eq(a: any, b: any): boolean;
|
|
61
|
+
export declare function safe_ne(a: any, b: any): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Ordering comparisons share the equality tolerance: `a < b` is "less AND not
|
|
64
|
+
* equal", `a <= b` is "less OR equal". A NaN difference fails every test, so
|
|
65
|
+
* `na` stays false throughout, as before.
|
|
66
|
+
*/
|
|
67
|
+
export declare function safe_lt(a: any, b: any): boolean;
|
|
68
|
+
export declare function safe_gt(a: any, b: any): boolean;
|
|
69
|
+
export declare function safe_le(a: any, b: any): boolean;
|
|
70
|
+
export declare function safe_ge(a: any, b: any): boolean;
|
|
71
|
+
export declare function tostring(x: any): string;
|
|
72
|
+
export declare function abs(x: any): number;
|
|
73
|
+
export declare function acos(x: any): number;
|
|
74
|
+
export declare function asin(x: any): number;
|
|
75
|
+
export declare function atan(x: any): number;
|
|
76
|
+
export declare function ceil(x: any): number;
|
|
77
|
+
export declare function cos(x: any): number;
|
|
78
|
+
export declare function exp(x: any): number;
|
|
79
|
+
export declare function floor(x: any): number;
|
|
80
|
+
export declare function log(x: any): number;
|
|
81
|
+
export declare function log10(x: any): number;
|
|
82
|
+
export declare function max(...args: any[]): number;
|
|
83
|
+
export declare function min(...args: any[]): number;
|
|
84
|
+
export declare function pow(x: any, y: any): number;
|
|
85
|
+
/**
|
|
86
|
+
* `round(x)`, and from v5 `math.round(number, precision)`.
|
|
87
|
+
*
|
|
88
|
+
* Half rounds AWAY from zero, and `precision` rounds to that many decimals as
|
|
89
|
+
* the number is WRITTEN: TradingView's log gives math.round(-2.5) = -3 and
|
|
90
|
+
* math.round(1.005, 2) = 1.01 (conformance/v6/golden/harness_v6_language).
|
|
91
|
+
* JavaScript's Math.round gives -2, and 1.005 * 100 is 100.49999999999999 in
|
|
92
|
+
* binary, so both need doing here. Shifting by exponent notation —
|
|
93
|
+
* Number("1.005e2") is exactly 100.5 — moves the decimal point in the decimal
|
|
94
|
+
* representation instead of multiplying in binary.
|
|
95
|
+
*/
|
|
96
|
+
export declare function round(x: any, precision?: any): number;
|
|
97
|
+
export declare function sign(x: any): number;
|
|
98
|
+
export declare function sin(x: any): number;
|
|
99
|
+
export declare function sqrt(x: any): number;
|
|
100
|
+
export declare function tan(x: any): number;
|
|
101
|
+
export declare function avg(...args: any[]): number;
|
|
102
|
+
export declare const red = "#FF5252";
|
|
103
|
+
export declare const green = "#4CAF50";
|
|
104
|
+
export declare const blue = "#2196F3";
|
|
105
|
+
export declare const orange = "#FF9800";
|
|
106
|
+
export declare const teal = "#009688";
|
|
107
|
+
export declare const navy = "#3F51B5";
|
|
108
|
+
export declare const white = "#FFFFFF";
|
|
109
|
+
export declare const black = "#000000";
|
|
110
|
+
export declare const gray = "#9E9E9E";
|
|
111
|
+
export declare const purple = "#9C27B0";
|
|
112
|
+
export declare const yellow = "#FFEB3B";
|
|
113
|
+
export declare const lime = "#CDDC39";
|
|
114
|
+
export declare const aqua = "#00BCD4";
|
|
115
|
+
export declare const fuchsia = "#E040FB";
|
|
116
|
+
export declare const olive = "#808000";
|
|
117
|
+
export declare const maroon = "#800000";
|
|
118
|
+
export declare const silver = "#C0C0C0";
|
|
119
|
+
/**
|
|
120
|
+
* `int(x)` — explicit cast from float to int.
|
|
121
|
+
*
|
|
122
|
+
* Pine v4 added "functions for explicit type casting" (June 2019) because it
|
|
123
|
+
* has no implicit float → integer conversion. The v4 manual's own example is
|
|
124
|
+
* the reason this matters:
|
|
125
|
+
*
|
|
126
|
+
* len = 10.0
|
|
127
|
+
* s = sma(close, int(len))
|
|
128
|
+
*
|
|
129
|
+
* without which `sma` rejects `const float` where it wants `integer`.
|
|
130
|
+
*
|
|
131
|
+
* Truncates toward zero rather than rounding — `int(-1.7)` is `-1`, not `-2` —
|
|
132
|
+
* and propagates `na`, since a cast cannot invent a value.
|
|
133
|
+
*
|
|
134
|
+
* Source: https://www.tradingview.com/pine-script-docs/v4/language/type-system/
|
|
135
|
+
*
|
|
136
|
+
* @returns {series int} `x` truncated toward zero, or na.
|
|
137
|
+
*/
|
|
138
|
+
export declare function int(x: any): number;
|
|
139
|
+
/**
|
|
140
|
+
* `max_bars_back(var, num)` — request a deeper history buffer for one series.
|
|
141
|
+
*
|
|
142
|
+
* ── Deliberately a no-op ────────────────────────────────────────────────────
|
|
143
|
+
*
|
|
144
|
+
* On TradingView this raises the internal lookback buffer for `var`, and exists
|
|
145
|
+
* because that buffer is capped: a script that indexes further back than the
|
|
146
|
+
* engine guessed fails with "Pine cannot determine the referencing length of
|
|
147
|
+
* series".
|
|
148
|
+
*
|
|
149
|
+
* This engine has no such cap. Lookback depth is bounded by available memory,
|
|
150
|
+
* which is one of the limits skipped on purpose — see the "Deliberate
|
|
151
|
+
* deviations" section of docs/common/CONFORMANCE.md and the table that follows it.
|
|
152
|
+
* Every buffer is therefore already at least as large as any `max_bars_back`
|
|
153
|
+
* call could ask for, and honouring the request would mean SHRINKING history
|
|
154
|
+
* to match a restriction that is not being modelled.
|
|
155
|
+
*
|
|
156
|
+
* Accepting and ignoring it is what keeps scripts that call it runnable. The
|
|
157
|
+
* alternative — leaving the name unbound — is what made four of TradingView's
|
|
158
|
+
* own documentation examples die with a ReferenceError.
|
|
159
|
+
*
|
|
160
|
+
* @returns {void}
|
|
161
|
+
*/
|
|
162
|
+
export declare function max_bars_back(_series: any, _num: any): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How far the dataset runs — `last_bar_index` and `last_bar_time`.
|
|
3
|
+
*
|
|
4
|
+
* Added in Pine v5 (December 2021). The release notes are explicit about the
|
|
5
|
+
* property that makes them useful:
|
|
6
|
+
*
|
|
7
|
+
* "Added new built-in variables that return the bar_index and time values of
|
|
8
|
+
* the last bar in the dataset. Their VALUES ARE KNOWN AT THE BEGINNING of
|
|
9
|
+
* the script's calculation: last_bar_index - Bar index of the last chart
|
|
10
|
+
* bar. last_bar_time - UNIX time of the last chart bar."
|
|
11
|
+
*
|
|
12
|
+
* That guarantee is the whole point. `bar_index == last_bar_index - 1` and
|
|
13
|
+
* `last_bar_index - bar_index <= 100` are how scripts find the right-hand edge
|
|
14
|
+
* of the chart, and both are meaningless if the answer only arrives on the last
|
|
15
|
+
* bar.
|
|
16
|
+
*
|
|
17
|
+
* The Context cannot derive it — it is fed one bar at a time — so the HOST
|
|
18
|
+
* declares it up front with `provideDatasetExtent`. See the note on that method
|
|
19
|
+
* for what happens when a host does not, and why the fallback is a documented
|
|
20
|
+
* divergence rather than a silent one.
|
|
21
|
+
*
|
|
22
|
+
* Source: https://www.tradingview.com/pine-script-docs/v5/release-notes/
|
|
23
|
+
*/
|
|
24
|
+
import { Context } from "../context.js";
|
|
25
|
+
/**
|
|
26
|
+
* Bar index of the last bar in the dataset.
|
|
27
|
+
* @getter
|
|
28
|
+
* @returns {integer} The last bar's index, known from the first bar.
|
|
29
|
+
*/
|
|
30
|
+
export declare function last_bar_index(ctx: Context): number;
|
|
31
|
+
/**
|
|
32
|
+
* UNIX time of the last bar in the dataset, in milliseconds.
|
|
33
|
+
* @getter
|
|
34
|
+
* @returns {integer} The last bar's opening time, known from the first bar.
|
|
35
|
+
*/
|
|
36
|
+
export declare function last_bar_time(ctx: Context): number;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `display.*` — where a plot's values are shown.
|
|
3
|
+
*
|
|
4
|
+
* "controls the locations where plot values appear, which include the script
|
|
5
|
+
* pane, status line, price scale, and Data Window. The default is
|
|
6
|
+
* display.all."
|
|
7
|
+
*
|
|
8
|
+
* ── Why these are powers of two ─────────────────────────────────────────────
|
|
9
|
+
*
|
|
10
|
+
* Because the manual says the constants compose with ARITHMETIC:
|
|
11
|
+
*
|
|
12
|
+
* "supports addition and subtraction of display.* options, e.g.,
|
|
13
|
+
* display.all - display.pane hides the pane visuals but displays the plot's
|
|
14
|
+
* numeric results everywhere else, while
|
|
15
|
+
* display.status_line + display.data_window displays results only in those
|
|
16
|
+
* two locations."
|
|
17
|
+
*
|
|
18
|
+
* A set of disjoint bits is the only encoding under which both of those work
|
|
19
|
+
* with the ordinary `+` and `-` a script writes: `all - pane` clears exactly
|
|
20
|
+
* one location, and `status_line + data_window` names exactly two. Sequential
|
|
21
|
+
* integers (1, 2, 3, 4) would make `all - pane` land on some other location
|
|
22
|
+
* entirely, silently.
|
|
23
|
+
*
|
|
24
|
+
* `all` is therefore the sum of the four, not a magic number.
|
|
25
|
+
*
|
|
26
|
+
* ── What this engine does with them ─────────────────────────────────────────
|
|
27
|
+
*
|
|
28
|
+
* Carries them. There is no pane, status line, price scale or Data Window
|
|
29
|
+
* here, so `display` changes nothing about the values a plot produces — which
|
|
30
|
+
* is the whole of what this engine computes. A script that hides a plot with
|
|
31
|
+
* `display.none` still gets its series in the output, and that is a difference
|
|
32
|
+
* in presentation rather than in arithmetic.
|
|
33
|
+
*
|
|
34
|
+
* v5-only: the registry split in ./index.ts keeps the namespace out of the
|
|
35
|
+
* v1–v4 views.
|
|
36
|
+
*/
|
|
37
|
+
export declare const display: {
|
|
38
|
+
/** Shown nowhere. The plot is still calculated. */
|
|
39
|
+
none: number;
|
|
40
|
+
/** The Data Window. */
|
|
41
|
+
data_window: number;
|
|
42
|
+
/** The script's pane — the visible line, histogram or shape. */
|
|
43
|
+
pane: number;
|
|
44
|
+
/** The price scale on the right-hand edge. */
|
|
45
|
+
price_scale: number;
|
|
46
|
+
/** The status line above the chart. */
|
|
47
|
+
status_line: number;
|
|
48
|
+
/** Every location at once — the default. The sum of the four above. */
|
|
49
|
+
all: number;
|
|
50
|
+
};
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pine Script drawing objects — `line`, `label`, `box`, `table`.
|
|
3
|
+
*
|
|
4
|
+
* `line` and `label` arrived June 2019, `box` and `table` in May 2021, all
|
|
5
|
+
* under v4 (see the v4 release notes). The registry split in ./index.ts keeps
|
|
6
|
+
* the whole set out of the v1–v3 view, so a v3 script naming `label.new` is
|
|
7
|
+
* refused there rather than by a check here.
|
|
8
|
+
*
|
|
9
|
+
* ── WHAT THIS DOES AND DOES NOT DO ──────────────────────────────────────────
|
|
10
|
+
*
|
|
11
|
+
* A drawing is recorded on the Context with an id and its properties, and the
|
|
12
|
+
* setters mutate that record. It is NOT rendered, and it does not participate
|
|
13
|
+
* in `plots` — a drawing is an object with a lifetime, not a per-bar value, and
|
|
14
|
+
* TradingView's exported chart data does not contain drawings either. So
|
|
15
|
+
* nothing here can affect the golden-parity numbers.
|
|
16
|
+
*
|
|
17
|
+
* The point is that a script which draws RUNS. A large fraction of published v4
|
|
18
|
+
* indicators label their signals, and before this they died on the first
|
|
19
|
+
* `label.new` — which said nothing about whether their arithmetic was right.
|
|
20
|
+
*
|
|
21
|
+
* Getters return what was set. `line.get_price(id, x)` is the one that computes
|
|
22
|
+
* rather than recalls, because it is the only one a script reads back into its
|
|
23
|
+
* own maths.
|
|
24
|
+
*/
|
|
25
|
+
import { Context } from "../context.js";
|
|
26
|
+
export declare const line: {
|
|
27
|
+
/**
|
|
28
|
+
* `line.new(x1, y1, x2, y2, …)` and `line.new(first_point, second_point, …)`
|
|
29
|
+
* — see the note above `isChartPoint` for how the two are told apart, and
|
|
30
|
+
* why nothing here carries a parameter default.
|
|
31
|
+
*/
|
|
32
|
+
new: (ctx: Context, x1: any, y1: any, x2: any, y2: any, xloc?: any, extend?: any, color?: any, style?: any, width?: any) => string;
|
|
33
|
+
set_x1: (ctx: Context, id: any, x: any) => void;
|
|
34
|
+
set_y1: (ctx: Context, id: any, y: any) => void;
|
|
35
|
+
set_x2: (ctx: Context, id: any, x: any) => void;
|
|
36
|
+
set_y2: (ctx: Context, id: any, y: any) => void;
|
|
37
|
+
set_width: (ctx: Context, id: any, width: any) => void;
|
|
38
|
+
/**
|
|
39
|
+
* `line.set_xloc(id, x1, x2, xloc)` — both x coordinates AND what they
|
|
40
|
+
* mean, in one call, because changing `xloc` alone would reinterpret bar
|
|
41
|
+
* indices as timestamps or the reverse.
|
|
42
|
+
*
|
|
43
|
+
* This took `(id, xloc)`, so the documented four-argument call put `x1`
|
|
44
|
+
* into `xloc` and left the line where it was. TradingView's log settles
|
|
45
|
+
* it — conformance/common/v5_gaps_golden.test.ts — and the signature is the
|
|
46
|
+
* same at every version that has lines.
|
|
47
|
+
*/
|
|
48
|
+
set_xloc: (ctx: Context, id: any, x1: any, x2: any, xloc: any) => void;
|
|
49
|
+
set_extend: (ctx: Context, id: any, extend: any) => void;
|
|
50
|
+
set_color: (ctx: Context, id: any, color: any) => void;
|
|
51
|
+
set_style: (ctx: Context, id: any, style: any) => void;
|
|
52
|
+
get_x1: (ctx: Context, id: any) => any;
|
|
53
|
+
get_y1: (ctx: Context, id: any) => any;
|
|
54
|
+
get_x2: (ctx: Context, id: any) => any;
|
|
55
|
+
get_y2: (ctx: Context, id: any) => any;
|
|
56
|
+
/** Both endpoints at once — one call in Pine, so one call here. */
|
|
57
|
+
set_xy1: (ctx: Context, id: any, x: any, y: any) => void;
|
|
58
|
+
set_xy2: (ctx: Context, id: any, x: any, y: any) => void;
|
|
59
|
+
/**
|
|
60
|
+
* `line.set_first_point(id, point)` / `set_second_point` — the `chart.point`
|
|
61
|
+
* spellings of `set_xy1` / `set_xy2`, October 2023.
|
|
62
|
+
*
|
|
63
|
+
* A point carries BOTH x coordinates, and which one applies is the line's
|
|
64
|
+
* own `xloc` — so the drawing decides, not the point. That is the whole
|
|
65
|
+
* reason these exist beside the xy pair: a script that works in
|
|
66
|
+
* `chart.point`s should not have to unpack one to move a line.
|
|
67
|
+
*/
|
|
68
|
+
set_first_point: (ctx: Context, id: any, point: any) => void;
|
|
69
|
+
set_second_point: (ctx: Context, id: any, point: any) => void;
|
|
70
|
+
/**
|
|
71
|
+
* The price the line takes at bar `x`, by linear interpolation through its
|
|
72
|
+
* two endpoints — extrapolated beyond them, which is what makes the
|
|
73
|
+
* trendline-projection idiom work.
|
|
74
|
+
*
|
|
75
|
+
* Vertical lines have no single price, so they are `na` rather than ±∞.
|
|
76
|
+
*/
|
|
77
|
+
get_price: (ctx: Context, id: any, x: any) => any;
|
|
78
|
+
delete: (ctx: Context, id: any) => void;
|
|
79
|
+
/**
|
|
80
|
+
* `line.all` — every live line, oldest first.
|
|
81
|
+
*
|
|
82
|
+
* A Pine ARRAY, so `array.size(line.all)` and `line.all.size()` both work, and
|
|
83
|
+
* so does iterating it to delete the oldest. `polyline.all` and
|
|
84
|
+
* `linefill.all` are the same thing; these three were simply missing, and a
|
|
85
|
+
* missing member of a real namespace read as `undefined` — which made
|
|
86
|
+
* `array.size(label.all)` a call on nothing.
|
|
87
|
+
*
|
|
88
|
+
* @getter
|
|
89
|
+
*/
|
|
90
|
+
all: (ctx: Context) => string[];
|
|
91
|
+
copy: (ctx: Context, id: any) => string;
|
|
92
|
+
style_solid: string;
|
|
93
|
+
style_dotted: string;
|
|
94
|
+
style_dashed: string;
|
|
95
|
+
style_arrow_left: string;
|
|
96
|
+
style_arrow_right: string;
|
|
97
|
+
style_arrow_both: string;
|
|
98
|
+
};
|
|
99
|
+
export declare const label: {
|
|
100
|
+
/**
|
|
101
|
+
* `label.new(x, y, text, …)` and `label.new(point, text, …)`.
|
|
102
|
+
*
|
|
103
|
+
* The point form replaces ONE coordinate pair with one point, so the tail
|
|
104
|
+
* shifts by one rather than two. `text_font_family` is v5: three of
|
|
105
|
+
* TradingView's own examples pass it — `label.new(…, text_font_family =
|
|
106
|
+
* font.family_monospace)` — and an argument the signature does not name is
|
|
107
|
+
* dropped without a word, so a monospaced label came out proportional and
|
|
108
|
+
* nothing said so.
|
|
109
|
+
*/
|
|
110
|
+
new: (ctx: Context, x: any, y: any, text?: any, xloc?: any, yloc?: any, color?: any, style?: any, textcolor?: any, size?: any, textalign?: any, tooltip?: any, text_font_family?: any, force_overlay?: any, text_formatting?: any) => string;
|
|
111
|
+
set_x: (ctx: Context, id: any, x: any) => void;
|
|
112
|
+
set_y: (ctx: Context, id: any, y: any) => void;
|
|
113
|
+
set_text: (ctx: Context, id: any, text: any) => void;
|
|
114
|
+
/**
|
|
115
|
+
* `label.set_xloc(id, x, xloc)` — the reference's signature. The same
|
|
116
|
+
* defect `line.set_xloc` had: this took `(id, xloc)`. Fixed from the
|
|
117
|
+
* reference rather than from a log, as the line's twin.
|
|
118
|
+
*/
|
|
119
|
+
set_xloc: (ctx: Context, id: any, x: any, xloc: any) => void;
|
|
120
|
+
set_yloc: (ctx: Context, id: any, yloc: any) => void;
|
|
121
|
+
set_color: (ctx: Context, id: any, color: any) => void;
|
|
122
|
+
set_style: (ctx: Context, id: any, style: any) => void;
|
|
123
|
+
set_textcolor: (ctx: Context, id: any, textcolor: any) => void;
|
|
124
|
+
set_size: (ctx: Context, id: any, size: any) => void;
|
|
125
|
+
/** v6. See `formatting` above for the value. */
|
|
126
|
+
set_text_font_family: (ctx: Context, id: any, text_font_family: any) => void;
|
|
127
|
+
set_text_formatting: (ctx: Context, id: any, text_formatting: any) => void;
|
|
128
|
+
set_textalign: (ctx: Context, id: any, textalign: any) => void;
|
|
129
|
+
set_tooltip: (ctx: Context, id: any, tooltip: any) => void;
|
|
130
|
+
get_x: (ctx: Context, id: any) => any;
|
|
131
|
+
get_y: (ctx: Context, id: any) => any;
|
|
132
|
+
get_text: (ctx: Context, id: any) => any;
|
|
133
|
+
/** `label.set_point(id, point)` — `set_xy` from a `chart.point`. */
|
|
134
|
+
set_point: (ctx: Context, id: any, point: any) => void;
|
|
135
|
+
set_xy: (ctx: Context, id: any, x: any, y: any) => void;
|
|
136
|
+
delete: (ctx: Context, id: any) => void;
|
|
137
|
+
/**
|
|
138
|
+
* `label.all` — every live label, oldest first.
|
|
139
|
+
*
|
|
140
|
+
* A Pine ARRAY, so `array.size(label.all)` and `label.all.size()` both work, and
|
|
141
|
+
* so does iterating it to delete the oldest. `polyline.all` and
|
|
142
|
+
* `linefill.all` are the same thing; these three were simply missing, and a
|
|
143
|
+
* missing member of a real namespace read as `undefined` — which made
|
|
144
|
+
* `array.size(label.all)` a call on nothing.
|
|
145
|
+
*
|
|
146
|
+
* @getter
|
|
147
|
+
*/
|
|
148
|
+
all: (ctx: Context) => string[];
|
|
149
|
+
copy: (ctx: Context, id: any) => string;
|
|
150
|
+
style_none: string;
|
|
151
|
+
style_xcross: string;
|
|
152
|
+
style_cross: string;
|
|
153
|
+
style_triangleup: string;
|
|
154
|
+
style_triangledown: string;
|
|
155
|
+
style_flag: string;
|
|
156
|
+
style_circle: string;
|
|
157
|
+
style_arrowup: string;
|
|
158
|
+
style_arrowdown: string;
|
|
159
|
+
style_label_up: string;
|
|
160
|
+
style_label_down: string;
|
|
161
|
+
style_label_left: string;
|
|
162
|
+
style_label_right: string;
|
|
163
|
+
style_label_lower_left: string;
|
|
164
|
+
style_label_lower_right: string;
|
|
165
|
+
style_label_upper_left: string;
|
|
166
|
+
style_label_upper_right: string;
|
|
167
|
+
style_label_center: string;
|
|
168
|
+
/** Text drawn with an outline and no bubble — v5, 2024. */
|
|
169
|
+
style_text_outline: string;
|
|
170
|
+
style_square: string;
|
|
171
|
+
style_diamond: string;
|
|
172
|
+
};
|
|
173
|
+
export declare const box: {
|
|
174
|
+
/**
|
|
175
|
+
* `box.new(left, top, right, bottom, …)` and
|
|
176
|
+
* `box.new(top_left, bottom_right, …)`.
|
|
177
|
+
*
|
|
178
|
+
* A box's corners are (left, top) and (right, bottom), so `top_left`
|
|
179
|
+
* supplies left/top and `bottom_right` supplies right/bottom.
|
|
180
|
+
*
|
|
181
|
+
* `xloc` decides whether `left`/`right` are BAR INDICES or TIMES, and it
|
|
182
|
+
* sits between `extend` and `bgcolor` in the published signature. It was
|
|
183
|
+
* absent, so `box.new(…, xloc = xloc.bar_time)` had its coordinates read as
|
|
184
|
+
* bar indices — a box drawn at bar 1,700,000,000.
|
|
185
|
+
*
|
|
186
|
+
* The text defaults are the manual's: "size.auto (default)", "Its default
|
|
187
|
+
* is color.black", "text.align_center (default)" for both alignments, "The
|
|
188
|
+
* default is text.wrap_none", and `font.family_default`. Spelled as the
|
|
189
|
+
* VALUES those constants carry, so a script that passes the constant and a
|
|
190
|
+
* script that leaves it out record the same thing.
|
|
191
|
+
*/
|
|
192
|
+
new: (ctx: Context, left: any, top: any, right: any, bottom: any, border_color?: any, border_width?: any, border_style?: any, extend?: any, xloc?: any, bgcolor?: any, text?: any, text_size?: any, text_color?: any, text_halign?: any, text_valign?: any, text_wrap?: any, text_font_family?: any, force_overlay?: any, text_formatting?: any) => string;
|
|
193
|
+
set_left: (ctx: Context, id: any, left: any) => void;
|
|
194
|
+
set_top: (ctx: Context, id: any, top: any) => void;
|
|
195
|
+
set_right: (ctx: Context, id: any, right: any) => void;
|
|
196
|
+
set_bottom: (ctx: Context, id: any, bottom: any) => void;
|
|
197
|
+
set_border_width: (ctx: Context, id: any, width: any) => void;
|
|
198
|
+
set_border_color: (ctx: Context, id: any, color: any) => void;
|
|
199
|
+
set_border_style: (ctx: Context, id: any, style: any) => void;
|
|
200
|
+
set_extend: (ctx: Context, id: any, extend: any) => void;
|
|
201
|
+
set_bgcolor: (ctx: Context, id: any, bgcolor: any) => void;
|
|
202
|
+
/**
|
|
203
|
+
* v6, March 2025: "Sets the left and right border coordinates of a box
|
|
204
|
+
* and whether they are bar indices or UNIX timestamps. It works like the
|
|
205
|
+
* set_xloc() functions for lines and labels" — so the shape TradingView
|
|
206
|
+
* documents for `line.set_xloc`, `(id, x1, x2, xloc)`, with a box's
|
|
207
|
+
* horizontal coordinates being `left` and `right`.
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
set_xloc: (ctx: Context, id: any, left: any, right: any, xloc: any) => void;
|
|
211
|
+
/**
|
|
212
|
+
* A box holds TEXT, and the seven setters that write it.
|
|
213
|
+
*
|
|
214
|
+
* "box.set_text(), box.set_text_size(), box.set_text_color(),
|
|
215
|
+
* box.set_text_halign(), box.set_text_valign(), box.set_text_wrap(), and
|
|
216
|
+
* box.set_text_font_family() update the id box's text-related properties",
|
|
217
|
+
* and `box.new` takes the same seven as `text, text_size, text_color,
|
|
218
|
+
* text_halign, text_valign, text_wrap, text_font_family`.
|
|
219
|
+
*
|
|
220
|
+
* The whole family was missing, so `myBox.set_text(…)` — which
|
|
221
|
+
* TradingView's own lines-and-boxes example calls — died with "'box' has no
|
|
222
|
+
* method 'set_text'".
|
|
223
|
+
*/
|
|
224
|
+
set_text: (ctx: Context, id: any, text: any) => void;
|
|
225
|
+
set_text_size: (ctx: Context, id: any, text_size: any) => void;
|
|
226
|
+
/** v6. */
|
|
227
|
+
set_text_formatting: (ctx: Context, id: any, text_formatting: any) => void;
|
|
228
|
+
set_text_color: (ctx: Context, id: any, text_color: any) => void;
|
|
229
|
+
set_text_halign: (ctx: Context, id: any, text_halign: any) => void;
|
|
230
|
+
set_text_valign: (ctx: Context, id: any, text_valign: any) => void;
|
|
231
|
+
set_text_wrap: (ctx: Context, id: any, text_wrap: any) => void;
|
|
232
|
+
set_text_font_family: (ctx: Context, id: any, text_font_family: any) => void;
|
|
233
|
+
get_left: (ctx: Context, id: any) => any;
|
|
234
|
+
get_top: (ctx: Context, id: any) => any;
|
|
235
|
+
get_right: (ctx: Context, id: any) => any;
|
|
236
|
+
get_bottom: (ctx: Context, id: any) => any;
|
|
237
|
+
set_lefttop: (ctx: Context, id: any, left: any, top: any) => void;
|
|
238
|
+
/** The `chart.point` spellings of the two corner setters. */
|
|
239
|
+
set_top_left_point: (ctx: Context, id: any, point: any) => void;
|
|
240
|
+
set_bottom_right_point: (ctx: Context, id: any, point: any) => void;
|
|
241
|
+
set_rightbottom: (ctx: Context, id: any, right: any, bottom: any) => void;
|
|
242
|
+
delete: (ctx: Context, id: any) => void;
|
|
243
|
+
/**
|
|
244
|
+
* `box.all` — every live box, oldest first.
|
|
245
|
+
*
|
|
246
|
+
* A Pine ARRAY, so `array.size(box.all)` and `box.all.size()` both work, and
|
|
247
|
+
* so does iterating it to delete the oldest. `polyline.all` and
|
|
248
|
+
* `linefill.all` are the same thing; these three were simply missing, and a
|
|
249
|
+
* missing member of a real namespace read as `undefined` — which made
|
|
250
|
+
* `array.size(label.all)` a call on nothing.
|
|
251
|
+
*
|
|
252
|
+
* @getter
|
|
253
|
+
*/
|
|
254
|
+
all: (ctx: Context) => string[];
|
|
255
|
+
copy: (ctx: Context, id: any) => string;
|
|
256
|
+
style_solid: string;
|
|
257
|
+
style_dotted: string;
|
|
258
|
+
style_dashed: string;
|
|
259
|
+
};
|
|
260
|
+
export declare const table: {
|
|
261
|
+
new: (ctx: Context, position: any, columns: any, rows: any, bgcolor?: any, frame_color?: any, frame_width?: any, border_color?: any, border_width?: any) => string;
|
|
262
|
+
cell: (ctx: Context, table_id: any, column: any, row: any, text?: any, width?: any, height?: any, text_color?: any, text_halign?: any, text_valign?: any, text_size?: any, bgcolor?: any, tooltip?: any, text_font_family?: any, text_formatting?: any) => void;
|
|
263
|
+
/**
|
|
264
|
+
* `table.cell_set_*` — change ONE property of an existing cell.
|
|
265
|
+
*
|
|
266
|
+
* The prefix is `cell_set_`, not `set_cell_`. The distinction is the
|
|
267
|
+
* table's own naming rule: `table.set_*` changes the TABLE (`set_position`,
|
|
268
|
+
* `set_bgcolor`) and `table.cell_set_*` changes a CELL. Eight of
|
|
269
|
+
* TradingView's own examples call `table.cell_set_text`, and the misspelled
|
|
270
|
+
* `set_cell_text` this engine had was reachable by nothing.
|
|
271
|
+
*
|
|
272
|
+
* A cell that has not been written yet is created empty rather than
|
|
273
|
+
* ignored, which is what lets a script lay out a table with `table.cell`
|
|
274
|
+
* and then update one field of it per bar.
|
|
275
|
+
*/
|
|
276
|
+
/**
|
|
277
|
+
* The typeface and the tooltip of one cell.
|
|
278
|
+
*
|
|
279
|
+
* `table.cell_set_text_font_family` is not on the manual's Tables page, and
|
|
280
|
+
* TradingView's `v5-concepts-time-20` calls it anyway —
|
|
281
|
+
* `displayTable.cell_set_text_font_family(colID, rowID, font.family_monospace)`
|
|
282
|
+
* — which is the same standard of evidence the `fixnan` and `transp=`
|
|
283
|
+
* decisions rest on: a published example is the language.
|
|
284
|
+
*/
|
|
285
|
+
cell_set_text_font_family: (ctx: Context, table_id: any, column: any, row: any, family: any) => void;
|
|
286
|
+
cell_set_tooltip: (ctx: Context, table_id: any, column: any, row: any, tooltip: any) => void;
|
|
287
|
+
cell_set_text: (ctx: Context, table_id: any, column: any, row: any, text: any) => void;
|
|
288
|
+
cell_set_bgcolor: (ctx: Context, table_id: any, column: any, row: any, bgcolor: any) => void;
|
|
289
|
+
cell_set_text_color: (ctx: Context, table_id: any, column: any, row: any, text_color: any) => void;
|
|
290
|
+
cell_set_text_size: (ctx: Context, table_id: any, column: any, row: any, text_size: any) => void;
|
|
291
|
+
cell_set_text_halign: (ctx: Context, table_id: any, column: any, row: any, text_halign: any) => void;
|
|
292
|
+
cell_set_text_valign: (ctx: Context, table_id: any, column: any, row: any, text_valign: any) => void;
|
|
293
|
+
/** v6. */
|
|
294
|
+
cell_set_text_formatting: (ctx: Context, table_id: any, column: any, row: any, text_formatting: any) => void;
|
|
295
|
+
cell_set_width: (ctx: Context, table_id: any, column: any, row: any, width: any) => void;
|
|
296
|
+
cell_set_height: (ctx: Context, table_id: any, column: any, row: any, height: any) => void;
|
|
297
|
+
/**
|
|
298
|
+
* `table.merge_cells(table_id, start_column, start_row, end_column, end_row)`.
|
|
299
|
+
*
|
|
300
|
+
* Recorded rather than rendered: nothing here draws a table, so a merge is
|
|
301
|
+
* a fact about the cell range that a host renderer would honour. The
|
|
302
|
+
* top-left cell of the range carries it, which is where its text lives.
|
|
303
|
+
*/
|
|
304
|
+
merge_cells: (ctx: Context, table_id: any, start_column: any, start_row: any, end_column: any, end_row: any) => void;
|
|
305
|
+
set_position: (ctx: Context, id: any, position: any) => void;
|
|
306
|
+
set_bgcolor: (ctx: Context, id: any, bgcolor: any) => void;
|
|
307
|
+
set_border_color: (ctx: Context, id: any, border_color: any) => void;
|
|
308
|
+
set_border_width: (ctx: Context, id: any, border_width: any) => void;
|
|
309
|
+
set_frame_color: (ctx: Context, id: any, frame_color: any) => void;
|
|
310
|
+
set_frame_width: (ctx: Context, id: any, frame_width: any) => void;
|
|
311
|
+
/** Every table the script has made and not deleted, oldest first. @getter */
|
|
312
|
+
all: (ctx: Context) => string[];
|
|
313
|
+
clear: (ctx: Context, id: any) => void;
|
|
314
|
+
delete: (ctx: Context, id: any) => void;
|
|
315
|
+
};
|
|
316
|
+
/** `xloc` — whether an x coordinate is a bar index or a UNIX time. */
|
|
317
|
+
export declare const xloc: {
|
|
318
|
+
bar_index: string;
|
|
319
|
+
bar_time: string;
|
|
320
|
+
};
|
|
321
|
+
/** `yloc` — whether a y coordinate is a price or is pinned to the bar. */
|
|
322
|
+
export declare const yloc: {
|
|
323
|
+
price: string;
|
|
324
|
+
abovebar: string;
|
|
325
|
+
belowbar: string;
|
|
326
|
+
};
|
|
327
|
+
/** `extend` — how far a line or box runs past its endpoints. */
|
|
328
|
+
export declare const extend: {
|
|
329
|
+
none: string;
|
|
330
|
+
right: string;
|
|
331
|
+
left: string;
|
|
332
|
+
both: string;
|
|
333
|
+
};
|
|
334
|
+
/** `position` — where a table sits on the chart. */
|
|
335
|
+
export declare const position: {
|
|
336
|
+
top_left: string;
|
|
337
|
+
top_center: string;
|
|
338
|
+
top_right: string;
|
|
339
|
+
middle_left: string;
|
|
340
|
+
middle_center: string;
|
|
341
|
+
middle_right: string;
|
|
342
|
+
bottom_left: string;
|
|
343
|
+
bottom_center: string;
|
|
344
|
+
bottom_right: string;
|
|
345
|
+
};
|
|
346
|
+
/** `text.align_*` — v4 spells these on the `text` namespace. */
|
|
347
|
+
export declare const text: {
|
|
348
|
+
align_left: string;
|
|
349
|
+
align_center: string;
|
|
350
|
+
align_right: string;
|
|
351
|
+
align_top: string;
|
|
352
|
+
align_bottom: string;
|
|
353
|
+
/**
|
|
354
|
+
* `text.wrap_*` — a BOX's text wrapping, and v5 only.
|
|
355
|
+
*
|
|
356
|
+
* "If its value is text.wrap_auto, the box wraps the text to ensure it does
|
|
357
|
+
* not span past its vertical borders. It also clips the wrapped text when
|
|
358
|
+
* it extends past the bottom. If the value is text.wrap_none, the box
|
|
359
|
+
* displays the text on a single line that can extend beyond its borders.
|
|
360
|
+
* The default is text.wrap_none."
|
|
361
|
+
*
|
|
362
|
+
* Gated by name in V5_ONLY_NAMES: `text` itself is a v4 namespace, and box
|
|
363
|
+
* text arrived long after it.
|
|
364
|
+
*/
|
|
365
|
+
wrap_auto: string;
|
|
366
|
+
wrap_none: string;
|
|
367
|
+
/**
|
|
368
|
+
* `text.format_*` — v6 (November 2024): "whether displayed text is bold,
|
|
369
|
+
* italic, or both". Both is the SUM of the two, which is why these are bit
|
|
370
|
+
* flags rather than names: `text.format_bold + text.format_italic` is how a
|
|
371
|
+
* script asks for it, and 1 + 2 = 3 is unambiguous where "bold" + "italic"
|
|
372
|
+
* would not be. Gated by name in V6_ONLY_NAMES.
|
|
373
|
+
*/
|
|
374
|
+
format_none: number;
|
|
375
|
+
format_bold: number;
|
|
376
|
+
format_italic: number;
|
|
377
|
+
};
|
|
378
|
+
export declare const polyline: {
|
|
379
|
+
new: (ctx: Context, points: any, curved?: any, closed?: any, xloc?: any, line_color?: any, fill_color?: any, line_style?: any, line_width?: any, force_overlay?: any) => string;
|
|
380
|
+
delete: (ctx: Context, id: any) => void;
|
|
381
|
+
/**
|
|
382
|
+
* Every polyline currently on the chart, oldest first.
|
|
383
|
+
* @getter
|
|
384
|
+
*/
|
|
385
|
+
all: (ctx: Context) => string[];
|
|
386
|
+
};
|
|
387
|
+
export declare const linefill: {
|
|
388
|
+
/**
|
|
389
|
+
* A linefill on an `na` line is `na` and creates nothing.
|
|
390
|
+
*
|
|
391
|
+
* Logged on TradingView with `line nl = na; linefill.new(nl, nl, color.red)`:
|
|
392
|
+
* `linefill.all.size()` is 0 before and after
|
|
393
|
+
* (conformance/v5/parity/probe_drawing_limits.BTCUSDT.5.csv, `LF|0|0`).
|
|
394
|
+
* The case where only ONE line is `na` was not logged; it is INFERRED from
|
|
395
|
+
* that, since a fill is the space between two lines and has none with one.
|
|
396
|
+
*/
|
|
397
|
+
new: (ctx: Context, line1: any, line2: any, color: any) => string | number;
|
|
398
|
+
set_color: (ctx: Context, id: any, color: any) => void;
|
|
399
|
+
get_line1: (ctx: Context, id: any) => any;
|
|
400
|
+
get_line2: (ctx: Context, id: any) => any;
|
|
401
|
+
delete: (ctx: Context, id: any) => void;
|
|
402
|
+
/**
|
|
403
|
+
* Every linefill currently on the chart, oldest first.
|
|
404
|
+
* @getter
|
|
405
|
+
*/
|
|
406
|
+
all: (ctx: Context) => string[];
|
|
407
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `runtime.*` namespace — v5's script-authored failure path.
|
|
3
|
+
*
|
|
4
|
+
* One member: `runtime.error(message)`, which halts the script with the
|
|
5
|
+
* author's own message. It exists so a script can refuse to produce numbers it
|
|
6
|
+
* knows are wrong — the same stance this engine takes everywhere else — rather
|
|
7
|
+
* than plotting `na` and leaving the reader to guess why.
|
|
8
|
+
*/
|
|
9
|
+
import { Context } from "../context.js";
|
|
10
|
+
/**
|
|
11
|
+
* Thrown by `runtime.error`. A distinct class so a host can tell an intentional
|
|
12
|
+
* script-level halt from an engine defect: the first is the script working as
|
|
13
|
+
* written, the second is a bug here.
|
|
14
|
+
*/
|
|
15
|
+
export declare class PineRuntimeError extends Error {
|
|
16
|
+
readonly bar: number;
|
|
17
|
+
constructor(message: string, bar: number);
|
|
18
|
+
}
|
|
19
|
+
export declare const runtime: {
|
|
20
|
+
error: (ctx: Context, message: any) => never;
|
|
21
|
+
};
|