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
@@ -0,0 +1,944 @@
1
+ /**
2
+ * @fileoverview The documented types of the chart and symbol context namespaces of the script API: `timeframe`,
3
+ * `syminfo`, `barstate`, `session`, `barmerge`, `ticker`, `dividends`, `splits`, `earnings`, `request` and `chart`.
4
+ * @module script/api/context
5
+ */
6
+
7
+ import type { Series } from '../../runtime/series.js';
8
+ import type { ChartPoint } from '../../types/index.js';
9
+ import type { TimeframeInfo } from '../../timeframe/index.js';
10
+ import type {
11
+ EventRequestArgs,
12
+ SecurityArgs,
13
+ SecurityLowerTfArgs,
14
+ SecurityValue,
15
+ SeedArgs,
16
+ } from '../index.js';
17
+
18
+ // ── timeframe ────────────────────────────────────────────────────────────────
19
+
20
+ /**
21
+ * The timeframe of the chart and timeframe string helpers.
22
+ *
23
+ * A timeframe string is a multiplier and a unit letter: no letter for minutes (`"1"`, `"15"`, `"60"`, `"240"`), `"S"`
24
+ * seconds, `"D"` days, `"W"` weeks, `"M"` months, `"T"` ticks. Without a multiplier 1 is used (`"D"` is `"1D"`).
25
+ * The chart values come from the app; inside a `request.security` expression they describe the requested timeframe.
26
+ */
27
+ export interface TimeframeNamespace {
28
+ /**
29
+ * Number of seconds in a timeframe. A month counts 2,628,003 seconds (365 / 12 days); a tick timeframe gives
30
+ * `NaN`. Without an argument, or with `""`, the chart timeframe.
31
+ * @param tf - Timeframe string, e.g. `"60"`, `"1D"`, `"W"`, `"30S"`. Default: the chart timeframe.
32
+ * @returns The number of seconds. Throws for a string that is not a timeframe (`"1H"`).
33
+ * @example
34
+ * ```js
35
+ * const barMinutes = timeframe.in_seconds() / 60;
36
+ * const dayLength = Math.max(1, Math.round(1440 / barMinutes));
37
+ * plot(ta.sma(close, dayLength), "One-day average");
38
+ * ```
39
+ */
40
+ in_seconds(tf?: string): number;
41
+
42
+ /**
43
+ * The timeframe string of a number of seconds. When no timeframe lasts exactly that long, the next longer one is
44
+ * returned (`45` gives `"1"`); when several do, the larger unit wins (`604800` gives `"1W"`). From 365 days the
45
+ * result is `"12M"`.
46
+ * @param seconds - Duration in seconds.
47
+ * @returns A timeframe string such as `"60"`, `"1D"` or `"1W"`.
48
+ * @example
49
+ * ```js
50
+ * const higher = timeframe.from_seconds(timeframe.in_seconds() * 4);
51
+ * const higherClose = request.security("", higher, () => close);
52
+ * plot(higherClose, "Close x4");
53
+ * ```
54
+ */
55
+ from_seconds(seconds: number): string;
56
+
57
+ /**
58
+ * Describes any timeframe string with the same fields as the chart values (`period`, `multiplier`, `isintraday`,
59
+ * `isdaily`...). Use it to test a timeframe chosen in the inputs.
60
+ * @param timeframe - Timeframe string, e.g. `"5"`, `"60"`, `"D"`, `"1W"`, `"30S"`.
61
+ * @returns An object with `period` (always with its multiplier: `"D"` becomes `"1D"`), `multiplier` and the
62
+ * `is*` flags. Throws for a string that is not a timeframe.
63
+ * @example
64
+ * ```js
65
+ * const tf = input.timeframe("D", "Higher timeframe");
66
+ * const isDayOrMore = timeframe.info(tf).isdwm;
67
+ * plot(request.security("", tf, () => close), isDayOrMore ? "Daily+ close" : "Intraday close");
68
+ * ```
69
+ */
70
+ info(timeframe: string): TimeframeInfo;
71
+
72
+ /**
73
+ * Chart timeframe with its multiplier: `"1"`, `"60"`, `"1D"`, `"1W"`, `"30S"`. Throws when the app did not
74
+ * give it.
75
+ */
76
+ readonly period: string;
77
+
78
+ /**
79
+ * Timeframe of the chart the script runs on, e.g. `"60"` or `"1D"`, also inside a `request.security` expression
80
+ * (where `timeframe.period` is the requested timeframe).
81
+ */
82
+ readonly main_period: string;
83
+
84
+ /** Number before the unit of the chart timeframe: 60 for `"60"`, 1 for `"1D"`, 4 for `"4W"`. */
85
+ readonly multiplier: number;
86
+
87
+ /** True on a minutes, seconds or ticks chart. */
88
+ readonly isintraday: boolean;
89
+
90
+ /** True on a chart of days (`"1D"`, `"2D"`...). */
91
+ readonly isdaily: boolean;
92
+
93
+ /** True on a chart of weeks. */
94
+ readonly isweekly: boolean;
95
+
96
+ /** True on a chart of months. */
97
+ readonly ismonthly: boolean;
98
+
99
+ /** True on a chart of minutes (and hours: `"60"`, `"240"`). */
100
+ readonly isminutes: boolean;
101
+
102
+ /** True on a chart of seconds. */
103
+ readonly isseconds: boolean;
104
+
105
+ /** True on a chart of ticks. */
106
+ readonly isticks: boolean;
107
+
108
+ /** True on a chart of days, weeks or months. */
109
+ readonly isdwm: boolean;
110
+
111
+ /**
112
+ * Marks the bars that open a new period of another timeframe, e.g. the first bar of each day on an intraday
113
+ * chart. The first bar of the chart is 0. Follows the session and the holidays of the symbol.
114
+ * @param tf - Timeframe of the periods, e.g. `"D"`, `"W"`, `"240"`; `""` is the chart timeframe.
115
+ * @returns Series of 1 on the first bar of each new period and 0 elsewhere.
116
+ * @example
117
+ * ```js
118
+ * const newDay = timeframe.change("D");
119
+ * plotshape(newDay, "New day", { location: location.bottom, color: color.blue });
120
+ * ```
121
+ */
122
+ change(tf: string): Series;
123
+ }
124
+
125
+ // ── syminfo ──────────────────────────────────────────────────────────────────
126
+
127
+ /**
128
+ * Properties of the chart symbol: ticker, exchange, price step, currency, company and analysts' figures. Inside a
129
+ * `request.security` expression they describe the requested symbol (`main_tickerid` stays the chart's).
130
+ *
131
+ * A field the symbol does not have is na: `""` for a text (test it with `na(...)`), `NaN` for a number. A field the
132
+ * app does not know stops the script with an error.
133
+ */
134
+ export interface SyminfoNamespace {
135
+ /** Smallest price step of the symbol, e.g. 0.01. Equals `minmove / pricescale`. */
136
+ readonly mintick: number;
137
+
138
+ /** Number of price-scale units in one price step: `mintick = minmove / pricescale` (1 for most symbols). */
139
+ readonly minmove: number;
140
+
141
+ /** Price scale of the symbol: 100 for prices with 2 decimals, 32 for prices in 1/32. */
142
+ readonly pricescale: number;
143
+
144
+ /** Money value of a one-point price move for one contract (1 for stocks). */
145
+ readonly pointvalue: number;
146
+
147
+ /** Smallest quantity that can be traded (1 for whole shares). */
148
+ readonly mincontract: number;
149
+
150
+ /** Time zone of the exchange, e.g. `"America/New_York"`. The default time zone of the date and time functions. */
151
+ readonly timezone: string;
152
+
153
+ /**
154
+ * Full symbol id with its exchange prefix, e.g. `"NASDAQ:AAPL"`. Pass it to `request.security` for the chart
155
+ * symbol.
156
+ */
157
+ readonly tickerid: string;
158
+
159
+ /** Symbol id of the chart itself, also inside a `request.security` expression on another symbol. */
160
+ readonly main_tickerid: string;
161
+
162
+ /** Symbol name without the exchange prefix, e.g. `"AAPL"`. */
163
+ readonly ticker: string;
164
+
165
+ /** Exchange prefix of the symbol id, e.g. `"NASDAQ"`; `""` without one. */
166
+ readonly prefix: string;
167
+
168
+ /** Session type of the bars: `"regular"` (regular hours) or `"extended"` (with pre and post market). */
169
+ readonly session: string;
170
+
171
+ /** Type of the symbol: `"stock"`, `"fund"`, `"index"`, `"futures"`, `"forex"`, `"crypto"`... */
172
+ readonly type: string;
173
+
174
+ /** Currency the prices are in, e.g. `"USD"`. */
175
+ readonly currency: string;
176
+
177
+ /** Base currency of a pair: `"BTC"` for a BTC/USD symbol, `"EUR"` for EUR/USD; `""` for a stock or an index. */
178
+ readonly basecurrency: string;
179
+
180
+ /** Root of the symbol: `"ES"` for a continuous future `"ES1!"` or a contract `"ESZ2026"`; the ticker otherwise. */
181
+ readonly root: string;
182
+
183
+ /** Full name of the symbol, e.g. `"Apple Inc."`. */
184
+ readonly description: string;
185
+
186
+ /** Two-letter code of the country the symbol trades in, e.g. `"US"`. */
187
+ readonly country: string;
188
+
189
+ /** Contract a continuous future stands for, e.g. `"ESZ2026"`; `""` for other symbols. */
190
+ readonly current_contract: string;
191
+
192
+ /** Last trading day of a futures contract (UNIX time in ms); na for other symbols. */
193
+ readonly expiration_date: number;
194
+
195
+ /** Sector of the company, e.g. `"Electronic Technology"`; `""` when it has none. */
196
+ readonly sector: string;
197
+
198
+ /** Industry of the company; `""` when it has none. */
199
+ readonly industry: string;
200
+
201
+ /** International Securities Identification Number of the symbol, e.g. `"US0378331005"`. */
202
+ readonly isin: string;
203
+
204
+ /** Unit of the volume: `"base"` (units of the base currency), `"quote"`, `"tick"` or `"n/a"`. */
205
+ readonly volumetype: string;
206
+
207
+ /** Number of employees of the company. */
208
+ readonly employees: number;
209
+
210
+ /** Number of shareholders of the company. */
211
+ readonly shareholders: number;
212
+
213
+ /** Total number of shares the company has issued. */
214
+ readonly shares_outstanding_total: number;
215
+
216
+ /** Number of shares free to trade (without the shares held by insiders and large holders). */
217
+ readonly shares_outstanding_float: number;
218
+
219
+ /** Number of analysts who rate the symbol "buy". */
220
+ readonly recommendations_buy: number;
221
+
222
+ /** Number of analysts who rate the symbol "strong buy". */
223
+ readonly recommendations_buy_strong: number;
224
+
225
+ /** Number of analysts who rate the symbol "hold". */
226
+ readonly recommendations_hold: number;
227
+
228
+ /** Number of analysts who rate the symbol "sell". */
229
+ readonly recommendations_sell: number;
230
+
231
+ /** Number of analysts who rate the symbol "strong sell". */
232
+ readonly recommendations_sell_strong: number;
233
+
234
+ /** Total number of analysts' ratings. */
235
+ readonly recommendations_total: number;
236
+
237
+ /** Date of the analysts' ratings (UNIX time in ms). */
238
+ readonly recommendations_date: number;
239
+
240
+ /** Average of the analysts' price targets. */
241
+ readonly target_price_average: number;
242
+
243
+ /** Highest analyst price target. */
244
+ readonly target_price_high: number;
245
+
246
+ /** Lowest analyst price target. */
247
+ readonly target_price_low: number;
248
+
249
+ /** Median of the analysts' price targets. */
250
+ readonly target_price_median: number;
251
+
252
+ /** Number of analysts' price targets. */
253
+ readonly target_price_estimates: number;
254
+
255
+ /** Date of the analysts' price targets (UNIX time in ms). */
256
+ readonly target_price_date: number;
257
+ }
258
+
259
+ // ── barstate ─────────────────────────────────────────────────────────────────
260
+
261
+ /**
262
+ * Where each bar stands in the data: first, last, closed, history or live. Each value is a Series of 1 (true) and
263
+ * 0 (false), one value per bar: pass it to a plot as a condition, or read it in a bar loop with
264
+ * `c.get(barstate.islast) === 1`.
265
+ */
266
+ export interface BarstateNamespace {
267
+ /** 1 on the first bar of the data. */
268
+ readonly isfirst: Series;
269
+
270
+ /** 1 on the last bar of the chart. */
271
+ readonly islast: Series;
272
+
273
+ /** 1 on closed bars: every bar but the last, and the last bar once the app says it has closed. */
274
+ readonly isconfirmed: Series;
275
+
276
+ /** 1 on the last bar when it receives live updates. */
277
+ readonly isrealtime: Series;
278
+
279
+ /** 1 on every bar but a live last bar. */
280
+ readonly ishistory: Series;
281
+
282
+ /** 1 on every history bar, and on a live last bar at its first update. */
283
+ readonly isnew: Series;
284
+
285
+ /** 1 on the last closed history bar: the last bar when it is closed and not live, else the bar before it. */
286
+ readonly islastconfirmedhistory: Series;
287
+ }
288
+
289
+ // ── session ──────────────────────────────────────────────────────────────────
290
+
291
+ /**
292
+ * Trading session values: where each bar sits in the trading hours of the symbol, and the session types. The flags
293
+ * are Series of 1 (true) and 0 (false). Market, pre market and post market follow the regular hours; on a daily,
294
+ * weekly or monthly chart every bar is a first, last and market bar.
295
+ */
296
+ export interface SessionNamespace {
297
+ /** Session type of regular trading hours (compare with `syminfo.session`). */
298
+ readonly regular: 'regular';
299
+
300
+ /** Session type with the pre and post market hours (compare with `syminfo.session`). */
301
+ readonly extended: 'extended';
302
+
303
+ /** 1 on the first bar of each session period (including pre market when the bars have it). */
304
+ readonly isfirstbar: Series;
305
+
306
+ /** 1 on the last bar of each session period. */
307
+ readonly islastbar: Series;
308
+
309
+ /** 1 on bars inside the regular trading hours. */
310
+ readonly ismarket: Series;
311
+
312
+ /** 1 on bars before the regular hours open (pre market). */
313
+ readonly ispremarket: Series;
314
+
315
+ /** 1 on bars after the regular hours close (post market). */
316
+ readonly ispostmarket: Series;
317
+
318
+ /** 1 on the first bar of the regular trading hours of each day. */
319
+ readonly isfirstbar_regular: Series;
320
+
321
+ /** 1 on the last bar of the regular trading hours of each day. */
322
+ readonly islastbar_regular: Series;
323
+ }
324
+
325
+ // ── barmerge ─────────────────────────────────────────────────────────────────
326
+
327
+ /** How `request.security` and the event requests place their values on the chart bars. */
328
+ export interface BarmergeNamespace {
329
+ /** A value shows only on the bar where it appears; the bars between are na. */
330
+ readonly gaps_on: 'gaps_on';
331
+
332
+ /** A value stays on every bar until the next one (the default). */
333
+ readonly gaps_off: 'gaps_off';
334
+
335
+ /**
336
+ * A period's value shows from the first chart bar of that period. On history it reads values that were not known
337
+ * yet: use it with values of the previous period (`high.offset(1)`).
338
+ */
339
+ readonly lookahead_on: 'lookahead_on';
340
+
341
+ /** A period's value shows from the chart bar that completes the period (the default, no future values). */
342
+ readonly lookahead_off: 'lookahead_off';
343
+ }
344
+
345
+ // ── ticker ───────────────────────────────────────────────────────────────────
346
+
347
+ /** Symbol ids for `request.security`: Heikin Ashi bars of a symbol, and back to its standard bars. */
348
+ export interface TickerNamespace {
349
+ /**
350
+ * The symbol id of the Heikin Ashi bars of a symbol: `request.security` on it computes the expression on Heikin
351
+ * Ashi candles.
352
+ * @param symbol - Symbol id, e.g. `syminfo.tickerid`.
353
+ * @returns The symbol id that selects Heikin Ashi bars.
354
+ * @example
355
+ * ```js
356
+ * const haClose = request.security(ticker.heikinashi(syminfo.tickerid), "", () => close);
357
+ * plot(haClose, "Heikin Ashi close");
358
+ * ```
359
+ */
360
+ heikinashi(symbol: string): string;
361
+
362
+ /**
363
+ * The symbol id of the standard bars of a symbol: removes the Heikin Ashi marking of `ticker.heikinashi`, and
364
+ * returns any other id unchanged.
365
+ * @param symbol - Symbol id, e.g. `syminfo.tickerid`.
366
+ * @returns The symbol id of the standard bars.
367
+ * @example
368
+ * ```js
369
+ * const realClose = request.security(ticker.standard(syminfo.tickerid), "", () => close);
370
+ * plot(realClose, "Close");
371
+ * ```
372
+ */
373
+ standard(symbol: string): string;
374
+ }
375
+
376
+ // ── dividends / splits / earnings ────────────────────────────────────────────
377
+
378
+ /** Fields of `request.dividends`, and the next announced dividend of the chart symbol. */
379
+ export interface DividendsNamespace {
380
+ /** The dividend after taxes (the default field of `request.dividends`). */
381
+ readonly net: 'net';
382
+
383
+ /** The dividend before taxes. */
384
+ readonly gross: 'gross';
385
+
386
+ /** Amount of the next announced dividend (net); na when none is announced. */
387
+ readonly future_amount: number;
388
+
389
+ /** Ex-date of the next announced dividend (UNIX time in ms); na when none is announced. */
390
+ readonly future_ex_date: number;
391
+
392
+ /** Payment date of the next announced dividend (UNIX time in ms); na when none is announced. */
393
+ readonly future_pay_date: number;
394
+ }
395
+
396
+ /** Fields of `request.splits`: the two numbers of a split ratio. */
397
+ export interface SplitsNamespace {
398
+ /** The number of shares after the split (2 for a 2-for-1 split). */
399
+ readonly numerator: 'numerator';
400
+
401
+ /** The number of shares before the split (1 for a 2-for-1 split). */
402
+ readonly denominator: 'denominator';
403
+ }
404
+
405
+ /** Fields of `request.earnings`, and the next announced earnings release of the chart symbol. */
406
+ export interface EarningsNamespace {
407
+ /** The reported earnings per share (the default field of `request.earnings`). */
408
+ readonly actual: 'actual';
409
+
410
+ /** The analysts' estimate of the earnings per share. */
411
+ readonly estimate: 'estimate';
412
+
413
+ /** The standardized earnings per share. */
414
+ readonly standardized: 'standardized';
415
+
416
+ /** Estimated earnings per share of the next release; na when none is announced. */
417
+ readonly future_eps: number;
418
+
419
+ /** Estimated revenue of the next release; na when none is announced. */
420
+ readonly future_revenue: number;
421
+
422
+ /** Time of the next release (UNIX time in ms); na when none is announced. */
423
+ readonly future_time: number;
424
+
425
+ /** End of the fiscal period of the next release (UNIX time in ms); na when none is announced. */
426
+ readonly future_period_end_time: number;
427
+ }
428
+
429
+ // ── request ──────────────────────────────────────────────────────────────────
430
+
431
+ /** Named arguments of `request.splits`: those of the other event requests, without `currency`. */
432
+ export type SplitsRequestArgs = Omit<EventRequestArgs, 'currency'>;
433
+
434
+ /**
435
+ * Data of other timeframes and other symbols: values computed on their bars, lower-timeframe values, seed series,
436
+ * dividends, splits and earnings. The arguments after the first ones can be given by position or by name in a last
437
+ * object (`{ lookahead: barmerge.lookahead_on }`); an unknown name stops the script with the closest names.
438
+ */
439
+ export interface RequestNamespace {
440
+ /**
441
+ * Computes `expression` on the bars of another timeframe or another symbol and places its values on the chart
442
+ * bars. Compute every Series the expression needs inside it: a Series computed outside runs on the chart bars and
443
+ * stops the script. Return an array to get several Series at once.
444
+ * @param symbol - Symbol id: `""` or `syminfo.tickerid` for the chart symbol, `"NASDAQ:AAPL"` for another one,
445
+ * `ticker.heikinashi(...)` for Heikin Ashi bars.
446
+ * @param timeframe - Timeframe string, e.g. `"D"`, `"W"`, `"60"`; `""` is the chart timeframe.
447
+ * @param expression - Function that returns a Series, a number, or an array of them, computed on those bars.
448
+ * @param gaps - `barmerge.gaps_off` keeps a value on every bar until the next one; `barmerge.gaps_on` shows it only
449
+ * where it appears. Default: `barmerge.gaps_off`.
450
+ * @param lookahead - `barmerge.lookahead_off` shows a period's value from the bar that completes it;
451
+ * `barmerge.lookahead_on` from its first bar. Default: `barmerge.lookahead_off`.
452
+ * @param ignore_invalid_symbol - True to get na for a symbol that does not exist instead of stopping the script.
453
+ * Default: false.
454
+ * @returns A Series on the chart bars, or one Series per element when the expression returns an array.
455
+ * @example
456
+ * ```js
457
+ * const dailyEma = request.security("", "D", () => ta.ema(close, 20));
458
+ * const [prevHigh, prevLow] = request.security("", "D", () => [high.offset(1), low.offset(1)]);
459
+ * plot(dailyEma, "Daily EMA");
460
+ * ```
461
+ */
462
+ security<T extends SecurityValue>(
463
+ symbol: string,
464
+ timeframe: string,
465
+ expression: () => T,
466
+ gaps?: string,
467
+ lookahead?: string,
468
+ ignore_invalid_symbol?: boolean
469
+ ): T extends unknown[] ? Series[] : Series;
470
+ /**
471
+ * Computes `expression` on the bars of another timeframe or symbol, with the other arguments by name.
472
+ * @param symbol - Symbol id; `""` is the chart symbol.
473
+ * @param timeframe - Timeframe string; `""` is the chart timeframe.
474
+ * @param expression - Function that returns a Series, a number, or an array of them.
475
+ * @param args - Named arguments: `gaps`, `lookahead`, `ignore_invalid_symbol`. `currency` (other than `""`) and
476
+ * `calc_bars_count` are not supported and stop the script.
477
+ * @returns A Series on the chart bars, or one Series per element when the expression returns an array.
478
+ * @example
479
+ * ```js
480
+ * const weekOpen = request.security("", "W", () => open, { lookahead: barmerge.lookahead_on });
481
+ * plot(weekOpen, "Week open", { style: plot.style_stepline });
482
+ * ```
483
+ */
484
+ security<T extends SecurityValue>(
485
+ symbol: string,
486
+ timeframe: string,
487
+ expression: () => T,
488
+ args: SecurityArgs<T>
489
+ ): T extends unknown[] ? Series[] : Series;
490
+ /**
491
+ * Computes `expression` on the bars of another timeframe or symbol, with every argument by name.
492
+ * @param args - Named arguments: `symbol`, `timeframe`, `expression` (required), `gaps`, `lookahead`,
493
+ * `ignore_invalid_symbol`.
494
+ * @returns A Series on the chart bars, or one Series per element when the expression returns an array.
495
+ * @example
496
+ * ```js
497
+ * const weekly = request.security({ symbol: "", timeframe: "W", expression: () => close });
498
+ * plot(weekly, "Weekly close");
499
+ * ```
500
+ */
501
+ security<T extends SecurityValue>(
502
+ args: SecurityArgs<T> & { symbol: string; timeframe: string; expression: () => T }
503
+ ): T extends unknown[] ? Series[] : Series;
504
+
505
+ /**
506
+ * Computes `expression` on the bars of a lower timeframe and gives, for each chart bar, the values of all the
507
+ * lower bars inside it. The result is a plain array per chart bar (oldest first), not a Series: read it in a bar
508
+ * loop with `values[c.i]`. A timeframe higher than the chart's stops the script.
509
+ * @param symbol - Symbol id; `""` or `syminfo.tickerid` is the chart symbol.
510
+ * @param timeframe - Lower timeframe string, e.g. `"1"`, `"15"`, `"1T"`.
511
+ * @param expression - Function that returns a Series, a number, or an array of them.
512
+ * @param ignore_invalid_symbol - True to get empty arrays for a symbol that does not exist instead of stopping the
513
+ * script. Default: false.
514
+ * @returns One array of numbers per chart bar (empty when no lower bar is inside it), or one such list per element
515
+ * when the expression returns an array.
516
+ * @example
517
+ * ```js
518
+ * const vols = request.security_lower_tf("", "15", () => volume);
519
+ * const maxVolume = eachBar((c) => Math.max(0, ...vols[c.i]));
520
+ * plot(maxVolume, "Largest 15m volume");
521
+ * ```
522
+ */
523
+ security_lower_tf<T extends SecurityValue>(
524
+ symbol: string,
525
+ timeframe: string,
526
+ expression: () => T,
527
+ ignore_invalid_symbol?: boolean
528
+ ): T extends unknown[] ? number[][][] : number[][];
529
+ /**
530
+ * Lower-timeframe values per chart bar, with the other arguments by name.
531
+ * @param symbol - Symbol id; `""` is the chart symbol.
532
+ * @param timeframe - Lower timeframe string.
533
+ * @param expression - Function that returns a Series, a number, or an array of them.
534
+ * @param args - Named arguments: `ignore_invalid_symbol`. `currency`, `ignore_invalid_timeframe` and
535
+ * `calc_bars_count` are not supported and stop the script.
536
+ * @returns One array of numbers per chart bar, or one such list per element of an array expression.
537
+ * @example
538
+ * ```js
539
+ * const closes = request.security_lower_tf("", "5", () => close, { ignore_invalid_symbol: true });
540
+ * const count = eachBar((c) => closes[c.i].length);
541
+ * plot(count, "5m bars");
542
+ * ```
543
+ */
544
+ security_lower_tf<T extends SecurityValue>(
545
+ symbol: string,
546
+ timeframe: string,
547
+ expression: () => T,
548
+ args: SecurityLowerTfArgs<T>
549
+ ): T extends unknown[] ? number[][][] : number[][];
550
+ /**
551
+ * Lower-timeframe values per chart bar, with every argument by name.
552
+ * @param args - Named arguments: `symbol`, `timeframe`, `expression` (required), `ignore_invalid_symbol`.
553
+ * @returns One array of numbers per chart bar, or one such list per element of an array expression.
554
+ * @example
555
+ * ```js
556
+ * const highs = request.security_lower_tf({ symbol: "", timeframe: "1", expression: () => high });
557
+ * const first = eachBar((c) => highs[c.i][0] ?? NaN);
558
+ * plot(first, "First minute high");
559
+ * ```
560
+ */
561
+ security_lower_tf<T extends SecurityValue>(
562
+ args: SecurityLowerTfArgs<T> & { symbol: string; timeframe: string; expression: () => T }
563
+ ): T extends unknown[] ? number[][][] : number[][];
564
+
565
+ /**
566
+ * Computes `expression` on a seed data series (data published as a separate series), on the chart timeframe. It
567
+ * is `request.security` on the symbol the app gives that series (by default `"<SOURCE>:<SYMBOL>"` upper-cased).
568
+ * @param source - Name of the seed data source.
569
+ * @param symbol - Name of the series in that source.
570
+ * @param expression - Function that returns a Series, a number, or an array of them.
571
+ * @param ignore_invalid_symbol - True to get na for a series that does not exist instead of stopping the script.
572
+ * Default: false.
573
+ * @returns A Series on the chart bars, or one Series per element when the expression returns an array.
574
+ * @example
575
+ * ```js
576
+ * const activity = request.seed("seed_crypto_santiment", "BTC_DEV_ACTIVITY", () => close);
577
+ * plot(activity, "Dev activity");
578
+ * ```
579
+ */
580
+ seed<T extends SecurityValue>(
581
+ source: string,
582
+ symbol: string,
583
+ expression: () => T,
584
+ ignore_invalid_symbol?: boolean
585
+ ): T extends unknown[] ? Series[] : Series;
586
+ /**
587
+ * A seed data series, with the other arguments by name.
588
+ * @param source - Name of the seed data source.
589
+ * @param symbol - Name of the series in that source.
590
+ * @param expression - Function that returns a Series, a number, or an array of them.
591
+ * @param args - Named arguments: `ignore_invalid_symbol`. `calc_bars_count` is not supported and stops the script.
592
+ * @returns A Series on the chart bars, or one Series per element when the expression returns an array.
593
+ * @example
594
+ * ```js
595
+ * const options = { ignore_invalid_symbol: true };
596
+ * const activity = request.seed("seed_crypto_santiment", "BTC_DEV_ACTIVITY", () => close, options);
597
+ * plot(activity, "Dev activity");
598
+ * ```
599
+ */
600
+ seed<T extends SecurityValue>(
601
+ source: string,
602
+ symbol: string,
603
+ expression: () => T,
604
+ args: SeedArgs<T>
605
+ ): T extends unknown[] ? Series[] : Series;
606
+ /**
607
+ * A seed data series, with every argument by name.
608
+ * @param args - Named arguments: `source`, `symbol`, `expression` (required), `ignore_invalid_symbol`.
609
+ * @returns A Series on the chart bars, or one Series per element when the expression returns an array.
610
+ * @example
611
+ * ```js
612
+ * const source = "seed_crypto_santiment";
613
+ * const activity = request.seed({ source, symbol: "BTC_DEV_ACTIVITY", expression: () => close });
614
+ * plot(activity, "Dev activity");
615
+ * ```
616
+ */
617
+ seed<T extends SecurityValue>(
618
+ args: SeedArgs<T> & { source: string; symbol: string; expression: () => T }
619
+ ): T extends unknown[] ? Series[] : Series;
620
+
621
+ /**
622
+ * The dividend per share of a symbol, as declared (not adjusted for later splits), on the chart bars. With the
623
+ * default lookahead off, a dividend shows from the first bar that closes after the end of its ex-date's period
624
+ * (the next day on a daily chart). na before the first dividend.
625
+ * @param ticker - Symbol id; `""` or `syminfo.tickerid` is the chart symbol.
626
+ * @param field - `dividends.net` or `dividends.gross`. Default: `dividends.net`.
627
+ * @param gaps - `barmerge.gaps_on` shows the value only on the bar where it appears. Default: `barmerge.gaps_off`.
628
+ * @param lookahead - `barmerge.lookahead_on` shows it from the first bar of its period. Default:
629
+ * `barmerge.lookahead_off`.
630
+ * @param ignore_invalid_symbol - True to get na for a symbol that does not exist. Default: false.
631
+ * @param currency - Currency conversion is not supported: leave it out (any value but `""` or `"NONE"` stops the
632
+ * script).
633
+ * @returns Series of the last dividend.
634
+ * @example
635
+ * ```js
636
+ * const dividend = request.dividends(syminfo.tickerid);
637
+ * plot(dividend.mul(4).div(close).mul(100), "Yield %");
638
+ * ```
639
+ */
640
+ dividends(
641
+ ticker: string,
642
+ field?: string,
643
+ gaps?: string,
644
+ lookahead?: string,
645
+ ignore_invalid_symbol?: boolean,
646
+ currency?: string
647
+ ): Series;
648
+ /**
649
+ * The dividend per share of a symbol, with the arguments after `field` by name.
650
+ * @param ticker - Symbol id; `""` is the chart symbol.
651
+ * @param field - `dividends.net` or `dividends.gross`.
652
+ * @param args - Named arguments: `gaps`, `lookahead`, `ignore_invalid_symbol`.
653
+ * @returns Series of the last dividend.
654
+ * @example
655
+ * ```js
656
+ * const gross = request.dividends("", dividends.gross, { gaps: barmerge.gaps_on });
657
+ * plot(gross, "Gross dividend", { style: plot.style_circles });
658
+ * ```
659
+ */
660
+ dividends(ticker: string, field: string, args: EventRequestArgs): Series;
661
+ /**
662
+ * The dividend per share of a symbol, with the arguments after `ticker` by name.
663
+ * @param ticker - Symbol id; `""` is the chart symbol.
664
+ * @param args - Named arguments: `field`, `gaps`, `lookahead`, `ignore_invalid_symbol`.
665
+ * @returns Series of the last dividend.
666
+ * @example
667
+ * ```js
668
+ * const dividend = request.dividends("", { field: dividends.net });
669
+ * plot(dividend, "Dividend");
670
+ * ```
671
+ */
672
+ dividends(ticker: string, args: EventRequestArgs): Series;
673
+ /**
674
+ * The dividend per share of a symbol, with every argument by name.
675
+ * @param args - Named arguments: `ticker` (required), `field`, `gaps`, `lookahead`, `ignore_invalid_symbol`.
676
+ * @returns Series of the last dividend.
677
+ * @example
678
+ * ```js
679
+ * const dividend = request.dividends({ ticker: syminfo.tickerid });
680
+ * plot(dividend, "Dividend");
681
+ * ```
682
+ */
683
+ dividends(args: EventRequestArgs & { ticker: string }): Series;
684
+
685
+ /**
686
+ * One number of the last split ratio of a symbol on the chart bars (2 and 1 for a 2-for-1 split). With the
687
+ * default lookahead off, a split shows from the first bar that closes after the end of its day's period. na
688
+ * before the first split.
689
+ * @param ticker - Symbol id; `""` or `syminfo.tickerid` is the chart symbol.
690
+ * @param field - `splits.numerator` or `splits.denominator` (required).
691
+ * @param gaps - `barmerge.gaps_on` shows the value only on the bar where it appears. Default: `barmerge.gaps_off`.
692
+ * @param lookahead - `barmerge.lookahead_on` shows it from the first bar of its period. Default:
693
+ * `barmerge.lookahead_off`.
694
+ * @param ignore_invalid_symbol - True to get na for a symbol that does not exist. Default: false.
695
+ * @returns Series of the numerator or the denominator of the last split.
696
+ * @example
697
+ * ```js
698
+ * const split = request.splits(syminfo.tickerid, splits.numerator, barmerge.gaps_on);
699
+ * plotshape(split.gt(0), "Split", { location: location.bottom });
700
+ * ```
701
+ */
702
+ splits(
703
+ ticker: string,
704
+ field: string,
705
+ gaps?: string,
706
+ lookahead?: string,
707
+ ignore_invalid_symbol?: boolean
708
+ ): Series;
709
+ /**
710
+ * One number of the last split ratio, with the arguments after `field` by name.
711
+ * @param ticker - Symbol id; `""` is the chart symbol.
712
+ * @param field - `splits.numerator` or `splits.denominator`.
713
+ * @param args - Named arguments: `gaps`, `lookahead`, `ignore_invalid_symbol`.
714
+ * @returns Series of the numerator or the denominator of the last split.
715
+ * @example
716
+ * ```js
717
+ * const ratio = request.splits("", splits.denominator, { lookahead: barmerge.lookahead_off });
718
+ * plot(ratio, "Split denominator");
719
+ * ```
720
+ */
721
+ splits(ticker: string, field: string, args: SplitsRequestArgs): Series;
722
+ /**
723
+ * One number of the last split ratio, with the arguments after `ticker` by name.
724
+ * @param ticker - Symbol id; `""` is the chart symbol.
725
+ * @param args - Named arguments: `field` (required), `gaps`, `lookahead`, `ignore_invalid_symbol`.
726
+ * @returns Series of the numerator or the denominator of the last split.
727
+ * @example
728
+ * ```js
729
+ * const ratio = request.splits("", { field: splits.numerator });
730
+ * plot(ratio, "Split numerator");
731
+ * ```
732
+ */
733
+ splits(ticker: string, args: SplitsRequestArgs): Series;
734
+ /**
735
+ * One number of the last split ratio, with every argument by name.
736
+ * @param args - Named arguments: `ticker` and `field` (required), `gaps`, `lookahead`, `ignore_invalid_symbol`.
737
+ * @returns Series of the numerator or the denominator of the last split.
738
+ * @example
739
+ * ```js
740
+ * const ratio = request.splits({ ticker: syminfo.tickerid, field: splits.numerator });
741
+ * plot(ratio, "Split numerator");
742
+ * ```
743
+ */
744
+ splits(args: SplitsRequestArgs & { ticker: string }): Series;
745
+
746
+ /**
747
+ * The earnings per share of the last release of a symbol (adjusted for later splits) on the chart bars. With the
748
+ * default lookahead off, a release shows from the first bar after the period of the chart timeframe it was
749
+ * published in (the next day on a daily chart). Releases still to come are left out; na before the first one.
750
+ * A field the app has no data for stops the script.
751
+ * @param ticker - Symbol id; `""` or `syminfo.tickerid` is the chart symbol.
752
+ * @param field - `earnings.actual`, `earnings.estimate` or `earnings.standardized`. Default: `earnings.actual`.
753
+ * @param gaps - `barmerge.gaps_on` shows the value only on the bar where it appears. Default: `barmerge.gaps_off`.
754
+ * @param lookahead - `barmerge.lookahead_on` shows it from the first bar of its period. Default:
755
+ * `barmerge.lookahead_off`.
756
+ * @param ignore_invalid_symbol - True to get na for a symbol that does not exist. Default: false.
757
+ * @param currency - Currency conversion is not supported: leave it out (any value but `""` or `"NONE"` stops the
758
+ * script).
759
+ * @returns Series of the last earnings per share.
760
+ * @example
761
+ * ```js
762
+ * const eps = request.earnings(syminfo.tickerid, earnings.actual);
763
+ * plot(eps, "EPS", { style: plot.style_stepline });
764
+ * ```
765
+ */
766
+ earnings(
767
+ ticker: string,
768
+ field?: string,
769
+ gaps?: string,
770
+ lookahead?: string,
771
+ ignore_invalid_symbol?: boolean,
772
+ currency?: string
773
+ ): Series;
774
+ /**
775
+ * The earnings per share of the last release, with the arguments after `field` by name.
776
+ * @param ticker - Symbol id; `""` is the chart symbol.
777
+ * @param field - `earnings.actual`, `earnings.estimate` or `earnings.standardized`.
778
+ * @param args - Named arguments: `gaps`, `lookahead`, `ignore_invalid_symbol`.
779
+ * @returns Series of the last earnings per share.
780
+ * @example
781
+ * ```js
782
+ * const estimate = request.earnings("", earnings.estimate, { gaps: barmerge.gaps_on });
783
+ * plot(estimate, "EPS estimate", { style: plot.style_circles });
784
+ * ```
785
+ */
786
+ earnings(ticker: string, field: string, args: EventRequestArgs): Series;
787
+ /**
788
+ * The earnings per share of the last release, with the arguments after `ticker` by name.
789
+ * @param ticker - Symbol id; `""` is the chart symbol.
790
+ * @param args - Named arguments: `field`, `gaps`, `lookahead`, `ignore_invalid_symbol`.
791
+ * @returns Series of the last earnings per share.
792
+ * @example
793
+ * ```js
794
+ * const eps = request.earnings("", { field: earnings.actual });
795
+ * plot(eps, "EPS");
796
+ * ```
797
+ */
798
+ earnings(ticker: string, args: EventRequestArgs): Series;
799
+ /**
800
+ * The earnings per share of the last release, with every argument by name.
801
+ * @param args - Named arguments: `ticker` (required), `field`, `gaps`, `lookahead`, `ignore_invalid_symbol`.
802
+ * @returns Series of the last earnings per share.
803
+ * @example
804
+ * ```js
805
+ * const eps = request.earnings({ ticker: syminfo.tickerid });
806
+ * plot(eps, "EPS");
807
+ * ```
808
+ */
809
+ earnings(args: EventRequestArgs & { ticker: string }): Series;
810
+ }
811
+
812
+ // ── chart ────────────────────────────────────────────────────────────────────
813
+
814
+ /** `chart.point.*`: points (time or bar index, and price) for drawings such as polylines. */
815
+ export interface ChartPointNamespace {
816
+ /**
817
+ * A point with every coordinate. Give the time or the bar index (the other one can be null), as the drawing's
818
+ * `xloc` expects.
819
+ * @param time - UNIX time in ms, or null.
820
+ * @param index - Bar index, or null.
821
+ * @param price - Price of the point.
822
+ * @returns The new point.
823
+ * @example
824
+ * ```js
825
+ * eachBar((c) => {
826
+ * if (c.i === c.n - 1) polyline.new([chart.point.new(null, c.i - 10, c.low), chart.point.new(null, c.i, c.high)]);
827
+ * });
828
+ * ```
829
+ */
830
+ 'new'(time: number | null, index: number | null, price: number): ChartPoint;
831
+
832
+ /**
833
+ * A point with every coordinate (the same as `chart.point.new`).
834
+ * @param time - UNIX time in ms, or null.
835
+ * @param index - Bar index, or null.
836
+ * @param price - Price of the point.
837
+ * @returns The new point.
838
+ * @example
839
+ * ```js
840
+ * const p = chart.point.new_point(null, 0, 100);
841
+ * ```
842
+ */
843
+ new_point(time: number | null, index: number | null, price: number): ChartPoint;
844
+
845
+ /**
846
+ * A point at a time and a price (its bar index is null), for drawings placed with `xloc.bar_time`.
847
+ * @param time - UNIX time in ms.
848
+ * @param price - Price of the point.
849
+ * @returns The new point.
850
+ * @example
851
+ * ```js
852
+ * eachBar((c) => {
853
+ * const points = [chart.point.from_time(c.time, c.low), chart.point.from_time(c.time, c.high)];
854
+ * if (c.i === c.n - 1) polyline.new(points, { xloc: xloc.bar_time });
855
+ * });
856
+ * ```
857
+ */
858
+ from_time(time: number, price: number): ChartPoint;
859
+
860
+ /**
861
+ * A point at a bar index and a price (its time is null), for drawings placed with `xloc.bar_index`.
862
+ * @param index - Bar index.
863
+ * @param price - Price of the point.
864
+ * @returns The new point.
865
+ * @example
866
+ * ```js
867
+ * eachBar((c) => {
868
+ * const points = [chart.point.from_index(c.i - 20, c.low), chart.point.from_index(c.i, c.high)];
869
+ * if (c.i === c.n - 1) polyline.new(points);
870
+ * });
871
+ * ```
872
+ */
873
+ from_index(index: number, price: number): ChartPoint;
874
+
875
+ /**
876
+ * A copy of a point.
877
+ * @param point - The point to copy.
878
+ * @returns A new point with the same time, index and price.
879
+ * @example
880
+ * ```js
881
+ * const a = chart.point.from_index(0, 100);
882
+ * const b = chart.point.copy(a);
883
+ * ```
884
+ */
885
+ copy(point: ChartPoint): ChartPoint;
886
+
887
+ /**
888
+ * The point of the current bar: its time, its bar index and a price. Call it inside a bar loop.
889
+ * @param price - Price of the point. Default: the close of the bar.
890
+ * @returns The point of the current bar.
891
+ * @example
892
+ * ```js
893
+ * eachBar((c) => {
894
+ * if (c.i === c.n - 1) polyline.new([chart.point.from_index(c.i - 10, c.low), chart.point.now(c.high)]);
895
+ * });
896
+ * ```
897
+ */
898
+ now(price?: number): ChartPoint;
899
+ }
900
+
901
+ /** The chart the script runs on: its colours, the bars in view, its type, and chart points for drawings. */
902
+ export interface ChartNamespace {
903
+ /** Foreground (text) colour of the chart, e.g. `"#DBDBDB"` on a dark chart. */
904
+ readonly fg_color: string;
905
+
906
+ /** Background colour of the chart, e.g. `"#0F0F0F"` on a dark chart. */
907
+ readonly bg_color: string;
908
+
909
+ /**
910
+ * Time (UNIX ms) of the first bar in view; the first bar's time when the app does not give it. A script that reads
911
+ * it is calculated again when the chart scrolls.
912
+ */
913
+ readonly left_visible_bar_time: number;
914
+
915
+ /**
916
+ * Time (UNIX ms) of the last bar in view; the last bar's time when the app does not give it. A script that reads
917
+ * it is calculated again when the chart scrolls.
918
+ */
919
+ readonly right_visible_bar_time: number;
920
+
921
+ /** True when the chart shows standard bars or candles (none of the types below). */
922
+ readonly is_standard: boolean;
923
+
924
+ /** True on a Heikin Ashi chart. */
925
+ readonly is_heikinashi: boolean;
926
+
927
+ /** True on a Renko chart. */
928
+ readonly is_renko: boolean;
929
+
930
+ /** True on a Kagi chart. */
931
+ readonly is_kagi: boolean;
932
+
933
+ /** True on a Line break chart. */
934
+ readonly is_linebreak: boolean;
935
+
936
+ /** True on a Point and figure chart. */
937
+ readonly is_pnf: boolean;
938
+
939
+ /** True on a Range chart. */
940
+ readonly is_range: boolean;
941
+
942
+ /** Chart points (time or bar index, and price) for drawings. */
943
+ readonly point: ChartPointNamespace;
944
+ }