oakscriptjs 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) 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 +532 -61
  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/security/other.d.ts +8 -3
  110. package/dist/cjs/security/other.d.ts.map +1 -1
  111. package/dist/cjs/security/other.js +23 -6
  112. package/dist/cjs/security/other.js.map +2 -2
  113. package/dist/cjs/str/index.d.ts +50 -75
  114. package/dist/cjs/str/index.d.ts.map +1 -1
  115. package/dist/cjs/str/index.js +2 -2
  116. package/dist/cjs/str/index.js.map +2 -2
  117. package/dist/cjs/strategy/index.d.ts +102 -1
  118. package/dist/cjs/strategy/index.d.ts.map +1 -1
  119. package/dist/cjs/strategy/index.js.map +2 -2
  120. package/dist/cjs/table/index.d.ts +330 -49
  121. package/dist/cjs/table/index.d.ts.map +1 -1
  122. package/dist/cjs/table/index.js +55 -27
  123. package/dist/cjs/table/index.js.map +2 -2
  124. package/dist/cjs/text/index.d.ts +12 -14
  125. package/dist/cjs/text/index.d.ts.map +1 -1
  126. package/dist/cjs/text/index.js.map +2 -2
  127. package/dist/cjs/types/index.d.ts +15 -8
  128. package/dist/cjs/types/index.d.ts.map +1 -1
  129. package/dist/cjs/types/index.js +12 -3
  130. package/dist/cjs/types/index.js.map +2 -2
  131. package/dist/esm/box/index.d.ts +348 -289
  132. package/dist/esm/box/index.d.ts.map +1 -1
  133. package/dist/esm/box/index.js +276 -276
  134. package/dist/esm/box/index.js.map +1 -1
  135. package/dist/esm/check/node.d.ts.map +1 -1
  136. package/dist/esm/check/node.js +1 -0
  137. package/dist/esm/check/node.js.map +1 -1
  138. package/dist/esm/check/preview.d.ts +31 -0
  139. package/dist/esm/check/preview.d.ts.map +1 -0
  140. package/dist/esm/check/preview.js +296 -0
  141. package/dist/esm/check/preview.js.map +1 -0
  142. package/dist/esm/color/index.d.ts +11 -11
  143. package/dist/esm/color/index.js +11 -11
  144. package/dist/esm/color/parse.d.ts +2 -0
  145. package/dist/esm/color/parse.d.ts.map +1 -1
  146. package/dist/esm/color/parse.js +7 -0
  147. package/dist/esm/color/parse.js.map +1 -1
  148. package/dist/esm/compare/index.d.ts +76 -12
  149. package/dist/esm/compare/index.d.ts.map +1 -1
  150. package/dist/esm/compare/index.js +76 -12
  151. package/dist/esm/compare/index.js.map +1 -1
  152. package/dist/esm/drawing/registry.d.ts +28 -5
  153. package/dist/esm/drawing/registry.d.ts.map +1 -1
  154. package/dist/esm/drawing/registry.js +39 -3
  155. package/dist/esm/drawing/registry.js.map +1 -1
  156. package/dist/esm/index.d.ts +1 -1
  157. package/dist/esm/index.js +1 -1
  158. package/dist/esm/label/index.d.ts +265 -187
  159. package/dist/esm/label/index.d.ts.map +1 -1
  160. package/dist/esm/label/index.js +207 -177
  161. package/dist/esm/label/index.js.map +1 -1
  162. package/dist/esm/line/index.d.ts +247 -207
  163. package/dist/esm/line/index.d.ts.map +1 -1
  164. package/dist/esm/line/index.js +202 -194
  165. package/dist/esm/line/index.js.map +1 -1
  166. package/dist/esm/linefill/index.d.ts +61 -89
  167. package/dist/esm/linefill/index.d.ts.map +1 -1
  168. package/dist/esm/linefill/index.js +61 -89
  169. package/dist/esm/linefill/index.js.map +1 -1
  170. package/dist/esm/math/index.d.ts +49 -40
  171. package/dist/esm/math/index.d.ts.map +1 -1
  172. package/dist/esm/math/index.js +22 -9
  173. package/dist/esm/math/index.js.map +1 -1
  174. package/dist/esm/polyline/index.d.ts +57 -78
  175. package/dist/esm/polyline/index.d.ts.map +1 -1
  176. package/dist/esm/polyline/index.js +57 -78
  177. package/dist/esm/polyline/index.js.map +1 -1
  178. package/dist/esm/runtime/input-active.d.ts +2 -2
  179. package/dist/esm/runtime/input-active.js +2 -2
  180. package/dist/esm/runtime/series.d.ts +241 -161
  181. package/dist/esm/runtime/series.d.ts.map +1 -1
  182. package/dist/esm/runtime/series.js +241 -161
  183. package/dist/esm/runtime/series.js.map +1 -1
  184. package/dist/esm/script/api/alert.d.ts +37 -0
  185. package/dist/esm/script/api/alert.d.ts.map +1 -0
  186. package/dist/esm/script/api/alert.js +7 -0
  187. package/dist/esm/script/api/alert.js.map +1 -0
  188. package/dist/esm/script/api/calc.d.ts +232 -0
  189. package/dist/esm/script/api/calc.d.ts.map +1 -0
  190. package/dist/esm/script/api/calc.js +6 -0
  191. package/dist/esm/script/api/calc.js.map +1 -0
  192. package/dist/esm/script/api/color.d.ts +213 -0
  193. package/dist/esm/script/api/color.d.ts.map +1 -0
  194. package/dist/esm/script/api/color.js +6 -0
  195. package/dist/esm/script/api/color.js.map +1 -0
  196. package/dist/esm/script/api/context.d.ts +764 -0
  197. package/dist/esm/script/api/context.d.ts.map +1 -0
  198. package/dist/esm/script/api/context.js +7 -0
  199. package/dist/esm/script/api/context.js.map +1 -0
  200. package/dist/esm/script/api/log.d.ts +58 -0
  201. package/dist/esm/script/api/log.d.ts.map +1 -0
  202. package/dist/esm/script/api/log.js +6 -0
  203. package/dist/esm/script/api/log.js.map +1 -0
  204. package/dist/esm/script/api/strategy.d.ts +391 -0
  205. package/dist/esm/script/api/strategy.d.ts.map +1 -0
  206. package/dist/esm/script/api/strategy.js +7 -0
  207. package/dist/esm/script/api/strategy.js.map +1 -0
  208. package/dist/esm/script/api/ta.d.ts +1012 -0
  209. package/dist/esm/script/api/ta.d.ts.map +1 -0
  210. package/dist/esm/script/api/ta.js +6 -0
  211. package/dist/esm/script/api/ta.js.map +1 -0
  212. package/dist/esm/script/api/table.d.ts +479 -0
  213. package/dist/esm/script/api/table.d.ts.map +1 -0
  214. package/dist/esm/script/api/table.js +7 -0
  215. package/dist/esm/script/api/table.js.map +1 -0
  216. package/dist/esm/script/constants.d.ts +228 -83
  217. package/dist/esm/script/constants.d.ts.map +1 -1
  218. package/dist/esm/script/constants.js +110 -24
  219. package/dist/esm/script/constants.js.map +1 -1
  220. package/dist/esm/script/define.d.ts +94 -0
  221. package/dist/esm/script/define.d.ts.map +1 -0
  222. package/dist/esm/script/define.js +136 -0
  223. package/dist/esm/script/define.js.map +1 -0
  224. package/dist/esm/script/drawing-args.d.ts.map +1 -1
  225. package/dist/esm/script/drawing-args.js +2 -1
  226. package/dist/esm/script/drawing-args.js.map +1 -1
  227. package/dist/esm/script/formula.d.ts +53 -0
  228. package/dist/esm/script/formula.d.ts.map +1 -0
  229. package/dist/esm/script/formula.js +408 -0
  230. package/dist/esm/script/formula.js.map +1 -0
  231. package/dist/esm/script/globals.d.ts +10 -0
  232. package/dist/esm/script/globals.d.ts.map +1 -1
  233. package/dist/esm/script/globals.js.map +1 -1
  234. package/dist/esm/script/index.d.ts +1065 -1006
  235. package/dist/esm/script/index.d.ts.map +1 -1
  236. package/dist/esm/script/index.js +1099 -153
  237. package/dist/esm/script/index.js.map +1 -1
  238. package/dist/esm/script/json.d.ts +117 -0
  239. package/dist/esm/script/json.d.ts.map +1 -0
  240. package/dist/esm/script/json.js +375 -0
  241. package/dist/esm/script/json.js.map +1 -0
  242. package/dist/esm/security/other.d.ts +8 -3
  243. package/dist/esm/security/other.d.ts.map +1 -1
  244. package/dist/esm/security/other.js +45 -10
  245. package/dist/esm/security/other.js.map +1 -1
  246. package/dist/esm/str/index.d.ts +50 -75
  247. package/dist/esm/str/index.d.ts.map +1 -1
  248. package/dist/esm/str/index.js +51 -76
  249. package/dist/esm/str/index.js.map +1 -1
  250. package/dist/esm/strategy/index.d.ts +102 -1
  251. package/dist/esm/strategy/index.d.ts.map +1 -1
  252. package/dist/esm/strategy/index.js +1 -1
  253. package/dist/esm/strategy/index.js.map +1 -1
  254. package/dist/esm/table/index.d.ts +330 -49
  255. package/dist/esm/table/index.d.ts.map +1 -1
  256. package/dist/esm/table/index.js +372 -61
  257. package/dist/esm/table/index.js.map +1 -1
  258. package/dist/esm/text/index.d.ts +12 -14
  259. package/dist/esm/text/index.d.ts.map +1 -1
  260. package/dist/esm/text/index.js +12 -14
  261. package/dist/esm/text/index.js.map +1 -1
  262. package/dist/esm/types/index.d.ts +15 -8
  263. package/dist/esm/types/index.d.ts.map +1 -1
  264. package/dist/esm/types/index.js +15 -8
  265. package/dist/esm/types/index.js.map +1 -1
  266. package/docs/first-indicator.md +152 -0
  267. package/docs/guide.md +1185 -0
  268. package/docs/inventory.md +772 -0
  269. package/docs/no-code.md +207 -0
  270. package/docs/recipes.md +202 -0
  271. package/package.json +2 -1
  272. package/skills/oakscript/SKILL.md +8 -0
  273. package/skills/oakscript/reference/errors.md +3 -2
  274. package/skills/oakscript/reference/timeframes-symbols.md +4 -0
  275. package/src/box/index.ts +348 -289
  276. package/src/check/node.ts +1 -0
  277. package/src/check/preview.ts +307 -0
  278. package/src/color/index.ts +11 -11
  279. package/src/color/parse.ts +7 -0
  280. package/src/compare/index.ts +76 -12
  281. package/src/drawing/registry.ts +44 -5
  282. package/src/index.ts +1 -1
  283. package/src/label/index.ts +267 -189
  284. package/src/line/index.ts +248 -208
  285. package/src/linefill/index.ts +61 -89
  286. package/src/math/index.ts +51 -42
  287. package/src/polyline/index.ts +57 -78
  288. package/src/runtime/input-active.ts +2 -2
  289. package/src/runtime/series.ts +243 -163
  290. package/src/script/api/alert.ts +43 -0
  291. package/src/script/api/calc.ts +250 -0
  292. package/src/script/api/color.ts +245 -0
  293. package/src/script/api/context.ts +944 -0
  294. package/src/script/api/log.ts +60 -0
  295. package/src/script/api/strategy.ts +410 -0
  296. package/src/script/api/ta.ts +1115 -0
  297. package/src/script/api/table.ts +538 -0
  298. package/src/script/constants.ts +229 -25
  299. package/src/script/define.ts +221 -0
  300. package/src/script/drawing-args.ts +2 -1
  301. package/src/script/formula.ts +438 -0
  302. package/src/script/globals.ts +10 -0
  303. package/src/script/index.ts +1520 -241
  304. package/src/script/json.ts +457 -0
  305. package/src/security/other.ts +43 -9
  306. package/src/str/index.ts +51 -76
  307. package/src/strategy/index.ts +102 -1
  308. package/src/table/index.ts +388 -62
  309. package/src/text/index.ts +12 -14
  310. 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
  */
