oakscriptjs 0.24.0 → 0.25.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/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 +1067 -1006
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +530 -60
- 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/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 +1067 -1006
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +1096 -151
- 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/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/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 +1519 -239
- package/src/script/json.ts +457 -0
- 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
package/dist/esm/box/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Box namespace
|
|
3
|
-
* Functions for creating and manipulating box drawing objects.
|
|
2
|
+
* Box namespace: functions that create, read, change and delete box drawings (`box.*`).
|
|
4
3
|
*
|
|
5
4
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
* (
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* - Rectangle pattern recognition
|
|
5
|
+
* A box is a rectangle between two x coordinates (left, right) and two prices (top, bottom), with an optional text
|
|
6
|
+
* inside. Its x coordinates are bar indexes (`xloc.bar_index`, the default), UNIX times in ms (`xloc.bar_time`) or
|
|
7
|
+
* percents of the pane's width (`xloc.pane`). The getters (`box.get_top()`...) let a script test whether the price
|
|
8
|
+
* entered or left a zone: gaps, ranges, supply and demand areas.
|
|
11
9
|
*
|
|
12
10
|
* @version 6
|
|
13
11
|
*/
|
|
@@ -15,428 +13,489 @@ import type { ChartPoint, Box, color } from '../types/index.js';
|
|
|
15
13
|
type BoxXloc = 'bar_index' | 'bar_time' | 'pane';
|
|
16
14
|
type BoxExtend = 'none' | 'left' | 'right' | 'both';
|
|
17
15
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* -
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
16
|
+
* Draws a box between two chart points and returns its handle, to change or delete it later.
|
|
17
|
+
* With `xloc.bar_index` the x of a point is its `index`, with `xloc.bar_time` its `time`. The arguments after the
|
|
18
|
+
* points can also be given by name in an object. Boxes above `max_boxes_count` (default 50) are deleted oldest first.
|
|
19
|
+
* @param top_left - Top-left corner (`chart.point.from_index(...)`, `chart.point.now()`...).
|
|
20
|
+
* @param bottom_right - Bottom-right corner.
|
|
21
|
+
* @param border_color - Colour of the border. Default: blue (#2962FF).
|
|
22
|
+
* @param border_width - Width of the border in pixels; 0 draws no border. Default: 1.
|
|
23
|
+
* @param border_style - `line.style_solid`, `line.style_dotted` or `line.style_dashed`. Default: `line.style_solid`.
|
|
24
|
+
* @param extend - Extends the box sideways to the edge of the pane: `extend.none`, `extend.left`, `extend.right` or
|
|
25
|
+
* `extend.both`. Default: `extend.none`.
|
|
26
|
+
* @param xloc - What the x coordinates are: `xloc.bar_index`, `xloc.bar_time` or `xloc.pane`. Default: `xloc.bar_index`.
|
|
27
|
+
* @param bgcolor - Fill colour of the box. Default: blue (#2962FF).
|
|
28
|
+
* @param text - Text written inside the box; `\n` starts a new line. Default: none.
|
|
29
|
+
* @param text_size - `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`, `size.auto`, or a size in
|
|
30
|
+
* points. Default: `size.auto`.
|
|
31
|
+
* @param text_color - Text colour. Default: white.
|
|
32
|
+
* @param text_halign - Horizontal place of the text: `text.align_left`, `text.align_center` or `text.align_right`.
|
|
33
|
+
* Default: `text.align_center`.
|
|
34
|
+
* @param text_valign - Vertical place of the text: `text.align_top`, `text.align_center` or `text.align_bottom`.
|
|
35
|
+
* Default: `text.align_center`.
|
|
36
|
+
* @param text_wrap - `text.wrap_auto` wraps the text to the width of the box, `text.wrap_none` keeps each line whole.
|
|
37
|
+
* Default: `text.wrap_none`.
|
|
38
|
+
* @param text_font_family - `font.family_default` or `font.family_monospace`. Default: `font.family_default`.
|
|
39
|
+
* @param force_overlay - When true, the box is drawn on the price pane even if the script has its own pane.
|
|
40
|
+
* Default: false.
|
|
41
|
+
* @param text_formatting - `text.format_bold`, `text.format_italic`, their sum, or `text.format_none`.
|
|
42
|
+
* Default: `text.format_none`.
|
|
43
|
+
* @returns The new box.
|
|
28
44
|
* @example
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
*
|
|
45
|
+
* ```js
|
|
46
|
+
* eachBar((c) => {
|
|
47
|
+
* if (c.i === c.n - 1) box.new(chart.point.from_index(c.i - 20, c.get(high, 20)), chart.point.now(c.low));
|
|
48
|
+
* });
|
|
32
49
|
* ```
|
|
33
50
|
*/
|
|
34
51
|
export declare function new_box(top_left: ChartPoint, bottom_right: ChartPoint, border_color?: color, border_width?: number, border_style?: 'solid' | 'dotted' | 'dashed', extend?: BoxExtend, xloc?: BoxXloc, bgcolor?: color, text?: string, text_size?: string | number, text_color?: color, text_halign?: 'left' | 'center' | 'right', text_valign?: 'top' | 'center' | 'bottom', text_wrap?: 'none' | 'auto', text_font_family?: 'default' | 'monospace', force_overlay?: boolean, text_formatting?: number): Box;
|
|
52
|
+
/**
|
|
53
|
+
* Draws a box from its left, top, right and bottom and returns its handle, to change or delete it later.
|
|
54
|
+
* Inside `eachBar` a Series argument is read on the current bar; the arguments after the coordinates can also be
|
|
55
|
+
* given by name in an object. A bar index x is rounded down; it may be up to 500 bars after the last bar. Boxes
|
|
56
|
+
* above `max_boxes_count` (default 50) are deleted oldest first.
|
|
57
|
+
* @param left - x of the left side: a bar index, a UNIX time in ms (`xloc.bar_time`) or a percent of the pane's
|
|
58
|
+
* width (`xloc.pane`).
|
|
59
|
+
* @param top - Price of the top side.
|
|
60
|
+
* @param right - x of the right side, in the same unit as `left`.
|
|
61
|
+
* @param bottom - Price of the bottom side.
|
|
62
|
+
* @param border_color - Colour of the border. Default: blue (#2962FF).
|
|
63
|
+
* @param border_width - Width of the border in pixels; 0 draws no border. Default: 1.
|
|
64
|
+
* @param border_style - `line.style_solid`, `line.style_dotted` or `line.style_dashed`. Default: `line.style_solid`.
|
|
65
|
+
* @param extend - Extends the box sideways to the edge of the pane: `extend.none`, `extend.left`, `extend.right` or
|
|
66
|
+
* `extend.both`. Default: `extend.none`.
|
|
67
|
+
* @param xloc - What the x coordinates are: `xloc.bar_index`, `xloc.bar_time` or `xloc.pane`. Default: `xloc.bar_index`.
|
|
68
|
+
* @param bgcolor - Fill colour of the box. Default: blue (#2962FF).
|
|
69
|
+
* @param text - Text written inside the box; `\n` starts a new line. Default: none.
|
|
70
|
+
* @param text_size - `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`, `size.auto`, or a size in
|
|
71
|
+
* points. Default: `size.auto`.
|
|
72
|
+
* @param text_color - Text colour. Default: white.
|
|
73
|
+
* @param text_halign - Horizontal place of the text: `text.align_left`, `text.align_center` or `text.align_right`.
|
|
74
|
+
* Default: `text.align_center`.
|
|
75
|
+
* @param text_valign - Vertical place of the text: `text.align_top`, `text.align_center` or `text.align_bottom`.
|
|
76
|
+
* Default: `text.align_center`.
|
|
77
|
+
* @param text_wrap - `text.wrap_auto` wraps the text to the width of the box, `text.wrap_none` keeps each line whole.
|
|
78
|
+
* Default: `text.wrap_none`.
|
|
79
|
+
* @param text_font_family - `font.family_default` or `font.family_monospace`. Default: `font.family_default`.
|
|
80
|
+
* @param force_overlay - When true, the box is drawn on the price pane even if the script has its own pane.
|
|
81
|
+
* Default: false.
|
|
82
|
+
* @param text_formatting - `text.format_bold`, `text.format_italic`, their sum, or `text.format_none`.
|
|
83
|
+
* Default: `text.format_none`.
|
|
84
|
+
* @returns The new box.
|
|
85
|
+
* @example
|
|
86
|
+
* ```js
|
|
87
|
+
* eachBar((c) => {
|
|
88
|
+
* if (c.i === c.n - 1) box.new(c.i - 20, c.get(high, 20), c.i, c.low, { bgcolor: color.new(color.blue, 85), text: "Range" });
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
35
92
|
export declare function new_box(left: number, top: number, right: number, bottom: number, border_color?: color, border_width?: number, border_style?: 'solid' | 'dotted' | 'dashed', extend?: BoxExtend, xloc?: BoxXloc, bgcolor?: color, text?: string, text_size?: string | number, text_color?: color, text_halign?: 'left' | 'center' | 'right', text_valign?: 'top' | 'center' | 'bottom', text_wrap?: 'none' | 'auto', text_font_family?: 'default' | 'monospace', force_overlay?: boolean, text_formatting?: number): Box;
|
|
36
93
|
/**
|
|
37
|
-
* Returns the left
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @returns Left border coordinate (bar index or timestamp)
|
|
41
|
-
*
|
|
42
|
-
* @remarks
|
|
43
|
-
* **COMPUTATIONAL USE**: Calculate gap duration, validate range timeframes
|
|
44
|
-
*
|
|
94
|
+
* Returns the x coordinate of the box's left side, for example to count how many bars a zone has been open.
|
|
95
|
+
* @param id - The box.
|
|
96
|
+
* @returns A bar index, a UNIX time in ms or a pane percent, by the box's xloc; NaN for a deleted box.
|
|
45
97
|
* @example
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* if (duration > 50) {
|
|
52
|
-
* console.log('Gap has been open for 50+ bars');
|
|
53
|
-
* }
|
|
98
|
+
* ```js
|
|
99
|
+
* eachBar((c) => {
|
|
100
|
+
* const b = box.new(c.i - 10, c.get(high, 10), c.i, c.low);
|
|
101
|
+
* const age = c.i - box.get_left(b); // 10
|
|
102
|
+
* });
|
|
54
103
|
* ```
|
|
55
104
|
*/
|
|
56
105
|
export declare function get_left(id: Box): number;
|
|
57
106
|
/**
|
|
58
|
-
* Returns the
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @returns Right border coordinate (bar index or timestamp)
|
|
62
|
-
*
|
|
63
|
-
* @remarks
|
|
64
|
-
* **COMPUTATIONAL USE**: Calculate gap duration, update trailing edges
|
|
65
|
-
*
|
|
107
|
+
* Returns the x coordinate of the box's right side.
|
|
108
|
+
* @param id - The box.
|
|
109
|
+
* @returns A bar index, a UNIX time in ms or a pane percent, by the box's xloc; NaN for a deleted box.
|
|
66
110
|
* @example
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
*
|
|
111
|
+
* ```js
|
|
112
|
+
* eachBar((c) => {
|
|
113
|
+
* const b = box.new(c.i - 10, c.get(high, 10), c.i, c.low);
|
|
114
|
+
* const bars = box.get_right(b) - box.get_left(b); // 10
|
|
115
|
+
* });
|
|
70
116
|
* ```
|
|
71
117
|
*/
|
|
72
118
|
export declare function get_right(id: Box): number;
|
|
73
119
|
/**
|
|
74
|
-
* Returns the top
|
|
75
|
-
*
|
|
76
|
-
* @
|
|
77
|
-
* @returns Top border price
|
|
78
|
-
*
|
|
79
|
-
* @remarks
|
|
80
|
-
* **COMPUTATIONAL USE**: Detect breakouts above resistance, check gap fills
|
|
81
|
-
*
|
|
120
|
+
* Returns the price of the box's top side, for example to test a breakout above a range.
|
|
121
|
+
* @param id - The box.
|
|
122
|
+
* @returns The top price; NaN for a deleted box.
|
|
82
123
|
* @example
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* if (high > box.get_top(gap)) {
|
|
89
|
-
* console.log('Gap completely filled!');
|
|
90
|
-
* }
|
|
124
|
+
* ```js
|
|
125
|
+
* eachBar((c) => {
|
|
126
|
+
* const b = box.new(c.i - 10, c.get(high, 1), c.i - 1, c.get(low, 1));
|
|
127
|
+
* if (c.close > box.get_top(b)) label.new(c.i, c.high, "Breakout");
|
|
128
|
+
* });
|
|
91
129
|
* ```
|
|
92
130
|
*/
|
|
93
131
|
export declare function get_top(id: Box): number;
|
|
94
132
|
/**
|
|
95
|
-
* Returns the bottom
|
|
96
|
-
*
|
|
97
|
-
* @
|
|
98
|
-
* @returns Bottom border price
|
|
99
|
-
*
|
|
100
|
-
* @remarks
|
|
101
|
-
* **COMPUTATIONAL USE**: Detect breakouts below support, check gap fills
|
|
102
|
-
*
|
|
133
|
+
* Returns the price of the box's bottom side, for example to test a breakdown below a range.
|
|
134
|
+
* @param id - The box.
|
|
135
|
+
* @returns The bottom price; NaN for a deleted box.
|
|
103
136
|
* @example
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* if (low < box.get_top(gap) && low > box.get_bottom(gap)) {
|
|
110
|
-
* console.log('Price entered the gap!');
|
|
111
|
-
* }
|
|
137
|
+
* ```js
|
|
138
|
+
* eachBar((c) => {
|
|
139
|
+
* const b = box.new(c.i - 10, c.get(high, 1), c.i - 1, c.get(low, 1));
|
|
140
|
+
* if (c.close < box.get_bottom(b)) label.new(c.i, c.low, "Breakdown", { style: label.style_label_up });
|
|
141
|
+
* });
|
|
112
142
|
* ```
|
|
113
143
|
*/
|
|
114
144
|
export declare function get_bottom(id: Box): number;
|
|
115
145
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* @param id -
|
|
119
|
-
* @returns
|
|
120
|
-
*
|
|
121
|
-
* @remarks
|
|
122
|
-
* Creates a shallow copy of the box. Modifications to the copy won't affect the original.
|
|
123
|
-
*
|
|
146
|
+
* Makes a new box with the same sides, colours and text as `id` (it counts toward `max_boxes_count`).
|
|
147
|
+
* Changing the copy does not change the original.
|
|
148
|
+
* @param id - The box to copy.
|
|
149
|
+
* @returns The new box.
|
|
124
150
|
* @example
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* copiedBox.top = 110;
|
|
151
|
+
* ```js
|
|
152
|
+
* eachBar((c) => {
|
|
153
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
154
|
+
* box.set_bgcolor(box.copy(b), color.new(color.red, 80)); // a red copy over the same bars
|
|
155
|
+
* });
|
|
131
156
|
* ```
|
|
132
157
|
*/
|
|
133
158
|
export declare function copy(id: Box): Box;
|
|
134
159
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @param
|
|
138
|
-
*
|
|
139
|
-
* @returns
|
|
140
|
-
*
|
|
160
|
+
* Moves the box's left side. Does nothing on a deleted box.
|
|
161
|
+
* @param id - The box.
|
|
162
|
+
* @param left - New x: a bar index, a UNIX time in ms or a pane percent, by the box's xloc. A bar index is rounded
|
|
163
|
+
* down.
|
|
164
|
+
* @returns The same box.
|
|
141
165
|
* @example
|
|
142
|
-
* ```
|
|
143
|
-
*
|
|
144
|
-
* box.
|
|
166
|
+
* ```js
|
|
167
|
+
* eachBar((c) => {
|
|
168
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
169
|
+
* box.set_left(b, c.i - 20);
|
|
170
|
+
* });
|
|
145
171
|
* ```
|
|
146
172
|
*/
|
|
147
173
|
export declare function set_left(id: Box, left: number): Box;
|
|
148
174
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @param
|
|
152
|
-
*
|
|
153
|
-
* @returns
|
|
154
|
-
*
|
|
175
|
+
* Moves the box's right side, for example to stretch a zone to the current bar. Does nothing on a deleted box.
|
|
176
|
+
* @param id - The box.
|
|
177
|
+
* @param right - New x: a bar index, a UNIX time in ms or a pane percent, by the box's xloc. A bar index is rounded
|
|
178
|
+
* down.
|
|
179
|
+
* @returns The same box.
|
|
155
180
|
* @example
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* box.
|
|
181
|
+
* ```js
|
|
182
|
+
* eachBar((c) => {
|
|
183
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
184
|
+
* box.set_right(b, c.i + 10); // reach 10 bars into the future
|
|
185
|
+
* });
|
|
159
186
|
* ```
|
|
160
187
|
*/
|
|
161
188
|
export declare function set_right(id: Box, right: number): Box;
|
|
162
189
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* @param
|
|
166
|
-
* @
|
|
167
|
-
* @returns Modified box object
|
|
168
|
-
*
|
|
190
|
+
* Moves the box's top side. Does nothing on a deleted box.
|
|
191
|
+
* @param id - The box.
|
|
192
|
+
* @param top - New top price.
|
|
193
|
+
* @returns The same box.
|
|
169
194
|
* @example
|
|
170
|
-
* ```
|
|
171
|
-
*
|
|
172
|
-
* box.
|
|
195
|
+
* ```js
|
|
196
|
+
* eachBar((c) => {
|
|
197
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
198
|
+
* box.set_top(b, c.get(high, 10));
|
|
199
|
+
* });
|
|
173
200
|
* ```
|
|
174
201
|
*/
|
|
175
202
|
export declare function set_top(id: Box, top: number): Box;
|
|
176
203
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* @param
|
|
180
|
-
* @
|
|
181
|
-
* @returns Modified box object
|
|
182
|
-
*
|
|
204
|
+
* Moves the box's bottom side. Does nothing on a deleted box.
|
|
205
|
+
* @param id - The box.
|
|
206
|
+
* @param bottom - New bottom price.
|
|
207
|
+
* @returns The same box.
|
|
183
208
|
* @example
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* box.
|
|
209
|
+
* ```js
|
|
210
|
+
* eachBar((c) => {
|
|
211
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
212
|
+
* box.set_bottom(b, c.get(low, 10));
|
|
213
|
+
* });
|
|
187
214
|
* ```
|
|
188
215
|
*/
|
|
189
216
|
export declare function set_bottom(id: Box, bottom: number): Box;
|
|
190
217
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* @param
|
|
194
|
-
* @param
|
|
195
|
-
* @
|
|
196
|
-
* @returns Modified box object
|
|
197
|
-
*
|
|
218
|
+
* Moves the box's top-left corner (left side and top price). Does nothing on a deleted box.
|
|
219
|
+
* @param id - The box.
|
|
220
|
+
* @param left - New x of the left side, by the box's xloc. A bar index is rounded down.
|
|
221
|
+
* @param top - New top price.
|
|
222
|
+
* @returns The same box.
|
|
198
223
|
* @example
|
|
199
|
-
* ```
|
|
200
|
-
*
|
|
201
|
-
* box.
|
|
224
|
+
* ```js
|
|
225
|
+
* eachBar((c) => {
|
|
226
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
227
|
+
* box.set_lefttop(b, c.i - 20, c.get(high, 20));
|
|
228
|
+
* });
|
|
202
229
|
* ```
|
|
203
230
|
*/
|
|
204
231
|
export declare function set_lefttop(id: Box, left: number, top: number): Box;
|
|
205
232
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* @param
|
|
209
|
-
* @param
|
|
210
|
-
* @
|
|
211
|
-
* @returns Modified box object
|
|
212
|
-
*
|
|
233
|
+
* Moves the box's bottom-right corner (right side and bottom price). Does nothing on a deleted box.
|
|
234
|
+
* @param id - The box.
|
|
235
|
+
* @param right - New x of the right side, by the box's xloc. A bar index is rounded down.
|
|
236
|
+
* @param bottom - New bottom price.
|
|
237
|
+
* @returns The same box.
|
|
213
238
|
* @example
|
|
214
|
-
* ```
|
|
215
|
-
*
|
|
216
|
-
* box.
|
|
239
|
+
* ```js
|
|
240
|
+
* eachBar((c) => {
|
|
241
|
+
* const b = box.new(c.i - 10, c.high, c.i - 1, c.low);
|
|
242
|
+
* box.set_rightbottom(b, c.i, c.low);
|
|
243
|
+
* });
|
|
217
244
|
* ```
|
|
218
245
|
*/
|
|
219
246
|
export declare function set_rightbottom(id: Box, right: number, bottom: number): Box;
|
|
220
247
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* @param id -
|
|
224
|
-
* @param left - New left
|
|
225
|
-
* @param right - New right
|
|
226
|
-
* @param xloc -
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* @remarks
|
|
230
|
-
* When changing xloc, you must provide appropriate x coordinates for the new system.
|
|
231
|
-
*
|
|
248
|
+
* Changes what the box's x coordinates are and sets its left and right sides in that unit. Does nothing on a
|
|
249
|
+
* deleted box.
|
|
250
|
+
* @param id - The box.
|
|
251
|
+
* @param left - New x of the left side, in the unit of `xloc`.
|
|
252
|
+
* @param right - New x of the right side, in the unit of `xloc`.
|
|
253
|
+
* @param xloc - `xloc.bar_index` (bar indexes), `xloc.bar_time` (UNIX times in ms) or `xloc.pane` (percents of the
|
|
254
|
+
* pane's width).
|
|
255
|
+
* @returns The same box.
|
|
232
256
|
* @example
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
257
|
+
* ```js
|
|
258
|
+
* eachBar((c) => {
|
|
259
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
260
|
+
* box.set_xloc(b, c.time - 3600000, c.time, xloc.bar_time);
|
|
261
|
+
* });
|
|
237
262
|
* ```
|
|
238
263
|
*/
|
|
239
264
|
export declare function set_xloc(id: Box, left: number, right: number, xloc: 'bar_index' | 'bar_time' | 'pane'): Box;
|
|
240
265
|
/**
|
|
241
|
-
* Sets the
|
|
242
|
-
*
|
|
243
|
-
* @param
|
|
244
|
-
* @
|
|
245
|
-
* @returns Modified box object
|
|
246
|
-
*
|
|
266
|
+
* Sets whether the box continues sideways to the edge of the pane. Does nothing on a deleted box.
|
|
267
|
+
* @param id - The box.
|
|
268
|
+
* @param extend - `extend.none`, `extend.left`, `extend.right` or `extend.both`.
|
|
269
|
+
* @returns The same box.
|
|
247
270
|
* @example
|
|
248
|
-
* ```
|
|
249
|
-
*
|
|
250
|
-
* box.
|
|
271
|
+
* ```js
|
|
272
|
+
* eachBar((c) => {
|
|
273
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
274
|
+
* box.set_extend(b, extend.right);
|
|
275
|
+
* });
|
|
251
276
|
* ```
|
|
252
277
|
*/
|
|
253
278
|
export declare function set_extend(id: Box, extend: 'none' | 'left' | 'right' | 'both'): Box;
|
|
254
279
|
/**
|
|
255
|
-
* Sets the border
|
|
256
|
-
*
|
|
257
|
-
* @param
|
|
258
|
-
* @
|
|
259
|
-
* @returns Modified box object
|
|
260
|
-
*
|
|
280
|
+
* Sets the colour of the box's border. Does nothing on a deleted box.
|
|
281
|
+
* @param id - The box.
|
|
282
|
+
* @param borderColor - New colour (`color.red`, `"#FF0000"`, `color.new(color.red, 50)`...).
|
|
283
|
+
* @returns The same box.
|
|
261
284
|
* @example
|
|
262
|
-
* ```
|
|
263
|
-
*
|
|
264
|
-
* box.
|
|
285
|
+
* ```js
|
|
286
|
+
* eachBar((c) => {
|
|
287
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
288
|
+
* box.set_border_color(b, color.red);
|
|
289
|
+
* });
|
|
265
290
|
* ```
|
|
266
291
|
*/
|
|
267
292
|
export declare function set_border_color(id: Box, borderColor: color): Box;
|
|
268
293
|
/**
|
|
269
|
-
* Sets the border
|
|
270
|
-
*
|
|
271
|
-
* @param
|
|
272
|
-
* @
|
|
273
|
-
* @returns Modified box object
|
|
274
|
-
*
|
|
294
|
+
* Sets the width of the box's border. Does nothing on a deleted box.
|
|
295
|
+
* @param id - The box.
|
|
296
|
+
* @param width - New width in pixels; 0 draws no border.
|
|
297
|
+
* @returns The same box.
|
|
275
298
|
* @example
|
|
276
|
-
* ```
|
|
277
|
-
*
|
|
278
|
-
* box.
|
|
299
|
+
* ```js
|
|
300
|
+
* eachBar((c) => {
|
|
301
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
302
|
+
* box.set_border_width(b, 2);
|
|
303
|
+
* });
|
|
279
304
|
* ```
|
|
280
305
|
*/
|
|
281
306
|
export declare function set_border_width(id: Box, width: number): Box;
|
|
282
307
|
/**
|
|
283
|
-
* Sets the border
|
|
284
|
-
*
|
|
285
|
-
* @param
|
|
286
|
-
* @
|
|
287
|
-
* @returns Modified box object
|
|
288
|
-
*
|
|
308
|
+
* Sets the style of the box's border. Does nothing on a deleted box.
|
|
309
|
+
* @param id - The box.
|
|
310
|
+
* @param style - `line.style_solid`, `line.style_dotted` or `line.style_dashed`.
|
|
311
|
+
* @returns The same box.
|
|
289
312
|
* @example
|
|
290
|
-
* ```
|
|
291
|
-
*
|
|
292
|
-
* box.
|
|
313
|
+
* ```js
|
|
314
|
+
* eachBar((c) => {
|
|
315
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
316
|
+
* box.set_border_style(b, line.style_dashed);
|
|
317
|
+
* });
|
|
293
318
|
* ```
|
|
294
319
|
*/
|
|
295
320
|
export declare function set_border_style(id: Box, style: 'solid' | 'dotted' | 'dashed'): Box;
|
|
296
321
|
/**
|
|
297
|
-
* Sets the
|
|
298
|
-
*
|
|
299
|
-
* @param
|
|
300
|
-
* @
|
|
301
|
-
* @returns Modified box object
|
|
302
|
-
*
|
|
322
|
+
* Sets the fill colour of the box. Does nothing on a deleted box.
|
|
323
|
+
* @param id - The box.
|
|
324
|
+
* @param bgColor - New fill colour; a transparent one (`color.new(color.green, 80)`) keeps the bars visible.
|
|
325
|
+
* @returns The same box.
|
|
303
326
|
* @example
|
|
304
|
-
* ```
|
|
305
|
-
*
|
|
306
|
-
* box.
|
|
327
|
+
* ```js
|
|
328
|
+
* eachBar((c) => {
|
|
329
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
330
|
+
* box.set_bgcolor(b, c.close > c.open ? color.new(color.green, 80) : color.new(color.red, 80));
|
|
331
|
+
* });
|
|
307
332
|
* ```
|
|
308
333
|
*/
|
|
309
334
|
export declare function set_bgcolor(id: Box, bgColor: color): Box;
|
|
310
335
|
/**
|
|
311
|
-
* Sets the text
|
|
312
|
-
*
|
|
313
|
-
* @param
|
|
314
|
-
* @
|
|
315
|
-
* @returns Modified box object
|
|
316
|
-
*
|
|
336
|
+
* Sets the text written inside the box. Does nothing on a deleted box.
|
|
337
|
+
* @param id - The box.
|
|
338
|
+
* @param text - New text; `\n` starts a new line.
|
|
339
|
+
* @returns The same box.
|
|
317
340
|
* @example
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* box.
|
|
341
|
+
* ```js
|
|
342
|
+
* eachBar((c) => {
|
|
343
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
344
|
+
* box.set_text(b, "Range " + str.tostring(c.high - c.low, "#.##"));
|
|
345
|
+
* });
|
|
321
346
|
* ```
|
|
322
347
|
*/
|
|
323
348
|
export declare function set_text(id: Box, text: string): Box;
|
|
324
349
|
/**
|
|
325
|
-
* Sets the text
|
|
326
|
-
*
|
|
327
|
-
* @param
|
|
328
|
-
* @
|
|
329
|
-
* @returns Modified box object
|
|
330
|
-
*
|
|
350
|
+
* Sets the colour of the box's text. Does nothing on a deleted box.
|
|
351
|
+
* @param id - The box.
|
|
352
|
+
* @param textColor - New text colour.
|
|
353
|
+
* @returns The same box.
|
|
331
354
|
* @example
|
|
332
|
-
* ```
|
|
333
|
-
*
|
|
334
|
-
* box.
|
|
355
|
+
* ```js
|
|
356
|
+
* eachBar((c) => {
|
|
357
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
|
|
358
|
+
* box.set_text_color(b, color.black);
|
|
359
|
+
* });
|
|
335
360
|
* ```
|
|
336
361
|
*/
|
|
337
362
|
export declare function set_text_color(id: Box, textColor: color): Box;
|
|
338
363
|
/**
|
|
339
|
-
* Sets the text
|
|
340
|
-
*
|
|
341
|
-
* @param
|
|
342
|
-
* @
|
|
343
|
-
* @returns Modified box object
|
|
344
|
-
*
|
|
364
|
+
* Sets the size of the box's text. Does nothing on a deleted box.
|
|
365
|
+
* @param id - The box.
|
|
366
|
+
* @param size - `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`, `size.auto`, or a size in points.
|
|
367
|
+
* @returns The same box.
|
|
345
368
|
* @example
|
|
346
|
-
* ```
|
|
347
|
-
*
|
|
348
|
-
* box.
|
|
369
|
+
* ```js
|
|
370
|
+
* eachBar((c) => {
|
|
371
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
|
|
372
|
+
* box.set_text_size(b, size.large);
|
|
373
|
+
* });
|
|
349
374
|
* ```
|
|
350
375
|
*/
|
|
351
376
|
export declare function set_text_size(id: Box, size: string | number): Box;
|
|
352
377
|
/**
|
|
353
|
-
* Sets the horizontal text
|
|
354
|
-
*
|
|
355
|
-
* @param
|
|
356
|
-
* @
|
|
357
|
-
* @returns Modified box object
|
|
358
|
-
*
|
|
378
|
+
* Sets the horizontal place of the text inside the box. Does nothing on a deleted box.
|
|
379
|
+
* @param id - The box.
|
|
380
|
+
* @param align - `text.align_left`, `text.align_center` or `text.align_right`.
|
|
381
|
+
* @returns The same box.
|
|
359
382
|
* @example
|
|
360
|
-
* ```
|
|
361
|
-
*
|
|
362
|
-
* box.
|
|
383
|
+
* ```js
|
|
384
|
+
* eachBar((c) => {
|
|
385
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
|
|
386
|
+
* box.set_text_halign(b, text.align_left);
|
|
387
|
+
* });
|
|
363
388
|
* ```
|
|
364
389
|
*/
|
|
365
390
|
export declare function set_text_halign(id: Box, align: 'left' | 'center' | 'right'): Box;
|
|
366
391
|
/**
|
|
367
|
-
* Sets the vertical text
|
|
368
|
-
*
|
|
369
|
-
* @param
|
|
370
|
-
* @
|
|
371
|
-
* @returns Modified box object
|
|
372
|
-
*
|
|
392
|
+
* Sets the vertical place of the text inside the box. Does nothing on a deleted box.
|
|
393
|
+
* @param id - The box.
|
|
394
|
+
* @param align - `text.align_top`, `text.align_center` or `text.align_bottom`.
|
|
395
|
+
* @returns The same box.
|
|
373
396
|
* @example
|
|
374
|
-
* ```
|
|
375
|
-
*
|
|
376
|
-
* box.
|
|
397
|
+
* ```js
|
|
398
|
+
* eachBar((c) => {
|
|
399
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
|
|
400
|
+
* box.set_text_valign(b, text.align_top);
|
|
401
|
+
* });
|
|
377
402
|
* ```
|
|
378
403
|
*/
|
|
379
404
|
export declare function set_text_valign(id: Box, align: 'top' | 'center' | 'bottom'): Box;
|
|
380
405
|
/**
|
|
381
|
-
* Sets
|
|
382
|
-
*
|
|
383
|
-
* @param
|
|
384
|
-
* @
|
|
385
|
-
* @returns Modified box object
|
|
386
|
-
*
|
|
406
|
+
* Sets whether a long text wraps onto several lines to fit the width of the box. Does nothing on a deleted box.
|
|
407
|
+
* @param id - The box.
|
|
408
|
+
* @param wrap - `text.wrap_auto` (wrap to the box's width) or `text.wrap_none` (each line stays whole).
|
|
409
|
+
* @returns The same box.
|
|
387
410
|
* @example
|
|
388
|
-
* ```
|
|
389
|
-
*
|
|
390
|
-
* box.
|
|
411
|
+
* ```js
|
|
412
|
+
* eachBar((c) => {
|
|
413
|
+
* const b = box.new(c.i - 3, c.high, c.i, c.low, { text: "A long note about this zone" });
|
|
414
|
+
* box.set_text_wrap(b, text.wrap_auto);
|
|
415
|
+
* });
|
|
391
416
|
* ```
|
|
392
417
|
*/
|
|
393
418
|
export declare function set_text_wrap(id: Box, wrap: 'none' | 'auto'): Box;
|
|
394
419
|
/**
|
|
395
|
-
* Sets the text
|
|
396
|
-
*
|
|
397
|
-
* @param
|
|
398
|
-
* @
|
|
399
|
-
* @returns Modified box object
|
|
400
|
-
*
|
|
420
|
+
* Sets the font of the box's text. Does nothing on a deleted box.
|
|
421
|
+
* @param id - The box.
|
|
422
|
+
* @param font - `font.family_default` or `font.family_monospace`.
|
|
423
|
+
* @returns The same box.
|
|
401
424
|
* @example
|
|
402
|
-
* ```
|
|
403
|
-
*
|
|
404
|
-
* box.
|
|
425
|
+
* ```js
|
|
426
|
+
* eachBar((c) => {
|
|
427
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "123.45" });
|
|
428
|
+
* box.set_text_font_family(b, font.family_monospace);
|
|
429
|
+
* });
|
|
405
430
|
* ```
|
|
406
431
|
*/
|
|
407
432
|
export declare function set_text_font_family(id: Box, font: 'default' | 'monospace'): Box;
|
|
408
433
|
/**
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
* @param id -
|
|
412
|
-
*
|
|
413
|
-
* @remarks
|
|
414
|
-
* Removes the box from `box.all()`. As in PineScript, the deleted box is `na`: its getters
|
|
415
|
-
* return NaN and its setters do nothing. Deleting it twice has no effect.
|
|
416
|
-
*
|
|
434
|
+
* Removes the box from the chart and from `box.all`. Afterwards its getters return NaN and its setters do nothing;
|
|
435
|
+
* deleting it again does nothing.
|
|
436
|
+
* @param id - The box to delete.
|
|
417
437
|
* @example
|
|
418
|
-
* ```
|
|
419
|
-
*
|
|
420
|
-
* box.
|
|
421
|
-
*
|
|
438
|
+
* ```js
|
|
439
|
+
* eachBar((c) => {
|
|
440
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
441
|
+
* if (c.i < c.n - 1) box.delete(b); // keep only the box of the last bar
|
|
442
|
+
* });
|
|
422
443
|
* ```
|
|
423
444
|
*/
|
|
424
445
|
export declare function delete_box(id: Box): void;
|
|
425
446
|
/**
|
|
426
|
-
*
|
|
447
|
+
* Returns the boxes that are still on the chart, oldest first. The array is a copy.
|
|
448
|
+
* (In a script, `box.all` is read as a value, without a call.)
|
|
449
|
+
* @returns The live boxes in creation order.
|
|
450
|
+
* @example
|
|
451
|
+
* ```js
|
|
452
|
+
* eachBar((c) => {
|
|
453
|
+
* if (c.i === c.n - 1) for (const b of box.all) box.set_right(b, c.i);
|
|
454
|
+
* });
|
|
455
|
+
* ```
|
|
427
456
|
*/
|
|
428
457
|
export declare function all(): Box[];
|
|
429
458
|
/**
|
|
430
|
-
*
|
|
459
|
+
* Moves the box's top-left corner to a chart point: its `index` for a `xloc.bar_index` box, its `time` for a
|
|
460
|
+
* `xloc.bar_time` box (NaN when the point has none), and its `price`. Does nothing on a deleted box.
|
|
461
|
+
* @param id - The box.
|
|
462
|
+
* @param point - The new top-left corner.
|
|
463
|
+
* @returns The same box.
|
|
464
|
+
* @example
|
|
465
|
+
* ```js
|
|
466
|
+
* eachBar((c) => {
|
|
467
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low);
|
|
468
|
+
* box.set_top_left_point(b, chart.point.from_index(c.i - 20, c.get(high, 20)));
|
|
469
|
+
* });
|
|
470
|
+
* ```
|
|
431
471
|
*/
|
|
432
472
|
export declare function set_top_left_point(id: Box, point: ChartPoint): Box;
|
|
433
473
|
/**
|
|
434
|
-
*
|
|
474
|
+
* Moves the box's bottom-right corner to a chart point (see `box.set_top_left_point`). Does nothing on a deleted box.
|
|
475
|
+
* @param id - The box.
|
|
476
|
+
* @param point - The new bottom-right corner.
|
|
477
|
+
* @returns The same box.
|
|
478
|
+
* @example
|
|
479
|
+
* ```js
|
|
480
|
+
* eachBar((c) => {
|
|
481
|
+
* const b = box.new(c.i - 10, c.high, c.i - 1, c.low);
|
|
482
|
+
* box.set_bottom_right_point(b, chart.point.now(c.low));
|
|
483
|
+
* });
|
|
484
|
+
* ```
|
|
435
485
|
*/
|
|
436
486
|
export declare function set_bottom_right_point(id: Box, point: ChartPoint): Box;
|
|
437
487
|
/**
|
|
438
|
-
*
|
|
439
|
-
*
|
|
488
|
+
* Makes the box's text bold, italic, both or plain. Does nothing on a deleted box.
|
|
489
|
+
* @param id - The box.
|
|
490
|
+
* @param formatting - `text.format_bold`, `text.format_italic`, their sum, or `text.format_none`.
|
|
491
|
+
* @returns The same box.
|
|
492
|
+
* @example
|
|
493
|
+
* ```js
|
|
494
|
+
* eachBar((c) => {
|
|
495
|
+
* const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
|
|
496
|
+
* box.set_text_formatting(b, text.format_bold);
|
|
497
|
+
* });
|
|
498
|
+
* ```
|
|
440
499
|
*/
|
|
441
500
|
export declare function set_text_formatting(id: Box, formatting: number): Box;
|
|
442
501
|
export { new_box as new };
|