oakscriptjs 0.23.0 → 0.25.0
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/README.md +25 -1
- package/bin/oakscript.mjs +10 -3
- package/dist/cjs/box/index.d.ts +348 -289
- package/dist/cjs/box/index.d.ts.map +1 -1
- package/dist/cjs/box/index.js.map +2 -2
- package/dist/cjs/check/node.d.ts.map +1 -1
- package/dist/cjs/check/node.js +1 -0
- package/dist/cjs/check/node.js.map +2 -2
- package/dist/cjs/check/preview.d.ts +31 -0
- package/dist/cjs/check/preview.d.ts.map +1 -0
- package/dist/cjs/check/preview.js +303 -0
- package/dist/cjs/check/preview.js.map +7 -0
- package/dist/cjs/color/index.d.ts +11 -11
- package/dist/cjs/color/index.js.map +1 -1
- package/dist/cjs/color/parse.d.ts +2 -0
- package/dist/cjs/color/parse.d.ts.map +1 -1
- package/dist/cjs/color/parse.js +6 -0
- package/dist/cjs/color/parse.js.map +2 -2
- package/dist/cjs/compare/index.d.ts +76 -12
- package/dist/cjs/compare/index.d.ts.map +1 -1
- package/dist/cjs/compare/index.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +28 -5
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +14 -0
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/label/index.d.ts +265 -187
- package/dist/cjs/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js +1 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/line/index.d.ts +247 -207
- package/dist/cjs/line/index.d.ts.map +1 -1
- package/dist/cjs/line/index.js.map +2 -2
- package/dist/cjs/linefill/index.d.ts +61 -89
- package/dist/cjs/linefill/index.d.ts.map +1 -1
- package/dist/cjs/linefill/index.js.map +2 -2
- package/dist/cjs/math/index.d.ts +49 -40
- package/dist/cjs/math/index.d.ts.map +1 -1
- package/dist/cjs/math/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +57 -78
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/runtime/input-active.d.ts +2 -2
- package/dist/cjs/runtime/input-active.js.map +1 -1
- package/dist/cjs/runtime/series.d.ts +241 -161
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +223 -127
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/api/alert.d.ts +37 -0
- package/dist/cjs/script/api/alert.d.ts.map +1 -0
- package/dist/cjs/script/api/alert.js +17 -0
- package/dist/cjs/script/api/alert.js.map +7 -0
- package/dist/cjs/script/api/calc.d.ts +232 -0
- package/dist/cjs/script/api/calc.d.ts.map +1 -0
- package/dist/cjs/script/api/calc.js +17 -0
- package/dist/cjs/script/api/calc.js.map +7 -0
- package/dist/cjs/script/api/color.d.ts +213 -0
- package/dist/cjs/script/api/color.d.ts.map +1 -0
- package/dist/cjs/script/api/color.js +17 -0
- package/dist/cjs/script/api/color.js.map +7 -0
- package/dist/cjs/script/api/context.d.ts +764 -0
- package/dist/cjs/script/api/context.d.ts.map +1 -0
- package/dist/cjs/script/api/context.js +17 -0
- package/dist/cjs/script/api/context.js.map +7 -0
- package/dist/cjs/script/api/log.d.ts +58 -0
- package/dist/cjs/script/api/log.d.ts.map +1 -0
- package/dist/cjs/script/api/log.js +17 -0
- package/dist/cjs/script/api/log.js.map +7 -0
- package/dist/cjs/script/api/strategy.d.ts +391 -0
- package/dist/cjs/script/api/strategy.d.ts.map +1 -0
- package/dist/cjs/script/api/strategy.js +17 -0
- package/dist/cjs/script/api/strategy.js.map +7 -0
- package/dist/cjs/script/api/ta.d.ts +1012 -0
- package/dist/cjs/script/api/ta.d.ts.map +1 -0
- package/dist/cjs/script/api/ta.js +17 -0
- package/dist/cjs/script/api/ta.js.map +7 -0
- package/dist/cjs/script/api/table.d.ts +479 -0
- package/dist/cjs/script/api/table.d.ts.map +1 -0
- package/dist/cjs/script/api/table.js +17 -0
- package/dist/cjs/script/api/table.js.map +7 -0
- package/dist/cjs/script/constants.d.ts +228 -83
- package/dist/cjs/script/constants.d.ts.map +1 -1
- package/dist/cjs/script/constants.js +87 -0
- package/dist/cjs/script/constants.js.map +2 -2
- package/dist/cjs/script/define.d.ts +94 -0
- package/dist/cjs/script/define.d.ts.map +1 -0
- package/dist/cjs/script/define.js +127 -0
- package/dist/cjs/script/define.js.map +7 -0
- package/dist/cjs/script/drawing-args.d.ts.map +1 -1
- package/dist/cjs/script/drawing-args.js +1 -1
- package/dist/cjs/script/drawing-args.js.map +2 -2
- package/dist/cjs/script/formula.d.ts +53 -0
- package/dist/cjs/script/formula.d.ts.map +1 -0
- package/dist/cjs/script/formula.js +402 -0
- package/dist/cjs/script/formula.js.map +7 -0
- package/dist/cjs/script/globals.d.ts +10 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/index.d.ts +1065 -1006
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +532 -61
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/script/json.d.ts +117 -0
- package/dist/cjs/script/json.d.ts.map +1 -0
- package/dist/cjs/script/json.js +321 -0
- package/dist/cjs/script/json.js.map +7 -0
- package/dist/cjs/security/other.d.ts +8 -3
- package/dist/cjs/security/other.d.ts.map +1 -1
- package/dist/cjs/security/other.js +23 -6
- package/dist/cjs/security/other.js.map +2 -2
- package/dist/cjs/str/index.d.ts +50 -75
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +2 -2
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/strategy/index.d.ts +102 -1
- package/dist/cjs/strategy/index.d.ts.map +1 -1
- package/dist/cjs/strategy/index.js.map +2 -2
- package/dist/cjs/table/index.d.ts +330 -49
- package/dist/cjs/table/index.d.ts.map +1 -1
- package/dist/cjs/table/index.js +55 -27
- package/dist/cjs/table/index.js.map +2 -2
- package/dist/cjs/text/index.d.ts +12 -14
- package/dist/cjs/text/index.d.ts.map +1 -1
- package/dist/cjs/text/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +15 -8
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +12 -3
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/esm/box/index.d.ts +348 -289
- package/dist/esm/box/index.d.ts.map +1 -1
- package/dist/esm/box/index.js +276 -276
- package/dist/esm/box/index.js.map +1 -1
- package/dist/esm/check/node.d.ts.map +1 -1
- package/dist/esm/check/node.js +1 -0
- package/dist/esm/check/node.js.map +1 -1
- package/dist/esm/check/preview.d.ts +31 -0
- package/dist/esm/check/preview.d.ts.map +1 -0
- package/dist/esm/check/preview.js +296 -0
- package/dist/esm/check/preview.js.map +1 -0
- package/dist/esm/color/index.d.ts +11 -11
- package/dist/esm/color/index.js +11 -11
- package/dist/esm/color/parse.d.ts +2 -0
- package/dist/esm/color/parse.d.ts.map +1 -1
- package/dist/esm/color/parse.js +7 -0
- package/dist/esm/color/parse.js.map +1 -1
- package/dist/esm/compare/index.d.ts +76 -12
- package/dist/esm/compare/index.d.ts.map +1 -1
- package/dist/esm/compare/index.js +76 -12
- package/dist/esm/compare/index.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +28 -5
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +39 -3
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/label/index.d.ts +265 -187
- package/dist/esm/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js +207 -177
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/line/index.d.ts +247 -207
- package/dist/esm/line/index.d.ts.map +1 -1
- package/dist/esm/line/index.js +202 -194
- package/dist/esm/line/index.js.map +1 -1
- package/dist/esm/linefill/index.d.ts +61 -89
- package/dist/esm/linefill/index.d.ts.map +1 -1
- package/dist/esm/linefill/index.js +61 -89
- package/dist/esm/linefill/index.js.map +1 -1
- package/dist/esm/math/index.d.ts +49 -40
- package/dist/esm/math/index.d.ts.map +1 -1
- package/dist/esm/math/index.js +22 -9
- package/dist/esm/math/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +57 -78
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +57 -78
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/runtime/input-active.d.ts +2 -2
- package/dist/esm/runtime/input-active.js +2 -2
- package/dist/esm/runtime/series.d.ts +241 -161
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +241 -161
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/api/alert.d.ts +37 -0
- package/dist/esm/script/api/alert.d.ts.map +1 -0
- package/dist/esm/script/api/alert.js +7 -0
- package/dist/esm/script/api/alert.js.map +1 -0
- package/dist/esm/script/api/calc.d.ts +232 -0
- package/dist/esm/script/api/calc.d.ts.map +1 -0
- package/dist/esm/script/api/calc.js +6 -0
- package/dist/esm/script/api/calc.js.map +1 -0
- package/dist/esm/script/api/color.d.ts +213 -0
- package/dist/esm/script/api/color.d.ts.map +1 -0
- package/dist/esm/script/api/color.js +6 -0
- package/dist/esm/script/api/color.js.map +1 -0
- package/dist/esm/script/api/context.d.ts +764 -0
- package/dist/esm/script/api/context.d.ts.map +1 -0
- package/dist/esm/script/api/context.js +7 -0
- package/dist/esm/script/api/context.js.map +1 -0
- package/dist/esm/script/api/log.d.ts +58 -0
- package/dist/esm/script/api/log.d.ts.map +1 -0
- package/dist/esm/script/api/log.js +6 -0
- package/dist/esm/script/api/log.js.map +1 -0
- package/dist/esm/script/api/strategy.d.ts +391 -0
- package/dist/esm/script/api/strategy.d.ts.map +1 -0
- package/dist/esm/script/api/strategy.js +7 -0
- package/dist/esm/script/api/strategy.js.map +1 -0
- package/dist/esm/script/api/ta.d.ts +1012 -0
- package/dist/esm/script/api/ta.d.ts.map +1 -0
- package/dist/esm/script/api/ta.js +6 -0
- package/dist/esm/script/api/ta.js.map +1 -0
- package/dist/esm/script/api/table.d.ts +479 -0
- package/dist/esm/script/api/table.d.ts.map +1 -0
- package/dist/esm/script/api/table.js +7 -0
- package/dist/esm/script/api/table.js.map +1 -0
- package/dist/esm/script/constants.d.ts +228 -83
- package/dist/esm/script/constants.d.ts.map +1 -1
- package/dist/esm/script/constants.js +110 -24
- package/dist/esm/script/constants.js.map +1 -1
- package/dist/esm/script/define.d.ts +94 -0
- package/dist/esm/script/define.d.ts.map +1 -0
- package/dist/esm/script/define.js +136 -0
- package/dist/esm/script/define.js.map +1 -0
- package/dist/esm/script/drawing-args.d.ts.map +1 -1
- package/dist/esm/script/drawing-args.js +2 -1
- package/dist/esm/script/drawing-args.js.map +1 -1
- package/dist/esm/script/formula.d.ts +53 -0
- package/dist/esm/script/formula.d.ts.map +1 -0
- package/dist/esm/script/formula.js +408 -0
- package/dist/esm/script/formula.js.map +1 -0
- package/dist/esm/script/globals.d.ts +10 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/index.d.ts +1065 -1006
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +1099 -153
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/script/json.d.ts +117 -0
- package/dist/esm/script/json.d.ts.map +1 -0
- package/dist/esm/script/json.js +375 -0
- package/dist/esm/script/json.js.map +1 -0
- package/dist/esm/security/other.d.ts +8 -3
- package/dist/esm/security/other.d.ts.map +1 -1
- package/dist/esm/security/other.js +45 -10
- package/dist/esm/security/other.js.map +1 -1
- package/dist/esm/str/index.d.ts +50 -75
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +51 -76
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/strategy/index.d.ts +102 -1
- package/dist/esm/strategy/index.d.ts.map +1 -1
- package/dist/esm/strategy/index.js +1 -1
- package/dist/esm/strategy/index.js.map +1 -1
- package/dist/esm/table/index.d.ts +330 -49
- package/dist/esm/table/index.d.ts.map +1 -1
- package/dist/esm/table/index.js +372 -61
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/text/index.d.ts +12 -14
- package/dist/esm/text/index.d.ts.map +1 -1
- package/dist/esm/text/index.js +12 -14
- package/dist/esm/text/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +15 -8
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +15 -8
- package/dist/esm/types/index.js.map +1 -1
- package/docs/first-indicator.md +152 -0
- package/docs/guide.md +1185 -0
- package/docs/inventory.md +772 -0
- package/docs/no-code.md +207 -0
- package/docs/recipes.md +202 -0
- package/package.json +2 -1
- package/skills/oakscript/SKILL.md +8 -0
- package/skills/oakscript/reference/errors.md +3 -2
- package/skills/oakscript/reference/timeframes-symbols.md +4 -0
- package/src/box/index.ts +348 -289
- package/src/check/node.ts +1 -0
- package/src/check/preview.ts +307 -0
- package/src/color/index.ts +11 -11
- package/src/color/parse.ts +7 -0
- package/src/compare/index.ts +76 -12
- package/src/drawing/registry.ts +44 -5
- package/src/index.ts +1 -1
- package/src/label/index.ts +267 -189
- package/src/line/index.ts +248 -208
- package/src/linefill/index.ts +61 -89
- package/src/math/index.ts +51 -42
- package/src/polyline/index.ts +57 -78
- package/src/runtime/input-active.ts +2 -2
- package/src/runtime/series.ts +243 -163
- package/src/script/api/alert.ts +43 -0
- package/src/script/api/calc.ts +250 -0
- package/src/script/api/color.ts +245 -0
- package/src/script/api/context.ts +944 -0
- package/src/script/api/log.ts +60 -0
- package/src/script/api/strategy.ts +410 -0
- package/src/script/api/ta.ts +1115 -0
- package/src/script/api/table.ts +538 -0
- package/src/script/constants.ts +229 -25
- package/src/script/define.ts +221 -0
- package/src/script/drawing-args.ts +2 -1
- package/src/script/formula.ts +438 -0
- package/src/script/globals.ts +10 -0
- package/src/script/index.ts +1520 -241
- package/src/script/json.ts +457 -0
- package/src/security/other.ts +43 -9
- package/src/str/index.ts +51 -76
- package/src/strategy/index.ts +102 -1
- package/src/table/index.ts +388 -62
- package/src/text/index.ts +12 -14
- package/src/types/index.ts +15 -8
|
@@ -1,125 +1,97 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Linefill namespace
|
|
3
|
-
* Functions for creating and manipulating linefill drawing objects.
|
|
2
|
+
* Linefill namespace: functions that fill the area between two lines (`linefill.*`).
|
|
4
3
|
*
|
|
5
4
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* and provide a way to retrieve the underlying line references.
|
|
5
|
+
* A linefill colours the space between two lines and follows them when they move. It is deleted with either line,
|
|
6
|
+
* and two lines share one linefill.
|
|
9
7
|
*
|
|
10
8
|
* @version 6
|
|
11
9
|
*/
|
|
12
10
|
import type { Linefill, Line, color } from '../types/index.js';
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* - Automatically deleted if either line is deleted
|
|
24
|
-
* - One linefill per pair of lines, as in PineScript (#174): when both lines already belong to a live linefill
|
|
25
|
-
* (`linefill.new(b, a)` after `linefill.new(a, b)`, or `linefill.new(a, a)` after either), that linefill is
|
|
26
|
-
* returned with the new colour instead of a new one; with several, the one created or returned last
|
|
27
|
-
* - If both lines extend in same direction, fill extends too
|
|
28
|
-
* - Purely visual in PineScript, but getters allow retrieving line references
|
|
29
|
-
*
|
|
12
|
+
* Fills the area between two lines with a colour and returns the linefill's handle. The fill follows the lines when
|
|
13
|
+
* they move or extend, and is deleted when either line is deleted. Two lines have one linefill: when they already
|
|
14
|
+
* have one, that linefill gets the new colour and is returned instead of a new one. An `na` line gives `na`.
|
|
15
|
+
* The arguments can also be given by name in an object.
|
|
16
|
+
* @param line1 - The first line.
|
|
17
|
+
* @param line2 - The second line.
|
|
18
|
+
* @param fillColor - Fill colour; a transparent one (`color.new(color.blue, 85)`) keeps the bars visible.
|
|
19
|
+
* Default: none.
|
|
20
|
+
* @returns The linefill.
|
|
30
21
|
* @example
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* // Fill channel with color
|
|
39
|
-
* const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20'); // Transparent blue
|
|
22
|
+
* ```js
|
|
23
|
+
* eachBar((c) => {
|
|
24
|
+
* if (c.i !== c.n - 1) return;
|
|
25
|
+
* const top = line.new(c.i - 20, c.get(high, 20), c.i, c.high, { extend: extend.right });
|
|
26
|
+
* const bottom = line.new(c.i - 20, c.get(low, 20), c.i, c.low, { extend: extend.right });
|
|
27
|
+
* linefill.new(top, bottom, color.new(color.blue, 85));
|
|
28
|
+
* });
|
|
40
29
|
* ```
|
|
41
30
|
*/
|
|
42
31
|
export declare function new_linefill(line1: Line, line2: Line, fillColor?: color): Linefill;
|
|
43
32
|
/**
|
|
44
|
-
* Returns the first line
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
47
|
-
* @returns First line object
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* Can be used to retrieve and manipulate the first line.
|
|
51
|
-
*
|
|
33
|
+
* Returns the first line of a linefill, to read or move it.
|
|
34
|
+
* @param id - The linefill.
|
|
35
|
+
* @returns The first line given to `linefill.new()`.
|
|
52
36
|
* @example
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* line.set_y2(line1, 175); // Update upper line's second point
|
|
37
|
+
* ```js
|
|
38
|
+
* eachBar((c) => {
|
|
39
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
40
|
+
* line.set_color(linefill.get_line1(lf), color.green);
|
|
41
|
+
* });
|
|
59
42
|
* ```
|
|
60
43
|
*/
|
|
61
44
|
export declare function get_line1(id: Linefill): Line;
|
|
62
45
|
/**
|
|
63
|
-
* Returns the second line
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
* @returns Second line object
|
|
67
|
-
*
|
|
68
|
-
* @remarks
|
|
69
|
-
* Can be used to retrieve and manipulate the second line.
|
|
70
|
-
*
|
|
46
|
+
* Returns the second line of a linefill, to read or move it.
|
|
47
|
+
* @param id - The linefill.
|
|
48
|
+
* @returns The second line given to `linefill.new()`.
|
|
71
49
|
* @example
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* line.set_y2(line2, 145); // Update lower line's second point
|
|
50
|
+
* ```js
|
|
51
|
+
* eachBar((c) => {
|
|
52
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
53
|
+
* line.set_color(linefill.get_line2(lf), color.red);
|
|
54
|
+
* });
|
|
78
55
|
* ```
|
|
79
56
|
*/
|
|
80
57
|
export declare function get_line2(id: Linefill): Line;
|
|
81
58
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
* @
|
|
86
|
-
* @returns Modified linefill object
|
|
87
|
-
*
|
|
88
|
-
* @remarks
|
|
89
|
-
* Useful for dynamically changing channel colors based on conditions.
|
|
90
|
-
*
|
|
59
|
+
* Changes the fill colour. Does nothing on a deleted linefill.
|
|
60
|
+
* @param id - The linefill.
|
|
61
|
+
* @param fillColor - New fill colour.
|
|
62
|
+
* @returns The same linefill.
|
|
91
63
|
* @example
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* linefill.set_color(channelFill, '#00FF0020'); // Green
|
|
98
|
-
* } else {
|
|
99
|
-
* linefill.set_color(channelFill, '#FF000020'); // Red
|
|
100
|
-
* }
|
|
64
|
+
* ```js
|
|
65
|
+
* eachBar((c) => {
|
|
66
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
67
|
+
* linefill.set_color(lf, c.close > c.open ? color.new(color.green, 80) : color.new(color.red, 80));
|
|
68
|
+
* });
|
|
101
69
|
* ```
|
|
102
70
|
*/
|
|
103
71
|
export declare function set_color(id: Linefill, fillColor: color): Linefill;
|
|
104
72
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @param id -
|
|
108
|
-
*
|
|
109
|
-
* @remarks
|
|
110
|
-
* Removes the linefill from `linefill.all()`. As in PineScript, the deleted linefill is `na`: its getters
|
|
111
|
-
* return NaN and its setters do nothing. Deleting it twice has no effect.
|
|
112
|
-
*
|
|
73
|
+
* Removes the fill from the chart and from `linefill.all`; the two lines stay. Afterwards its setters do nothing;
|
|
74
|
+
* deleting it again does nothing.
|
|
75
|
+
* @param id - The linefill to delete.
|
|
113
76
|
* @example
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* linefill.
|
|
117
|
-
*
|
|
77
|
+
* ```js
|
|
78
|
+
* eachBar((c) => {
|
|
79
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
80
|
+
* if (c.close < c.open) linefill.delete(lf);
|
|
81
|
+
* });
|
|
118
82
|
* ```
|
|
119
83
|
*/
|
|
120
84
|
export declare function delete_linefill(id: Linefill): void;
|
|
121
85
|
/**
|
|
122
|
-
*
|
|
86
|
+
* Returns the linefills that are still on the chart, oldest first. The array is a copy.
|
|
87
|
+
* (In a script, `linefill.all` is read as a value, without a call.)
|
|
88
|
+
* @returns The live linefills in creation order.
|
|
89
|
+
* @example
|
|
90
|
+
* ```js
|
|
91
|
+
* eachBar((c) => {
|
|
92
|
+
* if (c.i === c.n - 1) for (const lf of linefill.all) linefill.set_color(lf, color.new(color.gray, 80));
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
123
95
|
*/
|
|
124
96
|
export declare function all(): Linefill[];
|
|
125
97
|
export { new_linefill as new };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/linefill/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/linefill/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAoBlF;AAeD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAE5C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAE5C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAG,QAAQ,CAIlE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAElD;AAGD;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,IAAI,QAAQ,EAAE,CAEhC;AAGD,OAAO,EAAE,YAAY,IAAI,GAAG,EAAE,CAAC;AAC/B,OAAO,EAAE,eAAe,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -1,42 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Linefill namespace
|
|
3
|
-
* Functions for creating and manipulating linefill drawing objects.
|
|
2
|
+
* Linefill namespace: functions that fill the area between two lines (`linefill.*`).
|
|
4
3
|
*
|
|
5
4
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* and provide a way to retrieve the underlying line references.
|
|
5
|
+
* A linefill colours the space between two lines and follows them when they move. It is deleted with either line,
|
|
6
|
+
* and two lines share one linefill.
|
|
9
7
|
*
|
|
10
8
|
* @version 6
|
|
11
9
|
*/
|
|
12
10
|
import { Stamped, all as allDrawings, isDeleted, liveFillsOf, register, remove } from '../drawing/registry.js';
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* - Automatically deleted if either line is deleted
|
|
24
|
-
* - One linefill per pair of lines, as in PineScript (#174): when both lines already belong to a live linefill
|
|
25
|
-
* (`linefill.new(b, a)` after `linefill.new(a, b)`, or `linefill.new(a, a)` after either), that linefill is
|
|
26
|
-
* returned with the new colour instead of a new one; with several, the one created or returned last
|
|
27
|
-
* - If both lines extend in same direction, fill extends too
|
|
28
|
-
* - Purely visual in PineScript, but getters allow retrieving line references
|
|
29
|
-
*
|
|
12
|
+
* Fills the area between two lines with a colour and returns the linefill's handle. The fill follows the lines when
|
|
13
|
+
* they move or extend, and is deleted when either line is deleted. Two lines have one linefill: when they already
|
|
14
|
+
* have one, that linefill gets the new colour and is returned instead of a new one. An `na` line gives `na`.
|
|
15
|
+
* The arguments can also be given by name in an object.
|
|
16
|
+
* @param line1 - The first line.
|
|
17
|
+
* @param line2 - The second line.
|
|
18
|
+
* @param fillColor - Fill colour; a transparent one (`color.new(color.blue, 85)`) keeps the bars visible.
|
|
19
|
+
* Default: none.
|
|
20
|
+
* @returns The linefill.
|
|
30
21
|
* @example
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* // Fill channel with color
|
|
39
|
-
* const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20'); // Transparent blue
|
|
22
|
+
* ```js
|
|
23
|
+
* eachBar((c) => {
|
|
24
|
+
* if (c.i !== c.n - 1) return;
|
|
25
|
+
* const top = line.new(c.i - 20, c.get(high, 20), c.i, c.high, { extend: extend.right });
|
|
26
|
+
* const bottom = line.new(c.i - 20, c.get(low, 20), c.i, c.low, { extend: extend.right });
|
|
27
|
+
* linefill.new(top, bottom, color.new(color.blue, 85));
|
|
28
|
+
* });
|
|
40
29
|
* ```
|
|
41
30
|
*/
|
|
42
31
|
export function new_linefill(line1, line2, fillColor) {
|
|
@@ -76,67 +65,46 @@ class Touched extends Stamped {
|
|
|
76
65
|
}
|
|
77
66
|
let touchCount = 0;
|
|
78
67
|
/**
|
|
79
|
-
* Returns the first line
|
|
80
|
-
*
|
|
81
|
-
* @
|
|
82
|
-
* @returns First line object
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* Can be used to retrieve and manipulate the first line.
|
|
86
|
-
*
|
|
68
|
+
* Returns the first line of a linefill, to read or move it.
|
|
69
|
+
* @param id - The linefill.
|
|
70
|
+
* @returns The first line given to `linefill.new()`.
|
|
87
71
|
* @example
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* line.set_y2(line1, 175); // Update upper line's second point
|
|
72
|
+
* ```js
|
|
73
|
+
* eachBar((c) => {
|
|
74
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
75
|
+
* line.set_color(linefill.get_line1(lf), color.green);
|
|
76
|
+
* });
|
|
94
77
|
* ```
|
|
95
78
|
*/
|
|
96
79
|
export function get_line1(id) {
|
|
97
80
|
return id.line1;
|
|
98
81
|
}
|
|
99
82
|
/**
|
|
100
|
-
* Returns the second line
|
|
101
|
-
*
|
|
102
|
-
* @
|
|
103
|
-
* @returns Second line object
|
|
104
|
-
*
|
|
105
|
-
* @remarks
|
|
106
|
-
* Can be used to retrieve and manipulate the second line.
|
|
107
|
-
*
|
|
83
|
+
* Returns the second line of a linefill, to read or move it.
|
|
84
|
+
* @param id - The linefill.
|
|
85
|
+
* @returns The second line given to `linefill.new()`.
|
|
108
86
|
* @example
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* line.set_y2(line2, 145); // Update lower line's second point
|
|
87
|
+
* ```js
|
|
88
|
+
* eachBar((c) => {
|
|
89
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
90
|
+
* line.set_color(linefill.get_line2(lf), color.red);
|
|
91
|
+
* });
|
|
115
92
|
* ```
|
|
116
93
|
*/
|
|
117
94
|
export function get_line2(id) {
|
|
118
95
|
return id.line2;
|
|
119
96
|
}
|
|
120
97
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* @param
|
|
124
|
-
* @
|
|
125
|
-
* @returns Modified linefill object
|
|
126
|
-
*
|
|
127
|
-
* @remarks
|
|
128
|
-
* Useful for dynamically changing channel colors based on conditions.
|
|
129
|
-
*
|
|
98
|
+
* Changes the fill colour. Does nothing on a deleted linefill.
|
|
99
|
+
* @param id - The linefill.
|
|
100
|
+
* @param fillColor - New fill colour.
|
|
101
|
+
* @returns The same linefill.
|
|
130
102
|
* @example
|
|
131
|
-
* ```
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* linefill.set_color(channelFill, '#00FF0020'); // Green
|
|
137
|
-
* } else {
|
|
138
|
-
* linefill.set_color(channelFill, '#FF000020'); // Red
|
|
139
|
-
* }
|
|
103
|
+
* ```js
|
|
104
|
+
* eachBar((c) => {
|
|
105
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
106
|
+
* linefill.set_color(lf, c.close > c.open ? color.new(color.green, 80) : color.new(color.red, 80));
|
|
107
|
+
* });
|
|
140
108
|
* ```
|
|
141
109
|
*/
|
|
142
110
|
export function set_color(id, fillColor) {
|
|
@@ -146,26 +114,30 @@ export function set_color(id, fillColor) {
|
|
|
146
114
|
return id;
|
|
147
115
|
}
|
|
148
116
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @param id -
|
|
152
|
-
*
|
|
153
|
-
* @remarks
|
|
154
|
-
* Removes the linefill from `linefill.all()`. As in PineScript, the deleted linefill is `na`: its getters
|
|
155
|
-
* return NaN and its setters do nothing. Deleting it twice has no effect.
|
|
156
|
-
*
|
|
117
|
+
* Removes the fill from the chart and from `linefill.all`; the two lines stay. Afterwards its setters do nothing;
|
|
118
|
+
* deleting it again does nothing.
|
|
119
|
+
* @param id - The linefill to delete.
|
|
157
120
|
* @example
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* linefill.
|
|
161
|
-
*
|
|
121
|
+
* ```js
|
|
122
|
+
* eachBar((c) => {
|
|
123
|
+
* const lf = linefill.new(line.new(c.i - 5, c.high, c.i, c.high), line.new(c.i - 5, c.low, c.i, c.low));
|
|
124
|
+
* if (c.close < c.open) linefill.delete(lf);
|
|
125
|
+
* });
|
|
162
126
|
* ```
|
|
163
127
|
*/
|
|
164
128
|
export function delete_linefill(id) {
|
|
165
129
|
remove('linefill', id);
|
|
166
130
|
}
|
|
167
131
|
/**
|
|
168
|
-
*
|
|
132
|
+
* Returns the linefills that are still on the chart, oldest first. The array is a copy.
|
|
133
|
+
* (In a script, `linefill.all` is read as a value, without a call.)
|
|
134
|
+
* @returns The live linefills in creation order.
|
|
135
|
+
* @example
|
|
136
|
+
* ```js
|
|
137
|
+
* eachBar((c) => {
|
|
138
|
+
* if (c.i === c.n - 1) for (const lf of linefill.all) linefill.set_color(lf, color.new(color.gray, 80));
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
169
141
|
*/
|
|
170
142
|
export function all() {
|
|
171
143
|
return allDrawings('linefill');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/linefill/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/linefill/index.ts"],"names":[],"mappings":"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"}
|