@@ -49,108 +47,76 @@ export function new_box(...args) {
49
47
  });
50
48
  }
51
49
  /**
52
- * Returns the left border x coordinate.
53
- *
54
- * @param id - Box object
55
- * @returns Left border coordinate (bar index or timestamp)
56
- *
57
- * @remarks
58
- * **COMPUTATIONAL USE**: Calculate gap duration, validate range timeframes
59
- *
50
+ * Returns the x coordinate of the box's left side, for example to count how many bars a zone has been open.
51
+ * @param id - The box.
52
+ * @returns A bar index, a UNIX time in ms or a pane percent, by the box's xloc; NaN for a deleted box.
60
53
  * @example
61
- * ```typescript
62
- * const gap = box.new(10, 105, 20, 100);
63
- * const currentBar = 30;
64
- * const duration = currentBar - box.get_left(gap); // Returns 20
65
- *
66
- * if (duration > 50) {
67
- * console.log('Gap has been open for 50+ bars');
68
- * }
54
+ * ```js
55
+ * eachBar((c) => {
56
+ * const b = box.new(c.i - 10, c.get(high, 10), c.i, c.low);
57
+ * const age = c.i - box.get_left(b); // 10
58
+ * });
69
59
  * ```
70
60
  */
71
61
  export function get_left(id) {
72
62
  return id.left;
73
63
  }
