oakscriptjs 0.24.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.
Files changed (300) hide show
  1. package/README.md +25 -1
  2. package/bin/oakscript.mjs +10 -3
  3. package/dist/cjs/box/index.d.ts +348 -289
  4. package/dist/cjs/box/index.d.ts.map +1 -1
  5. package/dist/cjs/box/index.js.map +2 -2
  6. package/dist/cjs/check/node.d.ts.map +1 -1
  7. package/dist/cjs/check/node.js +1 -0
  8. package/dist/cjs/check/node.js.map +2 -2
  9. package/dist/cjs/check/preview.d.ts +31 -0
  10. package/dist/cjs/check/preview.d.ts.map +1 -0
  11. package/dist/cjs/check/preview.js +303 -0
  12. package/dist/cjs/check/preview.js.map +7 -0
  13. package/dist/cjs/color/index.d.ts +11 -11
  14. package/dist/cjs/color/index.js.map +1 -1
  15. package/dist/cjs/color/parse.d.ts +2 -0
  16. package/dist/cjs/color/parse.d.ts.map +1 -1
  17. package/dist/cjs/color/parse.js +6 -0
  18. package/dist/cjs/color/parse.js.map +2 -2
  19. package/dist/cjs/compare/index.d.ts +76 -12
  20. package/dist/cjs/compare/index.d.ts.map +1 -1
  21. package/dist/cjs/compare/index.js.map +2 -2
  22. package/dist/cjs/drawing/registry.d.ts +28 -5
  23. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  24. package/dist/cjs/drawing/registry.js +14 -0
  25. package/dist/cjs/drawing/registry.js.map +2 -2
  26. package/dist/cjs/index.d.ts +1 -1
  27. package/dist/cjs/index.js +1 -1
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/label/index.d.ts +265 -187
  30. package/dist/cjs/label/index.d.ts.map +1 -1
  31. package/dist/cjs/label/index.js +1 -1
  32. package/dist/cjs/label/index.js.map +2 -2
  33. package/dist/cjs/line/index.d.ts +247 -207
  34. package/dist/cjs/line/index.d.ts.map +1 -1
  35. package/dist/cjs/line/index.js.map +2 -2
  36. package/dist/cjs/linefill/index.d.ts +61 -89
  37. package/dist/cjs/linefill/index.d.ts.map +1 -1
  38. package/dist/cjs/linefill/index.js.map +2 -2
  39. package/dist/cjs/math/index.d.ts +49 -40
  40. package/dist/cjs/math/index.d.ts.map +1 -1
  41. package/dist/cjs/math/index.js.map +2 -2
  42. package/dist/cjs/polyline/index.d.ts +57 -78
  43. package/dist/cjs/polyline/index.d.ts.map +1 -1
  44. package/dist/cjs/polyline/index.js.map +2 -2
  45. package/dist/cjs/runtime/input-active.d.ts +2 -2
  46. package/dist/cjs/runtime/input-active.js.map +1 -1
  47. package/dist/cjs/runtime/series.d.ts +241 -161
  48. package/dist/cjs/runtime/series.d.ts.map +1 -1
  49. package/dist/cjs/runtime/series.js +223 -127
  50. package/dist/cjs/runtime/series.js.map +2 -2
  51. package/dist/cjs/script/api/alert.d.ts +37 -0
  52. package/dist/cjs/script/api/alert.d.ts.map +1 -0
  53. package/dist/cjs/script/api/alert.js +17 -0
  54. package/dist/cjs/script/api/alert.js.map +7 -0
  55. package/dist/cjs/script/api/calc.d.ts +232 -0
  56. package/dist/cjs/script/api/calc.d.ts.map +1 -0
  57. package/dist/cjs/script/api/calc.js +17 -0
  58. package/dist/cjs/script/api/calc.js.map +7 -0
  59. package/dist/cjs/script/api/color.d.ts +213 -0
  60. package/dist/cjs/script/api/color.d.ts.map +1 -0
  61. package/dist/cjs/script/api/color.js +17 -0
  62. package/dist/cjs/script/api/color.js.map +7 -0
  63. package/dist/cjs/script/api/context.d.ts +764 -0
  64. package/dist/cjs/script/api/context.d.ts.map +1 -0
  65. package/dist/cjs/script/api/context.js +17 -0
  66. package/dist/cjs/script/api/context.js.map +7 -0
  67. package/dist/cjs/script/api/log.d.ts +58 -0
  68. package/dist/cjs/script/api/log.d.ts.map +1 -0
  69. package/dist/cjs/script/api/log.js +17 -0
  70. package/dist/cjs/script/api/log.js.map +7 -0
  71. package/dist/cjs/script/api/strategy.d.ts +391 -0
  72. package/dist/cjs/script/api/strategy.d.ts.map +1 -0
  73. package/dist/cjs/script/api/strategy.js +17 -0
  74. package/dist/cjs/script/api/strategy.js.map +7 -0
  75. package/dist/cjs/script/api/ta.d.ts +1012 -0
  76. package/dist/cjs/script/api/ta.d.ts.map +1 -0
  77. package/dist/cjs/script/api/ta.js +17 -0
  78. package/dist/cjs/script/api/ta.js.map +7 -0
  79. package/dist/cjs/script/api/table.d.ts +479 -0
  80. package/dist/cjs/script/api/table.d.ts.map +1 -0
  81. package/dist/cjs/script/api/table.js +17 -0
  82. package/dist/cjs/script/api/table.js.map +7 -0
  83. package/dist/cjs/script/constants.d.ts +228 -83
  84. package/dist/cjs/script/constants.d.ts.map +1 -1
  85. package/dist/cjs/script/constants.js +87 -0
  86. package/dist/cjs/script/constants.js.map +2 -2
  87. package/dist/cjs/script/define.d.ts +94 -0
  88. package/dist/cjs/script/define.d.ts.map +1 -0
  89. package/dist/cjs/script/define.js +127 -0
  90. package/dist/cjs/script/define.js.map +7 -0
  91. package/dist/cjs/script/drawing-args.d.ts.map +1 -1
  92. package/dist/cjs/script/drawing-args.js +1 -1
  93. package/dist/cjs/script/drawing-args.js.map +2 -2
  94. package/dist/cjs/script/formula.d.ts +53 -0
  95. package/dist/cjs/script/formula.d.ts.map +1 -0
  96. package/dist/cjs/script/formula.js +402 -0
  97. package/dist/cjs/script/formula.js.map +7 -0
  98. package/dist/cjs/script/globals.d.ts +10 -0
  99. package/dist/cjs/script/globals.d.ts.map +1 -1
  100. package/dist/cjs/script/globals.js.map +1 -1
  101. package/dist/cjs/script/index.d.ts +1065 -1006
  102. package/dist/cjs/script/index.d.ts.map +1 -1
  103. package/dist/cjs/script/index.js +530 -60
  104. package/dist/cjs/script/index.js.map +3 -3
  105. package/dist/cjs/script/json.d.ts +117 -0
  106. package/dist/cjs/script/json.d.ts.map +1 -0
  107. package/dist/cjs/script/json.js +321 -0
  108. package/dist/cjs/script/json.js.map +7 -0
  109. package/dist/cjs/str/index.d.ts +50 -75
  110. package/dist/cjs/str/index.d.ts.map +1 -1
  111. package/dist/cjs/str/index.js +2 -2
  112. package/dist/cjs/str/index.js.map +2 -2
  113. package/dist/cjs/strategy/index.d.ts +102 -1
  114. package/dist/cjs/strategy/index.d.ts.map +1 -1
  115. package/dist/cjs/strategy/index.js.map +2 -2
  116. package/dist/cjs/table/index.d.ts +330 -49
  117. package/dist/cjs/table/index.d.ts.map +1 -1
  118. package/dist/cjs/table/index.js +55 -27
  119. package/dist/cjs/table/index.js.map +2 -2
  120. package/dist/cjs/text/index.d.ts +12 -14
  121. package/dist/cjs/text/index.d.ts.map +1 -1
  122. package/dist/cjs/text/index.js.map +2 -2
  123. package/dist/cjs/types/index.d.ts +15 -8
  124. package/dist/cjs/types/index.d.ts.map +1 -1
  125. package/dist/cjs/types/index.js +12 -3
  126. package/dist/cjs/types/index.js.map +2 -2
  127. package/dist/esm/box/index.d.ts +348 -289
  128. package/dist/esm/box/index.d.ts.map +1 -1
  129. package/dist/esm/box/index.js +276 -276
  130. package/dist/esm/box/index.js.map +1 -1
  131. package/dist/esm/check/node.d.ts.map +1 -1
  132. package/dist/esm/check/node.js +1 -0
  133. package/dist/esm/check/node.js.map +1 -1
  134. package/dist/esm/check/preview.d.ts +31 -0
  135. package/dist/esm/check/preview.d.ts.map +1 -0
  136. package/dist/esm/check/preview.js +296 -0
  137. package/dist/esm/check/preview.js.map +1 -0
  138. package/dist/esm/color/index.d.ts +11 -11
  139. package/dist/esm/color/index.js +11 -11
  140. package/dist/esm/color/parse.d.ts +2 -0
  141. package/dist/esm/color/parse.d.ts.map +1 -1
  142. package/dist/esm/color/parse.js +7 -0
  143. package/dist/esm/color/parse.js.map +1 -1
  144. package/dist/esm/compare/index.d.ts +76 -12
  145. package/dist/esm/compare/index.d.ts.map +1 -1
  146. package/dist/esm/compare/index.js +76 -12
  147. package/dist/esm/compare/index.js.map +1 -1
  148. package/dist/esm/drawing/registry.d.ts +28 -5
  149. package/dist/esm/drawing/registry.d.ts.map +1 -1
  150. package/dist/esm/drawing/registry.js +39 -3
  151. package/dist/esm/drawing/registry.js.map +1 -1
  152. package/dist/esm/index.d.ts +1 -1
  153. package/dist/esm/index.js +1 -1
  154. package/dist/esm/label/index.d.ts +265 -187
  155. package/dist/esm/label/index.d.ts.map +1 -1
  156. package/dist/esm/label/index.js +207 -177
  157. package/dist/esm/label/index.js.map +1 -1
  158. package/dist/esm/line/index.d.ts +247 -207
  159. package/dist/esm/line/index.d.ts.map +1 -1
  160. package/dist/esm/line/index.js +202 -194
  161. package/dist/esm/line/index.js.map +1 -1
  162. package/dist/esm/linefill/index.d.ts +61 -89
  163. package/dist/esm/linefill/index.d.ts.map +1 -1
  164. package/dist/esm/linefill/index.js +61 -89
  165. package/dist/esm/linefill/index.js.map +1 -1
  166. package/dist/esm/math/index.d.ts +49 -40
  167. package/dist/esm/math/index.d.ts.map +1 -1
  168. package/dist/esm/math/index.js +22 -9
  169. package/dist/esm/math/index.js.map +1 -1
  170. package/dist/esm/polyline/index.d.ts +57 -78
  171. package/dist/esm/polyline/index.d.ts.map +1 -1
  172. package/dist/esm/polyline/index.js +57 -78
  173. package/dist/esm/polyline/index.js.map +1 -1
  174. package/dist/esm/runtime/input-active.d.ts +2 -2
  175. package/dist/esm/runtime/input-active.js +2 -2
  176. package/dist/esm/runtime/series.d.ts +241 -161
  177. package/dist/esm/runtime/series.d.ts.map +1 -1
  178. package/dist/esm/runtime/series.js +241 -161
  179. package/dist/esm/runtime/series.js.map +1 -1
  180. package/dist/esm/script/api/alert.d.ts +37 -0
  181. package/dist/esm/script/api/alert.d.ts.map +1 -0
  182. package/dist/esm/script/api/alert.js +7 -0
  183. package/dist/esm/script/api/alert.js.map +1 -0
  184. package/dist/esm/script/api/calc.d.ts +232 -0
  185. package/dist/esm/script/api/calc.d.ts.map +1 -0
  186. package/dist/esm/script/api/calc.js +6 -0
  187. package/dist/esm/script/api/calc.js.map +1 -0
  188. package/dist/esm/script/api/color.d.ts +213 -0
  189. package/dist/esm/script/api/color.d.ts.map +1 -0
  190. package/dist/esm/script/api/color.js +6 -0
  191. package/dist/esm/script/api/color.js.map +1 -0
  192. package/dist/esm/script/api/context.d.ts +764 -0
  193. package/dist/esm/script/api/context.d.ts.map +1 -0
  194. package/dist/esm/script/api/context.js +7 -0
  195. package/dist/esm/script/api/context.js.map +1 -0
  196. package/dist/esm/script/api/log.d.ts +58 -0
  197. package/dist/esm/script/api/log.d.ts.map +1 -0
  198. package/dist/esm/script/api/log.js +6 -0
  199. package/dist/esm/script/api/log.js.map +1 -0
  200. package/dist/esm/script/api/strategy.d.ts +391 -0
  201. package/dist/esm/script/api/strategy.d.ts.map +1 -0
  202. package/dist/esm/script/api/strategy.js +7 -0
  203. package/dist/esm/script/api/strategy.js.map +1 -0
  204. package/dist/esm/script/api/ta.d.ts +1012 -0
  205. package/dist/esm/script/api/ta.d.ts.map +1 -0
  206. package/dist/esm/script/api/ta.js +6 -0
  207. package/dist/esm/script/api/ta.js.map +1 -0
  208. package/dist/esm/script/api/table.d.ts +479 -0
  209. package/dist/esm/script/api/table.d.ts.map +1 -0
  210. package/dist/esm/script/api/table.js +7 -0
  211. package/dist/esm/script/api/table.js.map +1 -0
  212. package/dist/esm/script/constants.d.ts +228 -83
  213. package/dist/esm/script/constants.d.ts.map +1 -1
  214. package/dist/esm/script/constants.js +110 -24
  215. package/dist/esm/script/constants.js.map +1 -1
  216. package/dist/esm/script/define.d.ts +94 -0
  217. package/dist/esm/script/define.d.ts.map +1 -0
  218. package/dist/esm/script/define.js +136 -0
  219. package/dist/esm/script/define.js.map +1 -0
  220. package/dist/esm/script/drawing-args.d.ts.map +1 -1
  221. package/dist/esm/script/drawing-args.js +2 -1
  222. package/dist/esm/script/drawing-args.js.map +1 -1
  223. package/dist/esm/script/formula.d.ts +53 -0
  224. package/dist/esm/script/formula.d.ts.map +1 -0
  225. package/dist/esm/script/formula.js +408 -0
  226. package/dist/esm/script/formula.js.map +1 -0
  227. package/dist/esm/script/globals.d.ts +10 -0
  228. package/dist/esm/script/globals.d.ts.map +1 -1
  229. package/dist/esm/script/globals.js.map +1 -1
  230. package/dist/esm/script/index.d.ts +1065 -1006
  231. package/dist/esm/script/index.d.ts.map +1 -1
  232. package/dist/esm/script/index.js +1096 -151
  233. package/dist/esm/script/index.js.map +1 -1
  234. package/dist/esm/script/json.d.ts +117 -0
  235. package/dist/esm/script/json.d.ts.map +1 -0
  236. package/dist/esm/script/json.js +375 -0
  237. package/dist/esm/script/json.js.map +1 -0
  238. package/dist/esm/str/index.d.ts +50 -75
  239. package/dist/esm/str/index.d.ts.map +1 -1
  240. package/dist/esm/str/index.js +51 -76
  241. package/dist/esm/str/index.js.map +1 -1
  242. package/dist/esm/strategy/index.d.ts +102 -1
  243. package/dist/esm/strategy/index.d.ts.map +1 -1
  244. package/dist/esm/strategy/index.js +1 -1
  245. package/dist/esm/strategy/index.js.map +1 -1
  246. package/dist/esm/table/index.d.ts +330 -49
  247. package/dist/esm/table/index.d.ts.map +1 -1
  248. package/dist/esm/table/index.js +372 -61
  249. package/dist/esm/table/index.js.map +1 -1
  250. package/dist/esm/text/index.d.ts +12 -14
  251. package/dist/esm/text/index.d.ts.map +1 -1
  252. package/dist/esm/text/index.js +12 -14
  253. package/dist/esm/text/index.js.map +1 -1
  254. package/dist/esm/types/index.d.ts +15 -8
  255. package/dist/esm/types/index.d.ts.map +1 -1
  256. package/dist/esm/types/index.js +15 -8
  257. package/dist/esm/types/index.js.map +1 -1
  258. package/docs/first-indicator.md +152 -0
  259. package/docs/guide.md +1185 -0
  260. package/docs/inventory.md +772 -0
  261. package/docs/no-code.md +207 -0
  262. package/docs/recipes.md +202 -0
  263. package/package.json +2 -1
  264. package/skills/oakscript/SKILL.md +8 -0
  265. package/skills/oakscript/reference/errors.md +3 -2
  266. package/src/box/index.ts +348 -289
  267. package/src/check/node.ts +1 -0
  268. package/src/check/preview.ts +307 -0
  269. package/src/color/index.ts +11 -11
  270. package/src/color/parse.ts +7 -0
  271. package/src/compare/index.ts +76 -12
  272. package/src/drawing/registry.ts +44 -5
  273. package/src/index.ts +1 -1
  274. package/src/label/index.ts +267 -189
  275. package/src/line/index.ts +248 -208
  276. package/src/linefill/index.ts +61 -89
  277. package/src/math/index.ts +51 -42
  278. package/src/polyline/index.ts +57 -78
  279. package/src/runtime/input-active.ts +2 -2
  280. package/src/runtime/series.ts +243 -163
  281. package/src/script/api/alert.ts +43 -0
  282. package/src/script/api/calc.ts +250 -0
  283. package/src/script/api/color.ts +245 -0
  284. package/src/script/api/context.ts +944 -0
  285. package/src/script/api/log.ts +60 -0
  286. package/src/script/api/strategy.ts +410 -0
  287. package/src/script/api/ta.ts +1115 -0
  288. package/src/script/api/table.ts +538 -0
  289. package/src/script/constants.ts +229 -25
  290. package/src/script/define.ts +221 -0
  291. package/src/script/drawing-args.ts +2 -1
  292. package/src/script/formula.ts +438 -0
  293. package/src/script/globals.ts +10 -0
  294. package/src/script/index.ts +1517 -239
  295. package/src/script/json.ts +457 -0
  296. package/src/str/index.ts +51 -76
  297. package/src/strategy/index.ts +102 -1
  298. package/src/table/index.ts +388 -62
  299. package/src/text/index.ts +12 -14
  300. package/src/types/index.ts +15 -8
