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
@@ -0,0 +1,538 @@
1
+ /**
2
+ * @fileoverview Documented type of the `table` script global: tables fixed at a place of the pane, their cells and
3
+ * their look. Inside a bar loop a Series given for a number is read on the current bar.
4
+ * @module script/api/table
5
+ */
6
+
7
+ import type { Series } from '../../runtime/series.js';
8
+ import type { Table } from '../../types/index.js';
9
+ import type { TableCellArgs, TableNewArgs } from '../index.js';
10
+
11
+ /** A number, or a Series read on the current bar (inside a bar loop). */
12
+ type Numeric = number | Series;
13
+ /** A colour: `color.red`, `"#FF0000"`, `color.new(color.red, 50)`... */
14
+ type Colour = string;
15
+ /** Where a table sits in the pane (`position.*`). */
16
+ type TablePosition = Table['position'];
17
+ type HAlign = 'left' | 'center' | 'right';
18
+ type VAlign = 'top' | 'center' | 'bottom';
19
+ type FontFamily = 'default' | 'monospace';
20
+
21
+ /**
22
+ * The `table` global: tables fixed at a place of the pane (they do not scroll with the bars), to show values,
23
+ * statistics or a dashboard. Create one with `table.new()`, fill it with `table.cell()`. A column or row outside the
24
+ * table is an error; on a deleted table the functions do nothing.
25
+ */
26
+ export interface TableNamespace {
27
+ /**
28
+ * Creates a table fixed at a place of the pane (it does not scroll with the bars) and returns its handle; fill its
29
+ * cells with `table.cell()`. A pane holds one table per position: a live table at the same position (with the same
30
+ * `force_overlay`) is deleted. The arguments after `rows` can also be given by name in an object.
31
+ * @param position - Where the table sits: `position.top_left`, `position.top_center`, `position.top_right`,
32
+ * `position.middle_left`, `position.middle_center`, `position.middle_right`, `position.bottom_left`,
33
+ * `position.bottom_center` or `position.bottom_right`.
34
+ * @param columns - Number of columns.
35
+ * @param rows - Number of rows.
36
+ * @param bgcolor - Background colour of the whole table. Default: none (transparent).
37
+ * @param frame_color - Colour of the outer frame. Default: none.
38
+ * @param frame_width - Width of the outer frame in pixels. Default: 0 (no frame).
39
+ * @param border_color - Colour of the lines between the cells. Default: none.
40
+ * @param border_width - Width of the lines between the cells in pixels. Default: 0 (no lines).
41
+ * @param force_overlay - When true, the table is drawn on the price pane even if the script has its own pane.
42
+ * Default: false.
43
+ * @returns The new table.
44
+ * @example
45
+ * ```js
46
+ * const t = table.new(position.top_right, 2, 1, color.new(color.black, 20));
47
+ * eachBar((c) => {
48
+ * if (c.i === c.n - 1) table.cell(t, 0, 0, "Close", 0, 0, color.white);
49
+ * });
50
+ * ```
51
+ */
52
+ 'new'(
53
+ position: TablePosition,
54
+ columns: Numeric,
55
+ rows: Numeric,
56
+ bgcolor?: Colour,
57
+ frame_color?: Colour,
58
+ frame_width?: Numeric,
59
+ border_color?: Colour,
60
+ border_width?: Numeric,
61
+ force_overlay?: boolean
62
+ ): Table;
63
+ /**
64
+ * Creates a table, with the arguments after `rows` given by name (see the first form).
65
+ * @param position - Where the table sits (`position.top_right`, `position.bottom_left`...).
66
+ * @param columns - Number of columns.
67
+ * @param rows - Number of rows.
68
+ * @param args - The other arguments by name: `bgcolor`, `frame_color`, `frame_width`, `border_color`,
69
+ * `border_width`, `force_overlay`.
70
+ * @returns The new table.
71
+ * @example
72
+ * ```js
73
+ * const t = table.new(position.bottom_left, 2, 3, { bgcolor: color.new(color.black, 20), border_width: 1 });
74
+ * ```
75
+ */
76
+ 'new'(position: TablePosition, columns: Numeric, rows: Numeric, args: TableNewArgs): Table;
77
+ /**
78
+ * Creates a table, with every argument given by name (see the first form).
79
+ * @param args - `position`, `columns`, `rows`, and optionally `bgcolor`, `frame_color`, `frame_width`,
80
+ * `border_color`, `border_width`, `force_overlay`.
81
+ * @returns The new table.
82
+ * @example
83
+ * ```js
84
+ * const t = table.new({ position: position.top_center, columns: 3, rows: 1 });
85
+ * ```
86
+ */
87
+ 'new'(args: TableNewArgs): Table;
88
+ /**
89
+ * Creates a table, with its arguments by position only (`table.new()` also takes them by name).
90
+ * @param position - Where the table sits (`position.top_right`, `position.bottom_left`...).
91
+ * @param columns - Number of columns.
92
+ * @param rows - Number of rows.
93
+ * @param bgcolor - Background colour of the whole table. Default: none.
94
+ * @param frame_color - Colour of the outer frame. Default: none.
95
+ * @param frame_width - Width of the outer frame in pixels. Default: 0.
96
+ * @param border_color - Colour of the lines between the cells. Default: none.
97
+ * @param border_width - Width of the lines between the cells in pixels. Default: 0.
98
+ * @param force_overlay - When true, the table is drawn on the price pane. Default: false.
99
+ * @returns The new table.
100
+ * @example
101
+ * ```js
102
+ * const t = table.new_table(position.top_right, 1, 1, color.gray);
103
+ * ```
104
+ */
105
+ new_table(
106
+ position: TablePosition,
107
+ columns: Numeric,
108
+ rows: Numeric,
109
+ bgcolor?: Colour,
110
+ frame_color?: Colour,
111
+ frame_width?: Numeric,
112
+ border_color?: Colour,
113
+ border_width?: Numeric,
114
+ force_overlay?: boolean
115
+ ): Table;
116
+
117
+ /**
118
+ * Writes a cell of a table: its text and look. The properties not given get their default, so calling it again
119
+ * replaces the whole cell; use `table.cell_set_*()` to change one property. A column or row outside the table is an
120
+ * error; on a deleted table it does nothing. The arguments after `row` can also be given by name in an object.
121
+ * @param table_id - The table (from `table.new()`).
122
+ * @param column - Column of the cell, from 0 (left).
123
+ * @param row - Row of the cell, from 0 (top).
124
+ * @param text - Text of the cell; `\n` starts a new line. Default: "".
125
+ * @param width - Width of the cell in percent of the pane's width; 0 fits the text. Default: 0.
126
+ * @param height - Height of the cell in percent of the pane's height; 0 fits the text. Default: 0.
127
+ * @param text_color - Text colour. Default: dark gray (#363A45).
128
+ * @param text_halign - `text.align_left`, `text.align_center` or `text.align_right`. Default: `text.align_center`.
129
+ * @param text_valign - `text.align_top`, `text.align_center` or `text.align_bottom`. Default: `text.align_center`.
130
+ * @param text_size - `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`, `size.auto`, or a size in
131
+ * points. Default: `size.auto`.
132
+ * @param bgcolor - Background colour of the cell. Default: none (the table's background shows).
133
+ * @param tooltip - Text shown when the pointer is over the cell. Default: none.
134
+ * @param text_font_family - `font.family_default` or `font.family_monospace`. Default: `font.family_default`.
135
+ * @param text_formatting - `text.format_bold`, `text.format_italic`, their sum, or `text.format_none`.
136
+ * Default: `text.format_none`.
137
+ * @returns Nothing.
138
+ * @example
139
+ * ```js
140
+ * const t = table.new(position.bottom_right, 2, 1);
141
+ * eachBar((c) => {
142
+ * if (c.i === c.n - 1) table.cell(t, 1, 0, str.tostring(c.close, "#.##"), 0, 0, color.white, text.align_right);
143
+ * });
144
+ * ```
145
+ */
146
+ cell(
147
+ table_id: Table,
148
+ column: Numeric,
149
+ row: Numeric,
150
+ text?: string,
151
+ width?: Numeric,
152
+ height?: Numeric,
153
+ text_color?: Colour,
154
+ text_halign?: HAlign,
155
+ text_valign?: VAlign,
156
+ text_size?: string | number,
157
+ bgcolor?: Colour,
158
+ tooltip?: string,
159
+ text_font_family?: FontFamily,
160
+ text_formatting?: number
161
+ ): void;
162
+ /**
163
+ * Writes a cell, with the arguments after `row` given by name (see the first form).
164
+ * @param table_id - The table.
165
+ * @param column - Column of the cell, from 0.
166
+ * @param row - Row of the cell, from 0.
167
+ * @param args - The other arguments by name: `text`, `width`, `height`, `text_color`, `text_halign`, `text_valign`,
168
+ * `text_size`, `bgcolor`, `tooltip`, `text_font_family`, `text_formatting`.
169
+ * @returns Nothing.
170
+ * @example
171
+ * ```js
172
+ * const t = table.new(position.top_right, 1, 1);
173
+ * table.cell(t, 0, 0, { text: "Trend", bgcolor: color.teal, text_color: color.white });
174
+ * ```
175
+ */
176
+ cell(table_id: Table, column: Numeric, row: Numeric, args: TableCellArgs): void;
177
+ /**
178
+ * Writes a cell, with its text by position and the arguments after it by name (see the first form).
179
+ * @param table_id - The table.
180
+ * @param column - Column of the cell, from 0.
181
+ * @param row - Row of the cell, from 0.
182
+ * @param text - Text of the cell; `\n` starts a new line.
183
+ * @param args - The other arguments by name: `width`, `height`, `text_color`, `text_halign`, `text_valign`,
184
+ * `text_size`, `bgcolor`, `tooltip`, `text_font_family`, `text_formatting`.
185
+ * @returns Nothing.
186
+ * @example
187
+ * ```js
188
+ * const t = table.new(position.top_right, 1, 1);
189
+ * table.cell(t, 0, 0, "Trend", { text_size: size.small, tooltip: "50-bar trend" });
190
+ * ```
191
+ */
192
+ cell(table_id: Table, column: Numeric, row: Numeric, text: string, args: TableCellArgs): void;
193
+ /**
194
+ * Writes a cell, with every argument given by name (see the first form).
195
+ * @param args - `table_id`, `column`, `row`, and optionally `text`, `width`, `height`, `text_color`,
196
+ * `text_halign`, `text_valign`, `text_size`, `bgcolor`, `tooltip`, `text_font_family`, `text_formatting`.
197
+ * @returns Nothing.
198
+ * @example
199
+ * ```js
200
+ * const t = table.new(position.top_right, 1, 1);
201
+ * table.cell({ table_id: t, column: 0, row: 0, text: "Trend" });
202
+ * ```
203
+ */
204
+ cell(args: TableCellArgs): void;
205
+
206
+ /**
207
+ * Changes the text of a cell and keeps its other properties. A cell that was not written yet is created.
208
+ * @param table_id - The table.
209
+ * @param column - Column of the cell, from 0.
210
+ * @param row - Row of the cell, from 0.
211
+ * @param value - New text; `\n` starts a new line.
212
+ * @returns Nothing.
213
+ * @example
214
+ * ```js
215
+ * const t = table.new(position.top_right, 1, 1);
216
+ * eachBar((c) => {
217
+ * if (c.i === c.n - 1) table.cell_set_text(t, 0, 0, "Close " + str.tostring(c.close, "#.##"));
218
+ * });
219
+ * ```
220
+ */
221
+ cell_set_text(table_id: Table, column: Numeric, row: Numeric, value: string): void;
222
+ /**
223
+ * Changes the width of a cell. A cell that was not written yet is created.
224
+ * @param table_id - The table.
225
+ * @param column - Column of the cell, from 0.
226
+ * @param row - Row of the cell, from 0.
227
+ * @param value - Width in percent of the pane's width; 0 fits the text.
228
+ * @returns Nothing.
229
+ * @example
230
+ * ```js
231
+ * const t = table.new(position.top_right, 1, 1);
232
+ * table.cell(t, 0, 0, "Trend");
233
+ * table.cell_set_width(t, 0, 0, 10);
234
+ * ```
235
+ */
236
+ cell_set_width(table_id: Table, column: Numeric, row: Numeric, value: Numeric): void;
237
+ /**
238
+ * Changes the height of a cell. A cell that was not written yet is created.
239
+ * @param table_id - The table.
240
+ * @param column - Column of the cell, from 0.
241
+ * @param row - Row of the cell, from 0.
242
+ * @param value - Height in percent of the pane's height; 0 fits the text.
243
+ * @returns Nothing.
244
+ * @example
245
+ * ```js
246
+ * const t = table.new(position.top_right, 1, 1);
247
+ * table.cell(t, 0, 0, "Trend");
248
+ * table.cell_set_height(t, 0, 0, 5);
249
+ * ```
250
+ */
251
+ cell_set_height(table_id: Table, column: Numeric, row: Numeric, value: Numeric): void;
252
+ /**
253
+ * Changes the text colour of a cell. A cell that was not written yet is created.
254
+ * @param table_id - The table.
255
+ * @param column - Column of the cell, from 0.
256
+ * @param row - Row of the cell, from 0.
257
+ * @param value - New text colour.
258
+ * @returns Nothing.
259
+ * @example
260
+ * ```js
261
+ * const t = table.new(position.top_right, 1, 1);
262
+ * eachBar((c) => {
263
+ * if (c.i === c.n - 1) table.cell_set_text_color(t, 0, 0, c.close > c.open ? color.green : color.red);
264
+ * });
265
+ * ```
266
+ */
267
+ cell_set_text_color(table_id: Table, column: Numeric, row: Numeric, value: Colour): void;
268
+ /**
269
+ * Changes the horizontal alignment of the text of a cell. A cell that was not written yet is created.
270
+ * @param table_id - The table.
271
+ * @param column - Column of the cell, from 0.
272
+ * @param row - Row of the cell, from 0.
273
+ * @param value - `text.align_left`, `text.align_center` or `text.align_right`.
274
+ * @returns Nothing.
275
+ * @example
276
+ * ```js
277
+ * const t = table.new(position.top_right, 1, 1);
278
+ * table.cell(t, 0, 0, "Volume", { width: 15 });
279
+ * table.cell_set_text_halign(t, 0, 0, text.align_left);
280
+ * ```
281
+ */
282
+ cell_set_text_halign(table_id: Table, column: Numeric, row: Numeric, value: HAlign): void;
283
+ /**
284
+ * Changes the vertical alignment of the text of a cell. A cell that was not written yet is created.
285
+ * @param table_id - The table.
286
+ * @param column - Column of the cell, from 0.
287
+ * @param row - Row of the cell, from 0.
288
+ * @param value - `text.align_top`, `text.align_center` or `text.align_bottom`.
289
+ * @returns Nothing.
290
+ * @example
291
+ * ```js
292
+ * const t = table.new(position.top_right, 1, 1);
293
+ * table.cell(t, 0, 0, "Volume", { height: 8 });
294
+ * table.cell_set_text_valign(t, 0, 0, text.align_bottom);
295
+ * ```
296
+ */
297
+ cell_set_text_valign(table_id: Table, column: Numeric, row: Numeric, value: VAlign): void;
298
+ /**
299
+ * Changes the text size of a cell. A cell that was not written yet is created.
300
+ * @param table_id - The table.
301
+ * @param column - Column of the cell, from 0.
302
+ * @param row - Row of the cell, from 0.
303
+ * @param value - `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`, `size.auto`, or a size in
304
+ * points.
305
+ * @returns Nothing.
306
+ * @example
307
+ * ```js
308
+ * const t = table.new(position.top_right, 1, 1);
309
+ * table.cell(t, 0, 0, "Signal");
310
+ * table.cell_set_text_size(t, 0, 0, size.large);
311
+ * ```
312
+ */
313
+ cell_set_text_size(table_id: Table, column: Numeric, row: Numeric, value: string | number): void;
314
+ /**
315
+ * Changes the background colour of a cell. A cell that was not written yet is created.
316
+ * @param table_id - The table.
317
+ * @param column - Column of the cell, from 0.
318
+ * @param row - Row of the cell, from 0.
319
+ * @param value - New background colour.
320
+ * @returns Nothing.
321
+ * @example
322
+ * ```js
323
+ * const t = table.new(position.top_right, 1, 1);
324
+ * eachBar((c) => {
325
+ * if (c.i === c.n - 1) table.cell_set_bgcolor(t, 0, 0, c.close > c.open ? color.teal : color.maroon);
326
+ * });
327
+ * ```
328
+ */
329
+ cell_set_bgcolor(table_id: Table, column: Numeric, row: Numeric, value: Colour): void;
330
+ /**
331
+ * Changes the tooltip of a cell: the text shown when the pointer is over it. A cell that was not written yet is
332
+ * created.
333
+ * @param table_id - The table.
334
+ * @param column - Column of the cell, from 0.
335
+ * @param row - Row of the cell, from 0.
336
+ * @param value - Tooltip text.
337
+ * @returns Nothing.
338
+ * @example
339
+ * ```js
340
+ * const t = table.new(position.top_right, 1, 1);
341
+ * table.cell(t, 0, 0, "ATR");
342
+ * table.cell_set_tooltip(t, 0, 0, "Average true range over 14 bars");
343
+ * ```
344
+ */
345
+ cell_set_tooltip(table_id: Table, column: Numeric, row: Numeric, value: string): void;
346
+ /**
347
+ * Changes the font of a cell's text. A cell that was not written yet is created.
348
+ * @param table_id - The table.
349
+ * @param column - Column of the cell, from 0.
350
+ * @param row - Row of the cell, from 0.
351
+ * @param value - `font.family_default` or `font.family_monospace`.
352
+ * @returns Nothing.
353
+ * @example
354
+ * ```js
355
+ * const t = table.new(position.top_right, 1, 1);
356
+ * table.cell(t, 0, 0, "123.45");
357
+ * table.cell_set_text_font_family(t, 0, 0, font.family_monospace);
358
+ * ```
359
+ */
360
+ cell_set_text_font_family(
361
+ table_id: Table,
362
+ column: Numeric,
363
+ row: Numeric,
364
+ value: FontFamily
365
+ ): void;
366
+ /**
367
+ * Makes a cell's text bold, italic, both or plain. A cell that was not written yet is created.
368
+ * @param table_id - The table.
369
+ * @param column - Column of the cell, from 0.
370
+ * @param row - Row of the cell, from 0.
371
+ * @param value - `text.format_bold`, `text.format_italic`, their sum, or `text.format_none`.
372
+ * @returns Nothing.
373
+ * @example
374
+ * ```js
375
+ * const t = table.new(position.top_right, 1, 1);
376
+ * table.cell(t, 0, 0, "Summary");
377
+ * table.cell_set_text_formatting(t, 0, 0, text.format_bold + text.format_italic);
378
+ * ```
379
+ */
380
+ cell_set_text_formatting(table_id: Table, column: Numeric, row: Numeric, value: number): void;
381
+
382
+ /**
383
+ * Joins a block of cells into one cell, for a title over several columns for example. The merged cell shows the
384
+ * content and look of its start (top-left) cell. Merging the same block again does nothing. A cell outside the
385
+ * table, or an end before the start, is an error.
386
+ * @param table_id - The table.
387
+ * @param start_column - Column of the top-left cell of the block, from 0.
388
+ * @param start_row - Row of the top-left cell of the block, from 0.
389
+ * @param end_column - Column of the bottom-right cell of the block (not before `start_column`).
390
+ * @param end_row - Row of the bottom-right cell of the block (not before `start_row`).
391
+ * @returns Nothing.
392
+ * @example
393
+ * ```js
394
+ * const t = table.new(position.top_right, 2, 2);
395
+ * table.cell(t, 0, 0, "Daily stats");
396
+ * table.merge_cells(t, 0, 0, 1, 0); // the title spans both columns
397
+ * ```
398
+ */
399
+ merge_cells(
400
+ table_id: Table,
401
+ start_column: Numeric,
402
+ start_row: Numeric,
403
+ end_column: Numeric,
404
+ end_row: Numeric
405
+ ): void;
406
+ /**
407
+ * Empties a block of cells (text and look), and removes the merges that start inside it. Without an end, only the
408
+ * start cell is cleared. A cell outside the table is an error.
409
+ * @param table_id - The table.
410
+ * @param start_column - Column of the top-left cell of the block, from 0.
411
+ * @param start_row - Row of the top-left cell of the block, from 0.
412
+ * @param end_column - Column of the bottom-right cell of the block. Default: `start_column`.
413
+ * @param end_row - Row of the bottom-right cell of the block. Default: `start_row`.
414
+ * @returns Nothing.
415
+ * @example
416
+ * ```js
417
+ * const t = table.new(position.top_right, 3, 3);
418
+ * eachBar((c) => {
419
+ * if (c.i === c.n - 1) table.clear(t, 0, 0, 2, 2); // empty all nine cells
420
+ * });
421
+ * ```
422
+ */
423
+ clear(
424
+ table_id: Table,
425
+ start_column: Numeric,
426
+ start_row: Numeric,
427
+ end_column?: Numeric,
428
+ end_row?: Numeric
429
+ ): void;
430
+
431
+ /**
432
+ * Moves the table to another place of the pane. A live table already at that position (with the same
433
+ * `force_overlay`) is deleted. Does nothing on a deleted table.
434
+ * @param table_id - The table.
435
+ * @param position - New place: `position.top_left`, `position.top_center`, `position.top_right`,
436
+ * `position.middle_left`, `position.middle_center`, `position.middle_right`, `position.bottom_left`,
437
+ * `position.bottom_center` or `position.bottom_right`.
438
+ * @returns Nothing.
439
+ * @example
440
+ * ```js
441
+ * const where = input.string("Top right", "Table", { options: ["Top right", "Bottom left"] });
442
+ * const t = table.new(position.top_right, 1, 1);
443
+ * if (where === "Bottom left") table.set_position(t, position.bottom_left);
444
+ * ```
445
+ */
446
+ set_position(table_id: Table, position: TablePosition): void;
447
+ /**
448
+ * Changes the background colour of the whole table (cells with their own background keep it). Does nothing on a
449
+ * deleted table.
450
+ * @param table_id - The table.
451
+ * @param value - New background colour.
452
+ * @returns Nothing.
453
+ * @example
454
+ * ```js
455
+ * const t = table.new(position.top_right, 1, 1);
456
+ * eachBar((c) => {
457
+ * if (c.i === c.n - 1) table.set_bgcolor(t, c.close > c.open ? color.new(color.green, 80) : color.new(color.red, 80));
458
+ * });
459
+ * ```
460
+ */
461
+ set_bgcolor(table_id: Table, value: Colour): void;
462
+ /**
463
+ * Changes the colour of the outer frame of the table. Does nothing on a deleted table.
464
+ * @param table_id - The table.
465
+ * @param value - New frame colour.
466
+ * @returns Nothing.
467
+ * @example
468
+ * ```js
469
+ * const t = table.new(position.top_right, 1, 1, { frame_width: 1 });
470
+ * table.set_frame_color(t, color.gray);
471
+ * ```
472
+ */
473
+ set_frame_color(table_id: Table, value: Colour): void;
474
+ /**
475
+ * Changes the width of the outer frame of the table. Does nothing on a deleted table.
476
+ * @param table_id - The table.
477
+ * @param value - New frame width in pixels; 0 hides the frame.
478
+ * @returns Nothing.
479
+ * @example
480
+ * ```js
481
+ * const t = table.new(position.top_right, 1, 1, { frame_color: color.gray });
482
+ * table.set_frame_width(t, 2);
483
+ * ```
484
+ */
485
+ set_frame_width(table_id: Table, value: Numeric): void;
486
+ /**
487
+ * Changes the colour of the lines between the cells. Does nothing on a deleted table.
488
+ * @param table_id - The table.
489
+ * @param value - New border colour.
490
+ * @returns Nothing.
491
+ * @example
492
+ * ```js
493
+ * const t = table.new(position.top_right, 2, 2, { border_width: 1 });
494
+ * table.set_border_color(t, color.silver);
495
+ * ```
496
+ */
497
+ set_border_color(table_id: Table, value: Colour): void;
498
+ /**
499
+ * Changes the width of the lines between the cells. Does nothing on a deleted table.
500
+ * @param table_id - The table.
501
+ * @param value - New border width in pixels; 0 hides the lines.
502
+ * @returns Nothing.
503
+ * @example
504
+ * ```js
505
+ * const t = table.new(position.top_right, 2, 2, { border_color: color.silver });
506
+ * table.set_border_width(t, 1);
507
+ * ```
508
+ */
509
+ set_border_width(table_id: Table, value: Numeric): void;
510
+
511
+ /**
512
+ * Removes the table from the pane and from `table.all`. Afterwards the table functions do nothing on it; deleting
513
+ * it again does nothing.
514
+ * @param table_id - The table to delete.
515
+ * @returns Nothing.
516
+ * @example
517
+ * ```js
518
+ * const show = input.bool(true, "Show table");
519
+ * const t = table.new(position.top_right, 1, 1);
520
+ * if (!show) table.delete(t);
521
+ * ```
522
+ */
523
+ delete(table_id: Table): void;
524
+ /**
525
+ * Removes the table from the pane and from `table.all` (the same as `table.delete()`).
526
+ * @param table_id - The table to delete.
527
+ * @returns Nothing.
528
+ * @example
529
+ * ```js
530
+ * const t = table.new(position.top_right, 1, 1);
531
+ * table.delete_table(t);
532
+ * ```
533
+ */
534
+ delete_table(table_id: Table): void;
535
+
536
+ /** The tables still on the pane, oldest first (a new array on each read). */
537
+ readonly all: Table[];
538
+ }