74
64
  /**
75
- * Returns the right border x coordinate.
76
- *
77
- * @param id - Box object
78
- * @returns Right border coordinate (bar index or timestamp)
79
- *
80
- * @remarks
81
- * **COMPUTATIONAL USE**: Calculate gap duration, update trailing edges
82
- *
65
+ * Returns the x coordinate of the box's right side.
66
+ * @param id - The box.
67
+ * @returns A bar index, a UNIX time in ms or a pane percent, by the box's xloc; NaN for a deleted box.
83
68
  * @example
84
- * ```typescript
85
- * const range = box.new(100, 155, 150, 145);
86
- * const width = box.get_right(range) - box.get_left(range); // Returns 50 bars
69
+ * ```js
70
+ * eachBar((c) => {
71
+ * const b = box.new(c.i - 10, c.get(high, 10), c.i, c.low);
72
+ * const bars = box.get_right(b) - box.get_left(b); // 10
73
+ * });
87
74
  * ```
88
75
  */
89
76
  export function get_right(id) {
90
77
  return id.right;
91
78
  }
92
79
  /**
93
- * Returns the top border price level.
94
- *
95
- * @param id - Box object
96
- * @returns Top border price
97
- *
98
- * @remarks
99
- * **COMPUTATIONAL USE**: Detect breakouts above resistance, check gap fills
100
- *
80
+ * Returns the price of the box's top side, for example to test a breakout above a range.
81
+ * @param id - The box.
82
+ * @returns The top price; NaN for a deleted box.
101
83
  * @example
102
- * ```typescript
103
- * const gap = box.new(10, 105, 20, 100); // Bearish gap
104
- *
105
- * // Check if price has filled gap from below
106
- * const high = 106;
107
- * if (high > box.get_top(gap)) {
108
- * console.log('Gap completely filled!');
109
- * }
84
+ * ```js
85
+ * eachBar((c) => {
86
+ * const b = box.new(c.i - 10, c.get(high, 1), c.i - 1, c.get(low, 1));
87
+ * if (c.close > box.get_top(b)) label.new(c.i, c.high, "Breakout");
88
+ * });
110
89
  * ```
111
90
  */