@@ -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
- * Box objects represent rectangular areas on the chart. The getter functions
7
- * (get_top, get_bottom, get_left, get_right) enable computational use cases like:
8
- * - Gap detection and tracking (detecting when price fills gaps)
9
- * - Range breakout analysis (detecting when price breaks out of consolidation)
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
- * Creates a new box (PineScript `box.new`), with two chart points or with coordinates, in PineScript's
19
- * parameter order:
20
- *
21
- * - `box.new(top_left, bottom_right, border_color?, border_width?, border_style?, extend?, xloc?, bgcolor?,
22
- * text?, text_size?, text_color?, text_halign?, text_valign?, text_wrap?, text_font_family?,
23
- * force_overlay?, text_formatting?)`
24
- * - `box.new(left, top, right, bottom, border_color?, border_width?, border_style?, extend?, xloc?, ...)`
25
- *
26
- * With chart points, x is `point.index` for `bar_index` boxes and `point.time` for `bar_time` boxes.
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
- * ```typescript
30
- * // Gap box from bar 10 to 20, between 100 and 105, extended to the right
31
- * const gap = box.new(10, 105, 20, 100, '#2196F3', 1, 'solid', 'right');
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 border x coordinate.
38
- *
39
- * @param id - Box object
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
- * ```typescript
47
- * const gap = box.new(10, 105, 20, 100);
48
- * const currentBar = 30;
49
- * const duration = currentBar - box.get_left(gap); // Returns 20
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 right border x coordinate.
59
- *
60
- * @param id - Box object
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
- * ```typescript
68
- * const range = box.new(100, 155, 150, 145);
69
- * const width = box.get_right(range) - box.get_left(range); // Returns 50 bars
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 border price level.
75
- *
76
- * @param id - Box object
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
- * ```typescript
84
- * const gap = box.new(10, 105, 20, 100); // Bearish gap
85
- *
86
- * // Check if price has filled gap from below
87
- * const high = 106;
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 border price level.
96
- *
97
- * @param id - Box object
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
- * ```typescript
105
- * const gap = box.new(10, 105, 20, 100); // Bearish gap
106
- *
107
- * // Check if price has touched gap from above
108
- * const low = 104;
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
- * Creates a copy of the box object.
117
- *
118
- * @param id - Box object to copy
119
- * @returns New box object with same properties
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
- * ```typescript
126
- * const originalBox = box.new(10, 105, 20, 100);
127
- * const copiedBox = box.copy(originalBox);
128
- *
129
- * // Modify copy without affecting original
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
- * Sets the left border x coordinate.
136
- *
137
- * @param id - Box object to modify
138
- * @param left - New left border coordinate
139
- * @returns Modified box object
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
- * ```typescript
143
- * const box = box.new(10, 105, 20, 100);
144
- * box.set_left(box, 15); // Move left edge to bar 15
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
- * Sets the right border x coordinate.
150
- *
151
- * @param id - Box object to modify
152
- * @param right - New right border coordinate
153
- * @returns Modified box object
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
- * ```typescript
157
- * const box = box.new(10, 105, 20, 100);
158
- * box.set_right(box, 25); // Move right edge to bar 25
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
- * Sets the top border price level.
164
- *
165
- * @param id - Box object to modify
166
- * @param top - New top border price
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
- * ```typescript
171
- * const box = box.new(10, 105, 20, 100);
172
- * box.set_top(box, 110); // Move top edge to price 110
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
- * Sets the bottom border price level.
178
- *
179
- * @param id - Box object to modify
180
- * @param bottom - New bottom border price
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
- * ```typescript
185
- * const box = box.new(10, 105, 20, 100);
186
- * box.set_bottom(box, 95); // Move bottom edge to price 95
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
- * Sets the left and top coordinates.
192
- *
193
- * @param id - Box object to modify
194
- * @param left - New left border coordinate
195
- * @param top - New top border price
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
- * ```typescript
200
- * const box = box.new(10, 105, 20, 100);
201
- * box.set_lefttop(box, 12, 108); // Move top-left corner
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
- * Sets the right and bottom coordinates.
207
- *
208
- * @param id - Box object to modify
209
- * @param right - New right border coordinate
210
- * @param bottom - New bottom border price
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
- * ```typescript
215
- * const box = box.new(10, 105, 20, 100);
216
- * box.set_rightbottom(box, 25, 98); // Move bottom-right corner
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
- * Sets the coordinate system for the box.
222
- *
223
- * @param id - Box object to modify
224
- * @param left - New left border coordinate
225
- * @param right - New right border coordinate
226
- * @param xloc - New coordinate system ('bar_index', 'bar_time' or 'pane')
227
- * @returns Modified box object
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
- * ```typescript
234
- * const box = box.new(10, 105, 20, 100);
235
- * // Change to timestamp-based coordinates
236
- * box.set_xloc(box, 1609459200000, 1609545600000, 'bar_time');
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 horizontal extension mode.
242
- *
243
- * @param id - Box object to modify
244
- * @param extend - New extension mode
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
- * ```typescript
249
- * const box = box.new(10, 105, 20, 100);
250
- * box.set_extend(box, 'right'); // Extend box to the right
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 color.
256
- *
257
- * @param id - Box object to modify
258
- * @param borderColor - New border color
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
- * ```typescript
263
- * const box = box.new(10, 105, 20, 100);
264
- * box.set_border_color(box, '#FF0000'); // Red border
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 width.
270
- *
271
- * @param id - Box object to modify
272
- * @param width - New border width in pixels
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
- * ```typescript
277
- * const box = box.new(10, 105, 20, 100);
278
- * box.set_border_width(box, 2); // Thicker border
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 style.
284
- *
285
- * @param id - Box object to modify
286
- * @param style - New border style
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
- * ```typescript
291
- * const box = box.new(10, 105, 20, 100);
292
- * box.set_border_style(box, 'dashed'); // Dashed border
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 background fill color.
298
- *
299
- * @param id - Box object to modify
300
- * @param bgColor - New background color
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
- * ```typescript
305
- * const box = box.new(10, 105, 20, 100);
306
- * box.set_bgcolor(box, '#00FF0030'); // Transparent green fill
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 content.
312
- *
313
- * @param id - Box object to modify
314
- * @param text - New text content
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
- * ```typescript
319
- * const box = box.new(10, 105, 20, 100);
320
- * box.set_text(box, 'Gap Filled'); // Update text
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 color.
326
- *
327
- * @param id - Box object to modify
328
- * @param textColor - New text color
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
- * ```typescript
333
- * const box = box.new(10, 105, 20, 100);
334
- * box.set_text_color(box, '#FFFFFF'); // White text
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 size.
340
- *
341
- * @param id - Box object to modify
342
- * @param size - New text size
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
- * ```typescript
347
- * const box = box.new(10, 105, 20, 100);
348
- * box.set_text_size(box, 'large'); // Larger text
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 alignment.
354
- *
355
- * @param id - Box object to modify
356
- * @param align - New horizontal alignment
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
- * ```typescript
361
- * const box = box.new(10, 105, 20, 100);
362
- * box.set_text_halign(box, 'center'); // Center text horizontally
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 alignment.
368
- *
369
- * @param id - Box object to modify
370
- * @param align - New vertical alignment
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
- * ```typescript
375
- * const box = box.new(10, 105, 20, 100);
376
- * box.set_text_valign(box, 'center'); // Center text vertically
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 the text wrapping mode.
382
- *
383
- * @param id - Box object to modify
384
- * @param wrap - New text wrap mode
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
- * ```typescript
389
- * const box = box.new(10, 105, 20, 100);
390
- * box.set_text_wrap(box, 'auto'); // Enable text wrapping
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 font family.
396
- *
397
- * @param id - Box object to modify
398
- * @param font - New font family
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
- * ```typescript
403
- * const box = box.new(10, 105, 20, 100);
404
- * box.set_text_font_family(box, 'monospace'); // Monospace font
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
- * Deletes the box object.
410
- *
411
- * @param id - Box object to delete
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
- * ```typescript
419
- * const box = box.new(10, 105, 20, 100);
420
- * box.delete(box);
421
- * // box.all() no longer contains it
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
- * All live boxes, in creation order (PineScript `box.all`). A new array.
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
- * Sets the left and top borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).
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
- * Sets the right and bottom borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).
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
- * Sets the text formatting: `text.format_none`, `text.format_bold`, `text.format_italic`,
439
- * or `text.format_bold + text.format_italic`.
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 };