oakscriptjs 0.24.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +1067 -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 +1067 -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 +1519 -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,1012 @@
1
+ /**
2
+ * @fileoverview The documented type of the `ta` namespace of the script API (technical analysis).
3
+ * @module script/api/ta
4
+ */
5
+ import type { Series } from '../../runtime/series.js';
6
+ /**
7
+ * Technical analysis functions and values of the script API: moving averages, oscillators, bands, crosses,
8
+ * pivots and volume indicators.
9
+ *
10
+ * Each function computes a whole Series (one value per bar) in one call, so call it at the top level of the
11
+ * script, before any `eachBar()` loop, and read the value of a bar with `c.get(series)` inside the loop. Missing
12
+ * values (`na`) are `NaN`. Conditions come back as Series of 1 (true) and 0 (false).
13
+ */
14
+ export interface TaNamespace {
15
+ /**
16
+ * Simple moving average: the mean of the last `length` values. Use it to smooth a price or any Series.
17
+ * Missing values are skipped (the window holds the last `length` valid values); `NaN` until `length` values exist.
18
+ * @param source - Series to average, e.g. `close`.
19
+ * @param length - Number of values in the window (a fraction is truncated). A Series gives one length per bar.
20
+ * @returns Series of the averages.
21
+ * @example
22
+ * ```js
23
+ * const ma = ta.sma(close, 20);
24
+ * plot(ma, "SMA 20", { color: color.blue });
25
+ * ```
26
+ */
27
+ sma(source: Series, length: number | Series): Series;
28
+ /**
29
+ * Exponential moving average with the smoothing factor `2 / (length + 1)`: recent values weigh more than in
30
+ * `ta.sma`. The first value is the simple average of the first `length` valid values; `NaN` before it, and on a
31
+ * bar whose source is missing.
32
+ * @param source - Series to average.
33
+ * @param length - Number of bars of the average (at least 1).
34
+ * @returns Series of the averages.
35
+ * @example
36
+ * ```js
37
+ * const fast = ta.ema(close, 12);
38
+ * plot(fast, "Fast EMA");
39
+ * ```
40
+ */
41
+ ema(source: Series, length: number): Series;
42
+ /**
43
+ * Running moving average (Wilder's smoothing) with the smoothing factor `1 / length`, the average used by
44
+ * `ta.rsi` and `ta.atr`. Starts with the simple average of the first `length` valid values; `NaN` before it.
45
+ * @param source - Series to average.
46
+ * @param length - Number of bars of the average (at least 1).
47
+ * @returns Series of the averages.
48
+ * @example
49
+ * ```js
50
+ * const avgRange = ta.rma(high.sub(low), 14);
51
+ * plot(avgRange, "Average range");
52
+ * ```
53
+ */
54
+ rma(source: Series, length: number): Series;
55
+ /**
56
+ * Weighted moving average: the newest value has the weight `length`, the one before `length - 1`, and so on
57
+ * down to 1. `NaN` on a bar whose source is missing and until `length` valid values exist.
58
+ * @param source - Series to average.
59
+ * @param length - Number of values in the window (at least 1). A Series gives one length per bar.
60
+ * @returns Series of the averages.
61
+ * @example
62
+ * ```js
63
+ * const wma = ta.wma(close, 10);
64
+ * plot(wma, "WMA 10");
65
+ * ```
66
+ */
67
+ wma(source: Series, length: number | Series): Series;
68
+ /**
69
+ * Hull moving average: a weighted average of `2 * wma(source, length / 2) - wma(source, length)` over
70
+ * `sqrt(length)` bars, smooth with little lag.
71
+ * @param source - Series to average.
72
+ * @param length - Number of bars (at least 1).
73
+ * @returns Series of the averages.
74
+ * @example
75
+ * ```js
76
+ * const hull = ta.hma(close, 21);
77
+ * plot(hull, "HMA");
78
+ * ```
79
+ */
80
+ hma(source: Series, length: number): Series;
81
+ /**
82
+ * Arnaud Legoux moving average: a moving average whose weights follow a bell curve placed toward the newest
83
+ * values, smooth with little lag. `NaN` on the first `length - 1` bars and when the window holds a missing value.
84
+ * @param source - Series to average.
85
+ * @param length - Number of bars in the window. Default: 9.
86
+ * @param offset - Where the peak of the weights sits, from 0 (oldest bar) to 1 (newest bar). Default: 0.85.
87
+ * @param sigma - Width of the bell curve: a higher value gives flatter weights. Default: 6.
88
+ * @param floor - When true, the peak position `offset * (length - 1)` is rounded down to a whole bar.
89
+ * Default: false.
90
+ * @returns Series of the averages.
91
+ * @example
92
+ * ```js
93
+ * const alma = ta.alma(close, 9, 0.85, 6);
94
+ * plot(alma, "ALMA");
95
+ * ```
96
+ */
97
+ alma(source: Series, length?: number, offset?: number, sigma?: number, floor?: boolean): Series;
98
+ /**
99
+ * Symmetrically weighted moving average over 4 bars with the weights 1, 2, 2, 1 (newest to oldest).
100
+ * `NaN` on the first 3 bars and when one of the 4 values is missing.
101
+ * @param source - Series to average.
102
+ * @returns Series of the averages.
103
+ * @example
104
+ * ```js
105
+ * plot(ta.swma(close), "SWMA");
106
+ * ```
107
+ */
108
+ swma(source: Series): Series;
109
+ /**
110
+ * Volume-weighted moving average: `sma(source * volume, length) / sma(volume, length)`, so bars with more
111
+ * volume weigh more. Uses the chart volume unless a third argument gives another one.
112
+ * @param source - Series to average.
113
+ * @param length - Number of bars (at least 1).
114
+ * @param vol - Volume Series to weigh with. Default: the chart `volume`.
115
+ * @returns Series of the averages (`NaN` where the summed volume is 0).
116
+ * @example
117
+ * ```js
118
+ * const vwma = ta.vwma(close, 20);
119
+ * plot(vwma, "VWMA");
120
+ * ```
121
+ */
122
+ vwma(source: Series, length: number, vol?: Series): Series;
123
+ /**
124
+ * Volume-weighted average price with the chart volume, restarted on each anchor bar. Without an anchor it
125
+ * restarts on each new trading day (on daily, weekly and monthly charts every bar starts again).
126
+ * @param source - Price Series to average, usually `hlc3`.
127
+ * @param anchor - Series that is non-zero on the bars where the sums restart, e.g.
128
+ * `timeframe.change("W")`. Default: a new trading day.
129
+ * @returns Series of the average price since the last anchor.
130
+ * @example
131
+ * ```js
132
+ * const vwap = ta.vwap(hlc3);
133
+ * plot(vwap, "VWAP", { color: color.orange });
134
+ * ```
135
+ */
136
+ vwap(source: Series, anchor?: Series): Series;
137
+ /**
138
+ * Volume-weighted average price with bands at a multiple of the volume-weighted standard deviation.
139
+ * @param source - Price Series to average, usually `hlc3`.
140
+ * @param anchor - Series that is non-zero on the bars where the sums restart, or `undefined` for a new trading
141
+ * day.
142
+ * @param stdev_mult - Distance of the bands from the average, in standard deviations.
143
+ * @returns Tuple `[vwap, upper, lower]` of Series.
144
+ * @example
145
+ * ```js
146
+ * const [vwap, upper, lower] = ta.vwap(hlc3, undefined, 2);
147
+ * plot(upper, "Upper");
148
+ * plot(lower, "Lower");
149
+ * ```
150
+ */
151
+ vwap(source: Series, anchor: Series | undefined, stdev_mult: number): [Series, Series, Series];
152
+ /**
153
+ * Volume-weighted average price with bands, with an explicit volume. Same as `ta.vwap(source, anchor,
154
+ * stdev_mult)` with another volume Series; without an anchor the sums never restart.
155
+ * @param source - Price Series to average.
156
+ * @param volume - Volume Series to weigh with.
157
+ * @param anchor - Series that is non-zero on the bars where the sums restart, or `undefined` for no restart.
158
+ * @param stdev_mult - Distance of the bands from the average, in standard deviations.
159
+ * @returns Tuple `[vwap, upper, lower]` of Series.
160
+ * @example
161
+ * ```js
162
+ * const [vwap, upper, lower] = ta.vwapBands(hlc3, volume, timeframe.change("D"), 1);
163
+ * plot(vwap, "VWAP");
164
+ * ```
165
+ */
166
+ vwapBands(source: Series, volume: Series, anchor: Series | undefined, stdev_mult: number): [Series, Series, Series];
167
+ /**
168
+ * Relative strength index, from 0 to 100: the share of the average gains in the average gains and losses
169
+ * over `length` bars (Wilder's smoothing). Above 70 is often read as overbought, below 30 as oversold.
170
+ * @param source - Series to measure, e.g. `close`.
171
+ * @param length - Number of bars of the averages (at least 1).
172
+ * @returns Series of values from 0 to 100.
173
+ * @example
174
+ * ```js
175
+ * const rsi = ta.rsi(close, 14);
176
+ * plot(rsi, "RSI");
177
+ * hline(70, "Overbought");
178
+ * ```
179
+ */
180
+ rsi(source: Series, length: number): Series;
181
+ /**
182
+ * Relative strength index from two averages you computed yourself: `100 - 100 / (1 + up / down)`; 100 when
183
+ * `down` is 0, 0 when `up` is 0.
184
+ * @param up - Average of the upward changes.
185
+ * @param down - Average of the downward changes.
186
+ * @returns Series of values from 0 to 100.
187
+ * @example
188
+ * ```js
189
+ * const up = ta.rma(ta.change(close).mul(close.gt(close.offset(1))), 14);
190
+ * const down = ta.rma(ta.change(close).neg().mul(close.lt(close.offset(1))), 14);
191
+ * plot(ta.rsi(up, down), "RSI");
192
+ * ```
193
+ */
194
+ rsi(up: Series, down: Series): Series;
195
+ /**
196
+ * Moving average convergence divergence: the gap between a fast and a slow exponential average, its own
197
+ * average (the signal line) and the difference of the two (the histogram).
198
+ * @param source - Series to measure, e.g. `close`.
199
+ * @param fastLength - Length of the fast exponential average, e.g. 12.
200
+ * @param slowLength - Length of the slow exponential average, e.g. 26.
201
+ * @param signalLength - Length of the exponential average of the MACD line, e.g. 9.
202
+ * @returns Tuple `[macdLine, signalLine, histogram]` of Series.
203
+ * @example
204
+ * ```js
205
+ * const [macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9);
206
+ * plot(hist, "Histogram", { style: plot.style_columns });
207
+ * plot(macdLine, "MACD");
208
+ * ```
209
+ */
210
+ macd(source: Series, fastLength: number, slowLength: number, signalLength: number): [Series, Series, Series];
211
+ /**
212
+ * Stochastic %K, from 0 to 100: where `source` sits in the range between the lowest `low` and the highest
213
+ * `high` of the last `length` bars. Smooth it with `ta.sma` for the %D line. A bar where it cannot be computed
214
+ * keeps the previous value.
215
+ * @param source - Series to place in the range, usually `close`.
216
+ * @param highSource - Series of highs, usually `high`.
217
+ * @param lowSource - Series of lows, usually `low`.
218
+ * @param length - Number of bars of the range (at least 1).
219
+ * @returns Series of values from 0 to 100.
220
+ * @example
221
+ * ```js
222
+ * const k = ta.sma(ta.stoch(close, high, low, 14), 3);
223
+ * plot(k, "%K");
224
+ * plot(ta.sma(k, 3), "%D");
225
+ * ```
226
+ */
227
+ stoch(source: Series, highSource: Series, lowSource: Series, length: number): Series;
228
+ /**
229
+ * Commodity channel index: `(source - sma) / (0.015 * mean deviation)` over `length` bars. Readings above
230
+ * +100 or below -100 mark strong moves. A flat window keeps the previous value.
231
+ * @param source - Series to measure, usually `hlc3`.
232
+ * @param length - Number of bars (at least 1).
233
+ * @returns Series of index values (unbounded).
234
+ * @example
235
+ * ```js
236
+ * const cci = ta.cci(hlc3, 20);
237
+ * plot(cci, "CCI");
238
+ * ```
239
+ */
240
+ cci(source: Series, length: number): Series;
241
+ /**
242
+ * Money flow index, from 0 to 100: a volume-weighted version of the RSI built from the chart volume. Above 80
243
+ * is often read as overbought, below 20 as oversold.
244
+ * @param source - Price Series, usually `hlc3`.
245
+ * @param length - Number of bars (at least 1).
246
+ * @returns Series of values from 0 to 100.
247
+ * @example
248
+ * ```js
249
+ * const mfi = ta.mfi(hlc3, 14);
250
+ * plot(mfi, "MFI");
251
+ * ```
252
+ */
253
+ mfi(source: Series, length: number): Series;
254
+ /**
255
+ * Williams %R, from -100 to 0: where the close sits in the high-low range of the last `length` bars
256
+ * (0 = at the highest high, -100 = at the lowest low). Uses the chart high, low and close.
257
+ * @param length - Number of bars (at least 1). Default: 14.
258
+ * @returns Series of values from -100 to 0 (`NaN` when the range is 0).
259
+ * @example
260
+ * ```js
261
+ * const wpr = ta.wpr(14);
262
+ * plot(wpr, "%R");
263
+ * ```
264
+ */
265
+ wpr(length?: number): Series;
266
+ /**
267
+ * True strength index, from -1 to 1: the bar-to-bar change smoothed twice with exponential averages, divided
268
+ * by the change size smoothed the same way. Not multiplied by 100.
269
+ * @param source - Series to measure, e.g. `close`.
270
+ * @param shortLength - Length of the second (short) smoothing.
271
+ * @param longLength - Length of the first (long) smoothing.
272
+ * @returns Series of values from -1 to 1 (`NaN` when the source does not move).
273
+ * @example
274
+ * ```js
275
+ * const tsi = ta.tsi(close, 13, 25);
276
+ * plot(tsi, "TSI");
277
+ * ```
278
+ */
279
+ tsi(source: Series, shortLength: number, longLength: number): Series;
280
+ /**
281
+ * Chande momentum oscillator, from -100 to 100: `100 * (sum of gains - sum of losses) / (sum of gains + sum
282
+ * of losses)` over the last `length` bars.
283
+ * @param source - Series to measure, e.g. `close`.
284
+ * @param length - Number of bars (at least 1).
285
+ * @returns Series of values from -100 to 100 (`NaN` when every change in the window is 0).
286
+ * @example
287
+ * ```js
288
+ * const cmo = ta.cmo(close, 9);
289
+ * plot(cmo, "CMO");
290
+ * ```
291
+ */
292
+ cmo(source: Series, length: number): Series;
293
+ /**
294
+ * Center of gravity oscillator: `-sum(source[i] * (i + 1)) / sum(source)` over the last `length` bars
295
+ * (`i` = 0 for the newest bar). Turns tend to show early.
296
+ * @param source - Series to measure, e.g. `close`.
297
+ * @param length - Number of bars (at least 1). Default: 10.
298
+ * @returns Series of oscillator values (`NaN` when the window holds a missing value).
299
+ * @example
300
+ * ```js
301
+ * const cog = ta.cog(close, 10);
302
+ * plot(cog, "COG");
303
+ * ```
304
+ */
305
+ cog(source: Series, length?: number): Series;
306
+ /**
307
+ * Rank correlation index, from -100 to 100: how steadily the source rose (+100) or fell (-100) over the
308
+ * last `length` bars, from the rank order of the values. The first value is on bar `length`.
309
+ * @param source - Series to measure, e.g. `close`.
310
+ * @param length - Number of bars (at least 1).
311
+ * @returns Series of values from -100 to 100.
312
+ * @example
313
+ * ```js
314
+ * const rci = ta.rci(close, 9);
315
+ * plot(rci, "RCI");
316
+ * ```
317
+ */
318
+ rci(source: Series, length: number): Series;
319
+ /**
320
+ * Momentum: `source - source[length]`, the change over `length` bars. `NaN` on the first `length` bars.
321
+ * @param source - Series to measure.
322
+ * @param length - Number of bars back (at least 1).
323
+ * @returns Series of differences.
324
+ * @example
325
+ * ```js
326
+ * const mom = ta.mom(close, 10);
327
+ * plot(mom, "Momentum");
328
+ * ```
329
+ */
330
+ mom(source: Series, length: number): Series;
331
+ /**
332
+ * Rate of change in percent: `100 * (source - source[length]) / source[length]`. `NaN` on the first `length`
333
+ * bars.
334
+ * @param source - Series to measure.
335
+ * @param length - Number of bars back (at least 1).
336
+ * @returns Series of percentages (5 means +5%).
337
+ * @example
338
+ * ```js
339
+ * const roc = ta.roc(close, 9);
340
+ * plot(roc, "ROC");
341
+ * ```
342
+ */
343
+ roc(source: Series, length: number): Series;
344
+ /**
345
+ * Change over `length` bars: `source - source[length]`. With the default length, the difference from the
346
+ * previous bar. `NaN` on the first `length` bars.
347
+ * @param source - Series to measure.
348
+ * @param length - Number of bars back (at least 1). Default: 1.
349
+ * @returns Series of differences.
350
+ * @example
351
+ * ```js
352
+ * const diff = ta.change(close);
353
+ * plot(diff, "Change", { style: plot.style_histogram });
354
+ * ```
355
+ */
356
+ change(source: Series, length?: number): Series;
357
+ /**
358
+ * True range of each bar: the largest of `high - low`, `|high - previous close|` and `|low - previous close|`.
359
+ * Uses the chart high, low and close.
360
+ * @param handleNa - What to return when the previous close is missing (the first bar): true gives
361
+ * `high - low`, false gives `NaN`. Default: false.
362
+ * @returns Series of true ranges, in price units.
363
+ * @example
364
+ * ```js
365
+ * const range = ta.tr(true);
366
+ * plot(range, "True range");
367
+ * ```
368
+ */
369
+ tr(handleNa?: boolean): Series;
370
+ /**
371
+ * Average true range: the running moving average (`ta.rma`) of the true range over `length` bars, a measure
372
+ * of volatility in price units. Uses the chart high, low and close.
373
+ * @param length - Number of bars (at least 1).
374
+ * @returns Series of average ranges.
375
+ * @example
376
+ * ```js
377
+ * const atr = ta.atr(14);
378
+ * plot(close.sub(atr.mul(2)), "Stop");
379
+ * ```
380
+ */
381
+ atr(length: number): Series;
382
+ /**
383
+ * Bollinger Bands: a simple moving average with bands `mult` standard deviations above and below it.
384
+ * @param source - Series to measure, e.g. `close`.
385
+ * @param length - Number of bars of the average and the deviation.
386
+ * @param mult - Distance of the bands, in standard deviations, e.g. 2.
387
+ * @returns Tuple `[middle, upper, lower]` of Series.
388
+ * @example
389
+ * ```js
390
+ * const [middle, upper, lower] = ta.bb(close, 20, 2);
391
+ * fill(plot(upper, "Upper"), plot(lower, "Lower"), { color: color.new(color.blue, 90) });
392
+ * ```
393
+ */
394
+ bb(source: Series, length: number, mult: number): [Series, Series, Series];
395
+ /**
396
+ * Bollinger Bands width in percent of the middle band: `100 * (upper - lower) / middle`. Low values mark
397
+ * quiet markets.
398
+ * @param source - Series to measure, e.g. `close`.
399
+ * @param length - Number of bars of the average and the deviation.
400
+ * @param mult - Distance of the bands, in standard deviations.
401
+ * @returns Series of widths in percent (`NaN` when the middle band is 0).
402
+ * @example
403
+ * ```js
404
+ * const width = ta.bbw(close, 20, 2);
405
+ * plot(width, "BB width");
406
+ * ```
407
+ */
408
+ bbw(source: Series, length: number, mult: number): Series;
409
+ /**
410
+ * Keltner Channels: an exponential average of `source` with bands at `mult` times the exponential average
411
+ * of the true range (or of `high - low`) above and below it. Uses the chart high, low and close.
412
+ * @param source - Series of the middle line, e.g. `close`.
413
+ * @param length - Number of bars of the averages.
414
+ * @param mult - Multiplier of the range for the bands.
415
+ * @param useTrueRange - True: the bands use the true range; false: `high - low`. Default: true.
416
+ * @returns Tuple `[middle, upper, lower]` of Series.
417
+ * @example
418
+ * ```js
419
+ * const [middle, upper, lower] = ta.kc(close, 20, 1.5);
420
+ * plot(upper, "Upper");
421
+ * plot(lower, "Lower");
422
+ * ```
423
+ */
424
+ kc(source: Series, length: number, mult: number, useTrueRange?: boolean): [Series, Series, Series];
425
+ /**
426
+ * Keltner Channels width as a ratio of the middle line: `(upper - lower) / middle` (0.05 is a width of 5%).
427
+ * Uses the chart high, low and close.
428
+ * @param source - Series of the middle line, e.g. `close`.
429
+ * @param length - Number of bars of the averages. Default: 20.
430
+ * @param mult - Multiplier of the range for the bands. Default: 2.
431
+ * @param useTrueRange - True: the bands use the true range; false: `high - low`. Default: true.
432
+ * @returns Series of ratios.
433
+ * @example
434
+ * ```js
435
+ * const width = ta.kcw(close, 20, 2);
436
+ * plot(width, "KC width");
437
+ * ```
438
+ */
439
+ kcw(source: Series, length?: number, mult?: number, useTrueRange?: boolean): Series;
440
+ /**
441
+ * Standard deviation over the last `length` values: how far the values spread around their mean. Missing
442
+ * values are skipped; `NaN` until `length` values exist.
443
+ * @param source - Series to measure.
444
+ * @param length - Number of values in the window. A Series gives one length per bar.
445
+ * @param biased - True divides by `length` (whole population); false by `length - 1` (sample). Default: true.
446
+ * @returns Series of deviations, in the units of the source.
447
+ * @example
448
+ * ```js
449
+ * const sd = ta.stdev(close, 20);
450
+ * plot(sd, "Std dev");
451
+ * ```
452
+ */
453
+ stdev(source: Series, length: number | Series, biased?: boolean): Series;
454
+ /**
455
+ * Variance over the last `length` values: the mean of the squared distances to the mean (the square of
456
+ * `ta.stdev`). Missing values are skipped; `NaN` until `length` values exist.
457
+ * @param source - Series to measure.
458
+ * @param length - Number of values in the window. A Series gives one length per bar.
459
+ * @param biased - True divides by `length` (whole population); false by `length - 1` (sample). Default: true.
460
+ * @returns Series of variances.
461
+ * @example
462
+ * ```js
463
+ * const v = ta.variance(close, 20);
464
+ * plot(v, "Variance");
465
+ * ```
466
+ */
467
+ variance(source: Series, length: number | Series, biased?: boolean): Series;
468
+ /**
469
+ * Mean absolute deviation: the average distance of the last `length` values from their simple average.
470
+ * `NaN` when one of these values is missing.
471
+ * @param source - Series to measure.
472
+ * @param length - Number of bars (at least 1).
473
+ * @returns Series of deviations, in the units of the source.
474
+ * @example
475
+ * ```js
476
+ * const md = ta.dev(close, 20);
477
+ * plot(md, "Mean deviation");
478
+ * ```
479
+ */
480
+ dev(source: Series, length: number): Series;
481
+ /**
482
+ * Parabolic SAR (stop and reverse): a trailing level below the price in an up trend and above it in a down
483
+ * trend, which flips when the price crosses it. Uses the chart high, low and close. `NaN` on the first bar.
484
+ * @param start - Starting acceleration factor. Default: 0.02.
485
+ * @param inc - Step added to the acceleration on each new extreme. Default: 0.02.
486
+ * @param max - Largest acceleration factor. Default: 0.2.
487
+ * @returns Series of stop levels, in price units.
488
+ * @example
489
+ * ```js
490
+ * const sar = ta.sar(0.02, 0.02, 0.2);
491
+ * plot(sar, "SAR", { style: plot.style_cross });
492
+ * ```
493
+ */
494
+ sar(start?: number, inc?: number, max?: number): Series;
495
+ /**
496
+ * Supertrend: a trailing line at `factor` average true ranges from the middle of the bar, below the price in an
497
+ * up trend and above it in a down trend. Uses the chart high, low and close.
498
+ * @param factor - Multiplier of the average true range, e.g. 3.
499
+ * @param atrLength - Number of bars of the average true range, e.g. 10.
500
+ * @returns Tuple `[supertrend, direction]`: the line, and the direction (-1 in an up trend, 1 in a down trend).
501
+ * @example
502
+ * ```js
503
+ * const [line, direction] = ta.supertrend(3, 10);
504
+ * plot(line, "Supertrend", { color: color.when(direction.lt(0), color.green, color.red) });
505
+ * ```
506
+ */
507
+ supertrend(factor: number, atrLength: number): [Series, Series];
508
+ /**
509
+ * Directional movement index: the plus and minus directional indicators and the average directional index
510
+ * (trend strength, 0 to 100). Uses the chart high, low and close.
511
+ * @param diLength - Number of bars of the directional indicators, e.g. 14.
512
+ * @param adxSmoothing - Number of bars of the ADX smoothing, e.g. 14.
513
+ * @returns Tuple `[plusDI, minusDI, adx]` of Series.
514
+ * @example
515
+ * ```js
516
+ * const [plusDI, minusDI, adx] = ta.dmi(14, 14);
517
+ * plot(adx, "ADX");
518
+ * ```
519
+ */
520
+ dmi(diLength: number, adxSmoothing: number): [Series, Series, Series];
521
+ /**
522
+ * Ichimoku cloud lines, computed from the chart high, low and close. The two leading spans are already moved
523
+ * `displacement` bars forward (their value on a bar comes from `displacement` bars earlier), and the lagging
524
+ * span is moved `displacement` bars back (its value on a bar is the close `displacement` bars later, so the last
525
+ * `displacement` bars are `NaN`).
526
+ * @param conversionPeriods - Bars of the conversion line (midpoint of the high-low range), e.g. 9.
527
+ * @param basePeriods - Bars of the base line, e.g. 26.
528
+ * @param laggingSpan2Periods - Bars of the second leading span, e.g. 52.
529
+ * @param displacement - Number of bars the spans are moved, e.g. 26.
530
+ * @returns Tuple `[conversion, base, leadA, leadB, lagging]` of Series.
531
+ * @example
532
+ * ```js
533
+ * const [conversion, base, leadA, leadB] = ta.ichimoku(9, 26, 52, 26);
534
+ * fill(plot(leadA, "Lead A"), plot(leadB, "Lead B"), { color: color.new(color.teal, 85) });
535
+ * ```
536
+ */
537
+ ichimoku(conversionPeriods: number, basePeriods: number, laggingSpan2Periods: number, displacement: number): [Series, Series, Series, Series, Series];
538
+ /**
539
+ * Crossover: 1 on the bar where `a` moves above `b` (it was at or below `b` on the last bar where both had a
540
+ * value), 0 elsewhere.
541
+ * @param a - Series that crosses.
542
+ * @param b - Series or fixed level it crosses.
543
+ * @returns Series of 1 / 0.
544
+ * @example
545
+ * ```js
546
+ * const buy = ta.crossover(ta.ema(close, 9), ta.ema(close, 21));
547
+ * plotshape(buy, "Buy", { style: shape.triangleup, location: location.belowbar });
548
+ * ```
549
+ */
550
+ crossover(a: Series, b: Series | number): Series;
551
+ /**
552
+ * Crossunder: 1 on the bar where `a` moves below `b` (it was at or above `b` on the last bar where both had a
553
+ * value), 0 elsewhere.
554
+ * @param a - Series that crosses.
555
+ * @param b - Series or fixed level it crosses.
556
+ * @returns Series of 1 / 0.
557
+ * @example
558
+ * ```js
559
+ * const exitSignal = ta.crossunder(ta.rsi(close, 14), 70);
560
+ * plotshape(exitSignal, "Exit", { style: shape.xcross, location: location.abovebar });
561
+ * ```
562
+ */
563
+ crossunder(a: Series, b: Series | number): Series;
564
+ /**
565
+ * Cross in either direction: 1 on the bar where `a` moves to the other side of `b` (bars where they are equal
566
+ * do not count as a side), 0 elsewhere.
567
+ * @param a - First Series.
568
+ * @param b - Second Series or a fixed level.
569
+ * @returns Series of 1 / 0.
570
+ * @example
571
+ * ```js
572
+ * const [macdLine, signalLine] = ta.macd(close, 12, 26, 9);
573
+ * bgcolor(color.when(ta.cross(macdLine, signalLine), color.new(color.gray, 85)));
574
+ * ```
575
+ */
576
+ cross(a: Series, b: Series | number): Series;
577
+ /**
578
+ * Rising: 1 when the source went up on each of the last `length` bars, 0 otherwise.
579
+ * @param source - Series to test.
580
+ * @param length - Number of rises in a row needed (at least 1).
581
+ * @returns Series of 1 / 0.
582
+ * @example
583
+ * ```js
584
+ * const up3 = ta.rising(close, 3);
585
+ * bgcolor(color.when(up3, color.new(color.green, 85)));
586
+ * ```
587
+ */
588
+ rising(source: Series, length: number): Series;
589
+ /**
590
+ * Falling: 1 when the source went down on each of the last `length` bars, 0 otherwise.
591
+ * @param source - Series to test.
592
+ * @param length - Number of falls in a row needed (at least 1).
593
+ * @returns Series of 1 / 0.
594
+ * @example
595
+ * ```js
596
+ * const down3 = ta.falling(close, 3);
597
+ * bgcolor(color.when(down3, color.new(color.red, 85)));
598
+ * ```
599
+ */
600
+ falling(source: Series, length: number): Series;
601
+ /**
602
+ * Bars since a condition: 0 on a bar where the condition is 1, then 1, 2, 3... until it is 1 again. `NaN`
603
+ * until the condition was first true.
604
+ * @param condition - Series of 1 / 0 (only the value 1 counts as true).
605
+ * @returns Series of bar counts.
606
+ * @example
607
+ * ```js
608
+ * const sinceCross = ta.barssince(ta.crossover(close, ta.sma(close, 50)));
609
+ * plot(sinceCross, "Bars since cross");
610
+ * ```
611
+ */
612
+ barssince(condition: Series): Series;
613
+ /**
614
+ * Value when a condition was true: on each bar, the value `source` had on the bar of the `occurrence`-th most
615
+ * recent bar where the condition was 1. `NaN` while there were not enough such bars.
616
+ * @param condition - Series of 1 / 0 (only the value 1 counts as true).
617
+ * @param source - Series whose value is taken.
618
+ * @param occurrence - Which true bar, counting back: 0 is the most recent, 1 the one before, and so on.
619
+ * @returns Series of the remembered values.
620
+ * @example
621
+ * ```js
622
+ * const lastCrossLow = ta.valuewhen(ta.crossover(close, ta.sma(close, 20)), low, 0);
623
+ * plot(lastCrossLow, "Low at last cross");
624
+ * ```
625
+ */
626
+ valuewhen(condition: Series, source: Series, occurrence: number): Series;
627
+ /**
628
+ * Highest value of the last `length` bars of the chart `high`.
629
+ * @param length - Number of bars. A Series gives one length per bar.
630
+ * @returns Series of the highest highs (`NaN` on the first `length - 1` bars).
631
+ * @example
632
+ * ```js
633
+ * const top = ta.highest(20);
634
+ * plot(top, "20-bar high");
635
+ * ```
636
+ */
637
+ highest(length: number): Series;
638
+ /**
639
+ * Highest value of the last `length` values of a Series, e.g. a 20-bar high for a breakout. Missing values are
640
+ * skipped; `NaN` on the first `length - 1` bars.
641
+ * @param source - Series to search.
642
+ * @param length - Number of bars (a fraction is truncated). A Series gives one length per bar.
643
+ * @returns Series of the highest values.
644
+ * @example
645
+ * ```js
646
+ * const top = ta.highest(close, 20);
647
+ * plotshape(close.gte(top), "New high", { location: location.abovebar });
648
+ * ```
649
+ */
650
+ highest(source: Series, length: number | Series): Series;
651
+ /**
652
+ * Lowest value of the last `length` bars of the chart `low`.
653
+ * @param length - Number of bars. A Series gives one length per bar.
654
+ * @returns Series of the lowest lows (`NaN` on the first `length - 1` bars).
655
+ * @example
656
+ * ```js
657
+ * const bottom = ta.lowest(20);
658
+ * plot(bottom, "20-bar low");
659
+ * ```
660
+ */
661
+ lowest(length: number): Series;
662
+ /**
663
+ * Lowest value of the last `length` values of a Series. Missing values are skipped; `NaN` on the first
664
+ * `length - 1` bars.
665
+ * @param source - Series to search.
666
+ * @param length - Number of bars (a fraction is truncated). A Series gives one length per bar.
667
+ * @returns Series of the lowest values.
668
+ * @example
669
+ * ```js
670
+ * const bottom = ta.lowest(close, 20);
671
+ * plot(bottom, "20-bar low of close");
672
+ * ```
673
+ */
674
+ lowest(source: Series, length: number | Series): Series;
675
+ /**
676
+ * Offset to the bar with the highest chart `high` of the last `length` bars: 0 for the current bar, -1 for the
677
+ * bar before, and so on (always 0 or negative).
678
+ * @param length - Number of bars. A Series gives one length per bar.
679
+ * @returns Series of offsets (`NaN` on the first `length - 1` bars).
680
+ * @example
681
+ * ```js
682
+ * const ago = ta.highestbars(20);
683
+ * plot(ago, "Bars since 20-bar high");
684
+ * ```
685
+ */
686
+ highestbars(length: number): Series;
687
+ /**
688
+ * Offset to the bar with the highest value of the last `length` values of a Series: 0 for the current bar,
689
+ * -1 for the bar before, and so on (always 0 or negative; the newest bar wins a tie).
690
+ * @param source - Series to search.
691
+ * @param length - Number of bars. A Series gives one length per bar.
692
+ * @returns Series of offsets (`NaN` on the first `length - 1` bars).
693
+ * @example
694
+ * ```js
695
+ * const ago = ta.highestbars(close, 20);
696
+ * plot(ago, "Offset of highest close");
697
+ * ```
698
+ */
699
+ highestbars(source: Series, length: number | Series): Series;
700
+ /**
701
+ * Offset to the bar with the lowest chart `low` of the last `length` bars: 0 for the current bar, -1 for the
702
+ * bar before, and so on (always 0 or negative).
703
+ * @param length - Number of bars. A Series gives one length per bar.
704
+ * @returns Series of offsets (`NaN` on the first `length - 1` bars).
705
+ * @example
706
+ * ```js
707
+ * const ago = ta.lowestbars(20);
708
+ * plot(ago, "Bars since 20-bar low");
709
+ * ```
710
+ */
711
+ lowestbars(length: number): Series;
712
+ /**
713
+ * Offset to the bar with the lowest value of the last `length` values of a Series: 0 for the current bar,
714
+ * -1 for the bar before, and so on (always 0 or negative; the newest bar wins a tie).
715
+ * @param source - Series to search.
716
+ * @param length - Number of bars. A Series gives one length per bar.
717
+ * @returns Series of offsets (`NaN` on the first `length - 1` bars).
718
+ * @example
719
+ * ```js
720
+ * const ago = ta.lowestbars(close, 20);
721
+ * plot(ago, "Offset of lowest close");
722
+ * ```
723
+ */
724
+ lowestbars(source: Series, length: number | Series): Series;
725
+ /**
726
+ * Range of the last `length` values: highest minus lowest. Missing values are skipped; `NaN` until `length`
727
+ * values exist.
728
+ * @param source - Series to measure.
729
+ * @param length - Number of values (at least 1).
730
+ * @returns Series of ranges, in the units of the source.
731
+ * @example
732
+ * ```js
733
+ * const width = ta.range(close, 20);
734
+ * plot(width, "20-bar range");
735
+ * ```
736
+ */
737
+ range(source: Series, length: number): Series;
738
+ /**
739
+ * All-time highest value: the highest value of the source from the first bar up to each bar. Missing values
740
+ * are skipped.
741
+ * @param source - Series to search.
742
+ * @returns Series of running highest values (`NaN` until the first value).
743
+ * @example
744
+ * ```js
745
+ * plot(ta.max(high), "All-time high");
746
+ * ```
747
+ */
748
+ max(source: Series): Series;
749
+ /**
750
+ * All-time lowest value: the lowest value of the source from the first bar up to each bar. Missing values
751
+ * are skipped.
752
+ * @param source - Series to search.
753
+ * @returns Series of running lowest values (`NaN` until the first value).
754
+ * @example
755
+ * ```js
756
+ * plot(ta.min(low), "All-time low");
757
+ * ```
758
+ */
759
+ min(source: Series): Series;
760
+ /**
761
+ * Median of the last `length` values (the mean of the two middle values for an even length). Missing values
762
+ * are skipped; `NaN` until `length` values exist.
763
+ * @param source - Series to measure.
764
+ * @param length - Number of values (at least 1).
765
+ * @returns Series of medians.
766
+ * @example
767
+ * ```js
768
+ * plot(ta.median(close, 20), "Median");
769
+ * ```
770
+ */
771
+ median(source: Series, length: number): Series;
772
+ /**
773
+ * Mode of the last `length` values: the most frequent value (the smallest one when several are as frequent).
774
+ * Missing values are skipped; `NaN` until `length` values exist.
775
+ * @param source - Series to measure.
776
+ * @param length - Number of values (at least 1).
777
+ * @returns Series of modes.
778
+ * @example
779
+ * ```js
780
+ * plot(ta.mode(close, 20), "Mode");
781
+ * ```
782
+ */
783
+ mode(source: Series, length: number): Series;
784
+ /**
785
+ * Percentile of the last `length` values, interpolated between the two nearest ranks (so the result may not be
786
+ * one of the values). `NaN` on the first `length - 1` bars.
787
+ * @param source - Series to measure.
788
+ * @param length - Number of bars (at least 1).
789
+ * @param percentage - Percentile to return, from 0 to 100 (50 is the median).
790
+ * @returns Series of percentile values.
791
+ * @example
792
+ * ```js
793
+ * const p90 = ta.percentile_linear_interpolation(close, 50, 90);
794
+ * plot(p90, "90th percentile");
795
+ * ```
796
+ */
797
+ percentile_linear_interpolation(source: Series, length: number, percentage: number): Series;
798
+ /**
799
+ * Percentile of the last `length` values by the nearest rank: always one of the values in the window.
800
+ * `NaN` on the first `length - 1` bars.
801
+ * @param source - Series to measure.
802
+ * @param length - Number of bars (at least 1).
803
+ * @param percentage - Percentile to return, from 0 to 100 (100 is the largest value).
804
+ * @returns Series of percentile values.
805
+ * @example
806
+ * ```js
807
+ * const p10 = ta.percentile_nearest_rank(close, 50, 10);
808
+ * plot(p10, "10th percentile");
809
+ * ```
810
+ */
811
+ percentile_nearest_rank(source: Series, length: number, percentage: number): Series;
812
+ /**
813
+ * Percent rank, from 0 to 100: the share of the previous `length` values that are at or below the current
814
+ * value. `NaN` on the first `length` bars.
815
+ * @param source - Series to measure.
816
+ * @param length - Number of previous bars to compare with (at least 1).
817
+ * @returns Series of values from 0 to 100.
818
+ * @example
819
+ * ```js
820
+ * const rank = ta.percentrank(close, 100);
821
+ * plot(rank, "Percent rank");
822
+ * ```
823
+ */
824
+ percentrank(source: Series, length: number): Series;
825
+ /**
826
+ * Correlation coefficient of two Series over the last `length` bars, from -1 (move in opposite directions) to
827
+ * 1 (move together).
828
+ * @param a - First Series.
829
+ * @param b - Second Series.
830
+ * @param length - Number of bars (at least 1).
831
+ * @returns Series of values from -1 to 1 (`NaN` when one Series is flat over the window).
832
+ * @example
833
+ * ```js
834
+ * const corr = ta.correlation(close, volume, 20);
835
+ * plot(corr, "Price / volume correlation");
836
+ * ```
837
+ */
838
+ correlation(a: Series, b: Series, length: number): Series;
839
+ /**
840
+ * Linear regression: the least-squares line through the last `length` values, read on the current bar (or
841
+ * `offset` bars back along the line). `NaN` when the window holds a missing value.
842
+ * @param source - Series to fit.
843
+ * @param length - Number of bars (at least 1).
844
+ * @param offset - Bars back along the line where it is read: 0 is the current bar, a negative value projects
845
+ * ahead. Default: 0.
846
+ * @returns Series of fitted values.
847
+ * @example
848
+ * ```js
849
+ * const fit = ta.linreg(close, 50);
850
+ * plot(fit, "Regression");
851
+ * ```
852
+ */
853
+ linreg(source: Series, length: number, offset?: number): Series;
854
+ /**
855
+ * Cumulative sum of the source from the first bar. A missing value adds nothing and gives `NaN` on its own
856
+ * bar only.
857
+ * @param source - Series to add up.
858
+ * @returns Series of running totals.
859
+ * @example
860
+ * ```js
861
+ * const totalVolume = ta.cum(volume);
862
+ * plot(totalVolume, "Cumulative volume");
863
+ * ```
864
+ */
865
+ cum(source: Series): Series;
866
+ /**
867
+ * Pivot high of the chart `high`: a bar higher than the `rightbars` bars after it and at least as high as the
868
+ * `leftbars` bars before it. The value appears `rightbars` bars after the pivot bar, when it is confirmed;
869
+ * `NaN` on the other bars.
870
+ * @param leftbars - Bars to the left of the pivot.
871
+ * @param rightbars - Bars to the right of the pivot.
872
+ * @returns Series of the pivot high price on the confirming bar, `NaN` elsewhere.
873
+ * @example
874
+ * ```js
875
+ * const ph = ta.pivothigh(5, 5);
876
+ * plot(ph, "Pivot high", { style: plot.style_circles, offset: -5 });
877
+ * ```
878
+ */
879
+ pivothigh(leftbars: number, rightbars: number | Series): Series;
880
+ /**
881
+ * Pivot high of a Series: a value higher than the `rightbars` values after it and at least as high as the
882
+ * `leftbars` values before it. The value appears `rightbars` bars after the pivot bar; `NaN` on the other bars.
883
+ * @param source - Series to search.
884
+ * @param leftbars - Bars to the left of the pivot. A Series gives one length per bar.
885
+ * @param rightbars - Bars to the right of the pivot. A Series gives one length per bar.
886
+ * @returns Series of the pivot value on the confirming bar, `NaN` elsewhere.
887
+ * @example
888
+ * ```js
889
+ * const ph = ta.pivothigh(close, 3, 3);
890
+ * plot(ph, "Pivot high", { style: plot.style_circles, offset: -3 });
891
+ * ```
892
+ */
893
+ pivothigh(source: Series, leftbars: number | Series, rightbars: number | Series): Series;
894
+ /**
895
+ * Pivot low of the chart `low`: a bar lower than the `rightbars` bars after it and at most as low as the
896
+ * `leftbars` bars before it. The value appears `rightbars` bars after the pivot bar, when it is confirmed;
897
+ * `NaN` on the other bars.
898
+ * @param leftbars - Bars to the left of the pivot.
899
+ * @param rightbars - Bars to the right of the pivot.
900
+ * @returns Series of the pivot low price on the confirming bar, `NaN` elsewhere.
901
+ * @example
902
+ * ```js
903
+ * const pl = ta.pivotlow(5, 5);
904
+ * plot(pl, "Pivot low", { style: plot.style_circles, offset: -5 });
905
+ * ```
906
+ */
907
+ pivotlow(leftbars: number, rightbars: number | Series): Series;
908
+ /**
909
+ * Pivot low of a Series: a value lower than the `rightbars` values after it and at most as low as the
910
+ * `leftbars` values before it. The value appears `rightbars` bars after the pivot bar; `NaN` on the other bars.
911
+ * @param source - Series to search.
912
+ * @param leftbars - Bars to the left of the pivot. A Series gives one length per bar.
913
+ * @param rightbars - Bars to the right of the pivot. A Series gives one length per bar.
914
+ * @returns Series of the pivot value on the confirming bar, `NaN` elsewhere.
915
+ * @example
916
+ * ```js
917
+ * const pl = ta.pivotlow(close, 3, 3);
918
+ * plot(pl, "Pivot low", { style: plot.style_circles, offset: -3 });
919
+ * ```
920
+ */
921
+ pivotlow(source: Series, leftbars: number | Series, rightbars: number | Series): Series;
922
+ /**
923
+ * ZigZag of the chart: the turning points of the price that are at least `deviation` percent apart, found on the
924
+ * chart's highs and lows. The last point may move as new bars come in.
925
+ * @param deviation - Smallest move between two points, in percent. Default: 5.
926
+ * @param depth - Bars at the start used to find the first point. Default: 10.
927
+ * @param backstep - Bars a new high or low must beat, and bars a point must wait before it is confirmed.
928
+ * Default: 3.
929
+ * @returns Tuple `[price, direction, isPivot]` of Series: the point price on point bars (`NaN` elsewhere), the
930
+ * direction (1 up, -1 down, 0 before the first point) and 1 / 0 on point bars.
931
+ * @example
932
+ * ```js
933
+ * const [points, direction, isPivot] = ta.zigzag(5, 10, 3);
934
+ * plot(points, "ZigZag", { style: plot.style_circles });
935
+ * ```
936
+ */
937
+ zigzag(deviation?: number, depth?: number, backstep?: number): [Series, Series, Series];
938
+ /**
939
+ * On-balance volume of the chart: a running total that adds the volume on up closes and subtracts it on down
940
+ * closes. A Series, not a function: read it as `ta.obv`.
941
+ * @example
942
+ * ```js
943
+ * plot(ta.obv, "OBV");
944
+ * ```
945
+ */
946
+ readonly obv: Series;
947
+ /**
948
+ * Price-volume trend of the chart: a running total of the close change in fraction of the previous close
949
+ * times the volume. A Series, not a function.
950
+ * @example
951
+ * ```js
952
+ * plot(ta.pvt, "PVT");
953
+ * ```
954
+ */
955
+ readonly pvt: Series;
956
+ /**
957
+ * Accumulation / distribution of the chart: a running total of
958
+ * `((close - low) - (high - close)) / (high - low) * volume`. Bars with `high == low` add nothing. A Series,
959
+ * not a function.
960
+ * @example
961
+ * ```js
962
+ * plot(ta.accdist, "Accumulation / distribution");
963
+ * ```
964
+ */
965
+ readonly accdist: Series;
966
+ /**
967
+ * Negative volume index of the chart: starts at 1 and follows the close change only on bars where the volume
968
+ * falls. A Series, not a function.
969
+ * @example
970
+ * ```js
971
+ * plot(ta.nvi, "NVI");
972
+ * ```
973
+ */
974
+ readonly nvi: Series;
975
+ /**
976
+ * Positive volume index of the chart: starts at 1 and follows the close change only on bars where the volume
977
+ * rises. A Series, not a function.
978
+ * @example
979
+ * ```js
980
+ * plot(ta.pvi, "PVI");
981
+ * ```
982
+ */
983
+ readonly pvi: Series;
984
+ /**
985
+ * Intraday intensity index of the chart: `(2 * close - high - low) / (high - low) * volume` on each bar
986
+ * (`NaN` where `high == low`). A Series, not a function.
987
+ * @example
988
+ * ```js
989
+ * plot(ta.iii, "III", { style: plot.style_histogram });
990
+ * ```
991
+ */
992
+ readonly iii: Series;
993
+ /**
994
+ * Williams accumulation / distribution of the chart: a running total of the close move beyond the previous
995
+ * close (against the low on up closes, the high on down closes). A Series, not a function.
996
+ * @example
997
+ * ```js
998
+ * plot(ta.wad, "WAD");
999
+ * ```
1000
+ */
1001
+ readonly wad: Series;
1002
+ /**
1003
+ * Williams variable accumulation / distribution of the chart: `(close - open) / (high - low) * volume` on each
1004
+ * bar (`NaN` where `high == low`). A Series, not a function.
1005
+ * @example
1006
+ * ```js
1007
+ * plot(ta.wvad, "WVAD", { style: plot.style_histogram });
1008
+ * ```
1009
+ */
1010
+ readonly wvad: Series;
1011
+ }
1012
+ //# sourceMappingURL=ta.d.ts.map