112
91
  export function get_top(id) {
113
92
  return id.top;
114
93
  }
115
94
  /**
116
- * Returns the bottom border price level.
117
- *
118
- * @param id - Box object
119
- * @returns Bottom border price
120
- *
121
- * @remarks
122
- * **COMPUTATIONAL USE**: Detect breakouts below support, check gap fills
123
- *
95
+ * Returns the price of the box's bottom side, for example to test a breakdown below a range.
96
+ * @param id - The box.
97
+ * @returns The bottom price; NaN for a deleted box.
124
98
  * @example
125
- * ```typescript
126
- * const gap = box.new(10, 105, 20, 100); // Bearish gap
127
- *
128
- * // Check if price has touched gap from above
129
- * const low = 104;
130
- * if (low < box.get_top(gap) && low > box.get_bottom(gap)) {
131
- * console.log('Price entered the gap!');
132
- * }
99
+ * ```js
100
+ * eachBar((c) => {
101
+ * const b = box.new(c.i - 10, c.get(high, 1), c.i - 1, c.get(low, 1));
102
+ * if (c.close < box.get_bottom(b)) label.new(c.i, c.low, "Breakdown", { style: label.style_label_up });
103
+ * });
133
104
  * ```
134
105
  */
135
106
  export function get_bottom(id) {
136
107
  return id.bottom;
137
108
  }
138
109
  /**
139
- * Creates a copy of the box object.
140
- *
141
- * @param id - Box object to copy
142
- * @returns New box object with same properties
143
- *
144
- * @remarks
145
- * Creates a shallow copy of the box. Modifications to the copy won't affect the original.
146
- *
110
+ * Makes a new box with the same sides, colours and text as `id` (it counts toward `max_boxes_count`).
111
+ * Changing the copy does not change the original.
112
+ * @param id - The box to copy.
113
+ * @returns The new box.
147
114
  * @example
148
- * ```typescript
149
- * const originalBox = box.new(10, 105, 20, 100);
150
- * const copiedBox = box.copy(originalBox);
151
- *
152
- * // Modify copy without affecting original
153
- * copiedBox.top = 110;
115
+ * ```js
116
+ * eachBar((c) => {
117
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
118
+ * box.set_bgcolor(box.copy(b), color.new(color.red, 80)); // a red copy over the same bars
119
+ * });
154
120
  * ```
155
121
  */
156
122
  export function copy(id) {
@@ -160,16 +126,17 @@ export function copy(id) {
160
126
  // COORDINATE SETTERS
161
127
  // =============================================================================
162
128
  /**
163
- * Sets the left border x coordinate.
164
- *
165
- * @param id - Box object to modify
166
- * @param left - New left border coordinate
167
- * @returns Modified box object
168
- *
129
+ * Moves the box's left side. Does nothing on a deleted box.
130
+ * @param id - The box.
131
+ * @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
132
+ * down.
133
+ * @returns The same box.
169
134
  * @example
170
- * ```typescript
171
- * const box = box.new(10, 105, 20, 100);
172
- * box.set_left(box, 15); // Move left edge to bar 15
135
+ * ```js
136
+ * eachBar((c) => {
137
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
138
+ * box.set_left(b, c.i - 20);
139
+ * });
173
140
  * ```
174
141
  */
175
142
  export function set_left(id, left) {
@@ -180,16 +147,17 @@ export function set_left(id, left) {
180
147
  return id;
181
148
  }
182
149
  /**
183
- * Sets the right border x coordinate.
184
- *
185
- * @param id - Box object to modify
186
- * @param right - New right border coordinate
187
- * @returns Modified box object
188
- *
150
+ * Moves the box's right side, for example to stretch a zone to the current bar. Does nothing on a deleted box.
151
+ * @param id - The box.
152
+ * @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
153
+ * down.
154
+ * @returns The same box.
189
155
  * @example
190
- * ```typescript
191
- * const box = box.new(10, 105, 20, 100);
192
- * box.set_right(box, 25); // Move right edge to bar 25
156
+ * ```js
157
+ * eachBar((c) => {
158
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
159
+ * box.set_right(b, c.i + 10); // reach 10 bars into the future
160
+ * });
193
161
  * ```
194
162
  */
195
163
  export function set_right(id, right) {
@@ -200,16 +168,16 @@ export function set_right(id, right) {
200
168
  return id;
201
169
  }
202
170
  /**
203
- * Sets the top border price level.
204
- *
205
- * @param id - Box object to modify
206
- * @param top - New top border price
207
- * @returns Modified box object
208
- *
171
+ * Moves the box's top side. Does nothing on a deleted box.
172
+ * @param id - The box.
173
+ * @param top - New top price.
174
+ * @returns The same box.
209
175
  * @example
210
- * ```typescript
211
- * const box = box.new(10, 105, 20, 100);
212
- * box.set_top(box, 110); // Move top edge to price 110
176
+ * ```js
177
+ * eachBar((c) => {
178
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
179
+ * box.set_top(b, c.get(high, 10));
180
+ * });
213
181
  * ```
214
182
  */
215
183
  export function set_top(id, top) {
@@ -219,16 +187,16 @@ export function set_top(id, top) {
219
187
  return id;
220
188
  }
221
189
  /**
222
- * Sets the bottom border price level.
223
- *
224
- * @param id - Box object to modify
225
- * @param bottom - New bottom border price
226
- * @returns Modified box object
227
- *
190
+ * Moves the box's bottom side. Does nothing on a deleted box.
191
+ * @param id - The box.
192
+ * @param bottom - New bottom price.
193
+ * @returns The same box.
228
194
  * @example
229
- * ```typescript
230
- * const box = box.new(10, 105, 20, 100);
231
- * box.set_bottom(box, 95); // Move bottom edge to price 95
195
+ * ```js
196
+ * eachBar((c) => {
197
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
198
+ * box.set_bottom(b, c.get(low, 10));
199
+ * });
232
200
  * ```
233
201
  */
234
202
  export function set_bottom(id, bottom) {
@@ -238,17 +206,17 @@ export function set_bottom(id, bottom) {
238
206
  return id;
239
207
  }
240
208
  /**
241
- * Sets the left and top coordinates.
242
- *
243
- * @param id - Box object to modify
244
- * @param left - New left border coordinate
245
- * @param top - New top border price
246
- * @returns Modified box object
247
- *
209
+ * Moves the box's top-left corner (left side and top price). Does nothing on a deleted box.
210
+ * @param id - The box.
211
+ * @param left - New x of the left side, by the box's xloc. A bar index is rounded down.
212
+ * @param top - New top price.
213
+ * @returns The same box.
248
214
  * @example
249
- * ```typescript
250
- * const box = box.new(10, 105, 20, 100);
251
- * box.set_lefttop(box, 12, 108); // Move top-left corner
215
+ * ```js
216
+ * eachBar((c) => {
217
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
218
+ * box.set_lefttop(b, c.i - 20, c.get(high, 20));
219
+ * });
252
220
  * ```
253
221
  */
254
222
  export function set_lefttop(id, left, top) {
@@ -260,17 +228,17 @@ export function set_lefttop(id, left, top) {
260
228
  return id;
261
229
  }
262
230
  /**
263
- * Sets the right and bottom coordinates.
264
- *
265
- * @param id - Box object to modify
266
- * @param right - New right border coordinate
267
- * @param bottom - New bottom border price
268
- * @returns Modified box object
269
- *
231
+ * Moves the box's bottom-right corner (right side and bottom price). Does nothing on a deleted box.
232
+ * @param id - The box.
233
+ * @param right - New x of the right side, by the box's xloc. A bar index is rounded down.
234
+ * @param bottom - New bottom price.
235
+ * @returns The same box.
270
236
  * @example
271
- * ```typescript
272
- * const box = box.new(10, 105, 20, 100);
273
- * box.set_rightbottom(box, 25, 98); // Move bottom-right corner
237
+ * ```js
238
+ * eachBar((c) => {
239
+ * const b = box.new(c.i - 10, c.high, c.i - 1, c.low);
240
+ * box.set_rightbottom(b, c.i, c.low);
241
+ * });
274
242
  * ```
275
243
  */
276
244
  export function set_rightbottom(id, right, bottom) {
@@ -282,22 +250,20 @@ export function set_rightbottom(id, right, bottom) {
282
250
  return id;
283
251
  }
284
252
  /**
285
- * Sets the coordinate system for the box.
286
- *
287
- * @param id - Box object to modify
288
- * @param left - New left border coordinate
289
- * @param right - New right border coordinate
290
- * @param xloc - New coordinate system ('bar_index', 'bar_time' or 'pane')
291
- * @returns Modified box object
292
- *
293
- * @remarks
294
- * When changing xloc, you must provide appropriate x coordinates for the new system.
295
- *
253
+ * Changes what the box's x coordinates are and sets its left and right sides in that unit. Does nothing on a
254
+ * deleted box.
255
+ * @param id - The box.
256
+ * @param left - New x of the left side, in the unit of `xloc`.
257
+ * @param right - New x of the right side, in the unit of `xloc`.
258
+ * @param xloc - `xloc.bar_index` (bar indexes), `xloc.bar_time` (UNIX times in ms) or `xloc.pane` (percents of the
259
+ * pane's width).
260
+ * @returns The same box.
296
261
  * @example
297
- * ```typescript
298
- * const box = box.new(10, 105, 20, 100);
299
- * // Change to timestamp-based coordinates
300
- * box.set_xloc(box, 1609459200000, 1609545600000, 'bar_time');
262
+ * ```js
263
+ * eachBar((c) => {
264
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
265
+ * box.set_xloc(b, c.time - 3600000, c.time, xloc.bar_time);
266
+ * });
301
267
  * ```
302
268
  */
303
269
  export function set_xloc(id, left, right, xloc) {
@@ -309,16 +275,16 @@ export function set_xloc(id, left, right, xloc) {
309
275
  return id;
310
276
  }
311
277
  /**
312
- * Sets the horizontal extension mode.
313
- *
314
- * @param id - Box object to modify
315
- * @param extend - New extension mode
316
- * @returns Modified box object
317
- *
278
+ * Sets whether the box continues sideways to the edge of the pane. Does nothing on a deleted box.
279
+ * @param id - The box.
280
+ * @param extend - `extend.none`, `extend.left`, `extend.right` or `extend.both`.
281
+ * @returns The same box.
318
282
  * @example
319
- * ```typescript
320
- * const box = box.new(10, 105, 20, 100);
321
- * box.set_extend(box, 'right'); // Extend box to the right
283
+ * ```js
284
+ * eachBar((c) => {
285
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
286
+ * box.set_extend(b, extend.right);
287
+ * });
322
288
  * ```
323
289
  */
324
290
  export function set_extend(id, extend) {
@@ -331,16 +297,16 @@ export function set_extend(id, extend) {
331
297
  // STYLING SETTERS
332
298
  // =============================================================================
333
299
  /**
334
- * Sets the border color.
335
- *
336
- * @param id - Box object to modify
337
- * @param borderColor - New border color
338
- * @returns Modified box object
339
- *
300
+ * Sets the colour of the box's border. Does nothing on a deleted box.
301
+ * @param id - The box.
302
+ * @param borderColor - New colour (`color.red`, `"#FF0000"`, `color.new(color.red, 50)`...).
303
+ * @returns The same box.
340
304
  * @example
341
- * ```typescript
342
- * const box = box.new(10, 105, 20, 100);
343
- * box.set_border_color(box, '#FF0000'); // Red border
305
+ * ```js
306
+ * eachBar((c) => {
307
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
308
+ * box.set_border_color(b, color.red);
309
+ * });
344
310
  * ```
345
311
  */
346
312
  export function set_border_color(id, borderColor) {
@@ -350,16 +316,16 @@ export function set_border_color(id, borderColor) {
350
316
  return id;
351
317
  }
352
318
  /**
353
- * Sets the border width.
354
- *
355
- * @param id - Box object to modify
356
- * @param width - New border width in pixels
357
- * @returns Modified box object
358
- *
319
+ * Sets the width of the box's border. Does nothing on a deleted box.
320
+ * @param id - The box.
321
+ * @param width - New width in pixels; 0 draws no border.
322
+ * @returns The same box.
359
323
  * @example
360
- * ```typescript
361
- * const box = box.new(10, 105, 20, 100);
362
- * box.set_border_width(box, 2); // Thicker border
324
+ * ```js
325
+ * eachBar((c) => {
326
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
327
+ * box.set_border_width(b, 2);
328
+ * });
363
329
  * ```
364
330
  */
365
331
  export function set_border_width(id, width) {
@@ -369,16 +335,16 @@ export function set_border_width(id, width) {
369
335
  return id;
370
336
  }
371
337
  /**
372
- * Sets the border style.
373
- *
374
- * @param id - Box object to modify
375
- * @param style - New border style
376
- * @returns Modified box object
377
- *
338
+ * Sets the style of the box's border. Does nothing on a deleted box.
339
+ * @param id - The box.
340
+ * @param style - `line.style_solid`, `line.style_dotted` or `line.style_dashed`.
341
+ * @returns The same box.
378
342
  * @example
379
- * ```typescript
380
- * const box = box.new(10, 105, 20, 100);
381
- * box.set_border_style(box, 'dashed'); // Dashed border
343
+ * ```js
344
+ * eachBar((c) => {
345
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
346
+ * box.set_border_style(b, line.style_dashed);
347
+ * });
382
348
  * ```
383
349
  */
384
350
  export function set_border_style(id, style) {
@@ -388,16 +354,16 @@ export function set_border_style(id, style) {
388
354
  return id;
389
355
  }
390
356
  /**
391
- * Sets the background fill color.
392
- *
393
- * @param id - Box object to modify
394
- * @param bgColor - New background color
395
- * @returns Modified box object
396
- *
357
+ * Sets the fill colour of the box. Does nothing on a deleted box.
358
+ * @param id - The box.
359
+ * @param bgColor - New fill colour; a transparent one (`color.new(color.green, 80)`) keeps the bars visible.
360
+ * @returns The same box.
397
361
  * @example
398
- * ```typescript
399
- * const box = box.new(10, 105, 20, 100);
400
- * box.set_bgcolor(box, '#00FF0030'); // Transparent green fill
362
+ * ```js
363
+ * eachBar((c) => {
364
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
365
+ * box.set_bgcolor(b, c.close > c.open ? color.new(color.green, 80) : color.new(color.red, 80));
366
+ * });
401
367
  * ```
402
368
  */
403
369
  export function set_bgcolor(id, bgColor) {
@@ -410,16 +376,16 @@ export function set_bgcolor(id, bgColor) {
410
376
  // TEXT SETTERS
411
377
  // =============================================================================
412
378
  /**
413
- * Sets the text content.
414
- *
415
- * @param id - Box object to modify
416
- * @param text - New text content
417
- * @returns Modified box object
418
- *
379
+ * Sets the text written inside the box. Does nothing on a deleted box.
380
+ * @param id - The box.
381
+ * @param text - New text; `\n` starts a new line.
382
+ * @returns The same box.
419
383
  * @example
420
- * ```typescript
421
- * const box = box.new(10, 105, 20, 100);
422
- * box.set_text(box, 'Gap Filled'); // Update text
384
+ * ```js
385
+ * eachBar((c) => {
386
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
387
+ * box.set_text(b, "Range " + str.tostring(c.high - c.low, "#.##"));
388
+ * });
423
389
  * ```
424
390
  */
425
391
  export function set_text(id, text) {
@@ -429,16 +395,16 @@ export function set_text(id, text) {
429
395
  return id;
430
396
  }
431
397
  /**
432
- * Sets the text color.
433
- *
434
- * @param id - Box object to modify
435
- * @param textColor - New text color
436
- * @returns Modified box object
437
- *
398
+ * Sets the colour of the box's text. Does nothing on a deleted box.
399
+ * @param id - The box.
400
+ * @param textColor - New text colour.
401
+ * @returns The same box.
438
402
  * @example
439
- * ```typescript
440
- * const box = box.new(10, 105, 20, 100);
441
- * box.set_text_color(box, '#FFFFFF'); // White text
403
+ * ```js
404
+ * eachBar((c) => {
405
+ * const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
406
+ * box.set_text_color(b, color.black);
407
+ * });
442
408
  * ```
443
409
  */
444
410
  export function set_text_color(id, textColor) {
@@ -448,16 +414,16 @@ export function set_text_color(id, textColor) {
448
414
  return id;
449
415
  }
450
416
  /**
451
- * Sets the text size.
452
- *
453
- * @param id - Box object to modify
454
- * @param size - New text size
455
- * @returns Modified box object
456
- *
417
+ * Sets the size of the box's text. Does nothing on a deleted box.
418
+ * @param id - The box.
419
+ * @param size - `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`, `size.auto`, or a size in points.
420
+ * @returns The same box.
457
421
  * @example
458
- * ```typescript
459
- * const box = box.new(10, 105, 20, 100);
460
- * box.set_text_size(box, 'large'); // Larger text
422
+ * ```js
423
+ * eachBar((c) => {
424
+ * const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
425
+ * box.set_text_size(b, size.large);
426
+ * });
461
427
  * ```
462
428
  */
463
429
  export function set_text_size(id, size) {
@@ -467,16 +433,16 @@ export function set_text_size(id, size) {
467
433
  return id;
468
434
  }
469
435
  /**
470
- * Sets the horizontal text alignment.
471
- *
472
- * @param id - Box object to modify
473
- * @param align - New horizontal alignment
474
- * @returns Modified box object
475
- *
436
+ * Sets the horizontal place of the text inside the box. Does nothing on a deleted box.
437
+ * @param id - The box.
438
+ * @param align - `text.align_left`, `text.align_center` or `text.align_right`.
439
+ * @returns The same box.
476
440
  * @example
477
- * ```typescript
478
- * const box = box.new(10, 105, 20, 100);
479
- * box.set_text_halign(box, 'center'); // Center text horizontally
441
+ * ```js
442
+ * eachBar((c) => {
443
+ * const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
444
+ * box.set_text_halign(b, text.align_left);
445
+ * });
480
446
  * ```
481
447
  */
482
448
  export function set_text_halign(id, align) {
@@ -486,16 +452,16 @@ export function set_text_halign(id, align) {
486
452
  return id;
487
453
  }
488
454
  /**
489
- * Sets the vertical text alignment.
490
- *
491
- * @param id - Box object to modify
492
- * @param align - New vertical alignment
493
- * @returns Modified box object
494
- *
455
+ * Sets the vertical place of the text inside the box. Does nothing on a deleted box.
456
+ * @param id - The box.
457
+ * @param align - `text.align_top`, `text.align_center` or `text.align_bottom`.
458
+ * @returns The same box.
495
459
  * @example
496
- * ```typescript
497
- * const box = box.new(10, 105, 20, 100);
498
- * box.set_text_valign(box, 'center'); // Center text vertically
460
+ * ```js
461
+ * eachBar((c) => {
462
+ * const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
463
+ * box.set_text_valign(b, text.align_top);
464
+ * });
499
465
  * ```
500
466
  */
501
467
  export function set_text_valign(id, align) {
@@ -505,16 +471,16 @@ export function set_text_valign(id, align) {
505
471
  return id;
506
472
  }
507
473
  /**
508
- * Sets the text wrapping mode.
509
- *
510
- * @param id - Box object to modify
511
- * @param wrap - New text wrap mode
512
- * @returns Modified box object
513
- *
474
+ * Sets whether a long text wraps onto several lines to fit the width of the box. Does nothing on a deleted box.
475
+ * @param id - The box.
476
+ * @param wrap - `text.wrap_auto` (wrap to the box's width) or `text.wrap_none` (each line stays whole).
477
+ * @returns The same box.
514
478
  * @example
515
- * ```typescript
516
- * const box = box.new(10, 105, 20, 100);
517
- * box.set_text_wrap(box, 'auto'); // Enable text wrapping
479
+ * ```js
480
+ * eachBar((c) => {
481
+ * const b = box.new(c.i - 3, c.high, c.i, c.low, { text: "A long note about this zone" });
482
+ * box.set_text_wrap(b, text.wrap_auto);
483
+ * });
518
484
  * ```
519
485
  */
520
486
  export function set_text_wrap(id, wrap) {
@@ -524,16 +490,16 @@ export function set_text_wrap(id, wrap) {
524
490
  return id;
525
491
  }
526
492
  /**
527
- * Sets the text font family.
528
- *
529
- * @param id - Box object to modify
530
- * @param font - New font family
531
- * @returns Modified box object
532
- *
493
+ * Sets the font of the box's text. Does nothing on a deleted box.
494
+ * @param id - The box.
495
+ * @param font - `font.family_default` or `font.family_monospace`.
496
+ * @returns The same box.
533
497
  * @example
534
- * ```typescript
535
- * const box = box.new(10, 105, 20, 100);
536
- * box.set_text_font_family(box, 'monospace'); // Monospace font
498
+ * ```js
499
+ * eachBar((c) => {
500
+ * const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "123.45" });
501
+ * box.set_text_font_family(b, font.family_monospace);
502
+ * });
537
503
  * ```
538
504
  */
539
505
  export function set_text_font_family(id, font) {
@@ -543,19 +509,15 @@ export function set_text_font_family(id, font) {
543
509
  return id;
544
510
  }
545
511
  /**
546
- * Deletes the box object.
547
- *
548
- * @param id - Box object to delete
549
- *
550
- * @remarks
551
- * Removes the box from `box.all()`. As in PineScript, the deleted box is `na`: its getters
552
- * return NaN and its setters do nothing. Deleting it twice has no effect.
553
- *
512
+ * Removes the box from the chart and from `box.all`. Afterwards its getters return NaN and its setters do nothing;
513
+ * deleting it again does nothing.
514
+ * @param id - The box to delete.
554
515
  * @example
555
- * ```typescript
556
- * const box = box.new(10, 105, 20, 100);
557
- * box.delete(box);
558
- * // box.all() no longer contains it
516
+ * ```js
517
+ * eachBar((c) => {
518
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
519
+ * if (c.i < c.n - 1) box.delete(b); // keep only the box of the last bar
520
+ * });
559
521
  * ```
560
522
  */
561
523
  export function delete_box(id) {
@@ -567,13 +529,32 @@ function pointX(point, xloc) {
567
529
  return x ?? NaN;
568
530
  }
569
531
  /**
570
- * All live boxes, in creation order (PineScript `box.all`). A new array.
532
+ * Returns the boxes that are still on the chart, oldest first. The array is a copy.
533
+ * (In a script, `box.all` is read as a value, without a call.)
534
+ * @returns The live boxes in creation order.
535
+ * @example
536
+ * ```js
537
+ * eachBar((c) => {
538
+ * if (c.i === c.n - 1) for (const b of box.all) box.set_right(b, c.i);
539
+ * });
540
+ * ```
571
541
  */
572
542
  export function all() {
573
543
  return allDrawings('box');
574
544
  }
575
545
  /**
576
- * Sets the left and top borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).
546
+ * Moves the box's top-left corner to a chart point: its `index` for a `xloc.bar_index` box, its `time` for a
547
+ * `xloc.bar_time` box (NaN when the point has none), and its `price`. Does nothing on a deleted box.
548
+ * @param id - The box.
549
+ * @param point - The new top-left corner.
550
+ * @returns The same box.
551
+ * @example
552
+ * ```js
553
+ * eachBar((c) => {
554
+ * const b = box.new(c.i - 10, c.high, c.i, c.low);
555
+ * box.set_top_left_point(b, chart.point.from_index(c.i - 20, c.get(high, 20)));
556
+ * });
557
+ * ```
577
558
  */
578
559
  export function set_top_left_point(id, point) {
579
560
  if (isDeleted(id))
@@ -583,7 +564,17 @@ export function set_top_left_point(id, point) {
583
564
  return id;
584
565
  }
585
566
  /**
586
- * Sets the right and bottom borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).
567
+ * Moves the box's bottom-right corner to a chart point (see `box.set_top_left_point`). Does nothing on a deleted box.
568
+ * @param id - The box.
569
+ * @param point - The new bottom-right corner.
570
+ * @returns The same box.
571
+ * @example
572
+ * ```js
573
+ * eachBar((c) => {
574
+ * const b = box.new(c.i - 10, c.high, c.i - 1, c.low);
575
+ * box.set_bottom_right_point(b, chart.point.now(c.low));
576
+ * });
577
+ * ```
587
578
  */
588
579
  export function set_bottom_right_point(id, point) {
589
580
  if (isDeleted(id))
@@ -593,8 +584,17 @@ export function set_bottom_right_point(id, point) {
593
584
  return id;
594
585
  }
595
586
  /**
596
- * Sets the text formatting: `text.format_none`, `text.format_bold`, `text.format_italic`,
597
- * or `text.format_bold + text.format_italic`.
587
+ * Makes the box's text bold, italic, both or plain. Does nothing on a deleted box.
588
+ * @param id - The box.
589
+ * @param formatting - `text.format_bold`, `text.format_italic`, their sum, or `text.format_none`.
590
+ * @returns The same box.
591
+ * @example
592
+ * ```js
593
+ * eachBar((c) => {
594
+ * const b = box.new(c.i - 10, c.high, c.i, c.low, { text: "Zone" });
595
+ * box.set_text_formatting(b, text.format_bold);
596
+ * });
597
+ * ```
598
598
  */
599
599
  export function set_text_formatting(id, formatting) {
600
600
  if (isDeleted(id))