oakscriptjs 0.10.0 → 0.11.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 (201) hide show
  1. package/dist/cjs/box/index.d.ts.map +1 -1
  2. package/dist/cjs/box/index.js +7 -1
  3. package/dist/cjs/box/index.js.map +2 -2
  4. package/dist/cjs/callsite/index.d.ts +73 -32
  5. package/dist/cjs/callsite/index.d.ts.map +1 -1
  6. package/dist/cjs/callsite/index.js +69 -65
  7. package/dist/cjs/callsite/index.js.map +2 -2
  8. package/dist/cjs/drawing/registry.d.ts +75 -0
  9. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  10. package/dist/cjs/drawing/registry.js +139 -6
  11. package/dist/cjs/drawing/registry.js.map +2 -2
  12. package/dist/cjs/index.d.ts +8 -2
  13. package/dist/cjs/index.d.ts.map +1 -1
  14. package/dist/cjs/index.js +30 -1
  15. package/dist/cjs/index.js.map +2 -2
  16. package/dist/cjs/label/index.d.ts.map +1 -1
  17. package/dist/cjs/label/index.js +3 -0
  18. package/dist/cjs/label/index.js.map +2 -2
  19. package/dist/cjs/line/index.d.ts.map +1 -1
  20. package/dist/cjs/line/index.js +7 -1
  21. package/dist/cjs/line/index.js.map +2 -2
  22. package/dist/cjs/math/index.d.ts.map +1 -1
  23. package/dist/cjs/math/index.js +2 -0
  24. package/dist/cjs/math/index.js.map +2 -2
  25. package/dist/cjs/polyline/index.d.ts.map +1 -1
  26. package/dist/cjs/polyline/index.js +3 -0
  27. package/dist/cjs/polyline/index.js.map +2 -2
  28. package/dist/cjs/runtime/index.d.ts +2 -1
  29. package/dist/cjs/runtime/index.d.ts.map +1 -1
  30. package/dist/cjs/runtime/index.js +2 -0
  31. package/dist/cjs/runtime/index.js.map +2 -2
  32. package/dist/cjs/runtime/input-active.d.ts +27 -0
  33. package/dist/cjs/runtime/input-active.d.ts.map +1 -0
  34. package/dist/cjs/runtime/input-active.js +44 -0
  35. package/dist/cjs/runtime/input-active.js.map +7 -0
  36. package/dist/cjs/runtime/types.d.ts +29 -2
  37. package/dist/cjs/runtime/types.d.ts.map +1 -1
  38. package/dist/cjs/runtime/types.js.map +1 -1
  39. package/dist/cjs/script/index.d.ts +53 -17
  40. package/dist/cjs/script/index.d.ts.map +1 -1
  41. package/dist/cjs/script/index.js +70 -11
  42. package/dist/cjs/script/index.js.map +3 -3
  43. package/dist/cjs/session/bars.d.ts +15 -1
  44. package/dist/cjs/session/bars.d.ts.map +1 -1
  45. package/dist/cjs/session/bars.js +41 -6
  46. package/dist/cjs/session/bars.js.map +3 -3
  47. package/dist/cjs/session/calendar.d.ts +9 -1
  48. package/dist/cjs/session/calendar.d.ts.map +1 -1
  49. package/dist/cjs/session/calendar.js +28 -2
  50. package/dist/cjs/session/calendar.js.map +2 -2
  51. package/dist/cjs/session/context.d.ts +75 -0
  52. package/dist/cjs/session/context.d.ts.map +1 -0
  53. package/dist/cjs/session/context.js +113 -0
  54. package/dist/cjs/session/context.js.map +7 -0
  55. package/dist/cjs/str/index.d.ts +12 -4
  56. package/dist/cjs/str/index.d.ts.map +1 -1
  57. package/dist/cjs/str/index.js +13 -7
  58. package/dist/cjs/str/index.js.map +2 -2
  59. package/dist/cjs/str/numberformat.d.ts +10 -2
  60. package/dist/cjs/str/numberformat.d.ts.map +1 -1
  61. package/dist/cjs/str/numberformat.js +10 -2
  62. package/dist/cjs/str/numberformat.js.map +2 -2
  63. package/dist/cjs/ta/index.d.ts +33 -17
  64. package/dist/cjs/ta/index.d.ts.map +1 -1
  65. package/dist/cjs/ta/index.js +70 -29
  66. package/dist/cjs/ta/index.js.map +2 -2
  67. package/dist/cjs/ta/limits.d.ts +24 -0
  68. package/dist/cjs/ta/limits.d.ts.map +1 -0
  69. package/dist/cjs/ta/limits.js +50 -0
  70. package/dist/cjs/ta/limits.js.map +7 -0
  71. package/dist/cjs/ta/running-sum.d.ts +0 -16
  72. package/dist/cjs/ta/running-sum.d.ts.map +1 -1
  73. package/dist/cjs/ta/running-sum.js +2 -0
  74. package/dist/cjs/ta/running-sum.js.map +2 -2
  75. package/dist/cjs/ta-series.d.ts +7 -7
  76. package/dist/cjs/ta-series.d.ts.map +1 -1
  77. package/dist/cjs/ta-series.js +9 -7
  78. package/dist/cjs/ta-series.js.map +2 -2
  79. package/dist/cjs/time/index.d.ts +5 -2
  80. package/dist/cjs/time/index.d.ts.map +1 -1
  81. package/dist/cjs/time/index.js +2 -2
  82. package/dist/cjs/time/index.js.map +2 -2
  83. package/dist/cjs/time/session.d.ts +17 -1
  84. package/dist/cjs/time/session.d.ts.map +1 -1
  85. package/dist/cjs/time/session.js +61 -7
  86. package/dist/cjs/time/session.js.map +2 -2
  87. package/dist/cjs/types/metadata.d.ts +27 -3
  88. package/dist/cjs/types/metadata.d.ts.map +1 -1
  89. package/dist/cjs/types/metadata.js.map +1 -1
  90. package/dist/esm/box/index.d.ts.map +1 -1
  91. package/dist/esm/box/index.js +8 -2
  92. package/dist/esm/box/index.js.map +1 -1
  93. package/dist/esm/callsite/index.d.ts +73 -32
  94. package/dist/esm/callsite/index.d.ts.map +1 -1
  95. package/dist/esm/callsite/index.js +143 -106
  96. package/dist/esm/callsite/index.js.map +1 -1
  97. package/dist/esm/drawing/registry.d.ts +75 -0
  98. package/dist/esm/drawing/registry.d.ts.map +1 -1
  99. package/dist/esm/drawing/registry.js +237 -6
  100. package/dist/esm/drawing/registry.js.map +1 -1
  101. package/dist/esm/index.d.ts +8 -2
  102. package/dist/esm/index.d.ts.map +1 -1
  103. package/dist/esm/index.js +11 -1
  104. package/dist/esm/index.js.map +1 -1
  105. package/dist/esm/label/index.d.ts.map +1 -1
  106. package/dist/esm/label/index.js +4 -1
  107. package/dist/esm/label/index.js.map +1 -1
  108. package/dist/esm/line/index.d.ts.map +1 -1
  109. package/dist/esm/line/index.js +8 -2
  110. package/dist/esm/line/index.js.map +1 -1
  111. package/dist/esm/math/index.d.ts.map +1 -1
  112. package/dist/esm/math/index.js +3 -0
  113. package/dist/esm/math/index.js.map +1 -1
  114. package/dist/esm/polyline/index.d.ts.map +1 -1
  115. package/dist/esm/polyline/index.js +5 -1
  116. package/dist/esm/polyline/index.js.map +1 -1
  117. package/dist/esm/runtime/index.d.ts +2 -1
  118. package/dist/esm/runtime/index.d.ts.map +1 -1
  119. package/dist/esm/runtime/index.js +1 -0
  120. package/dist/esm/runtime/index.js.map +1 -1
  121. package/dist/esm/runtime/input-active.d.ts +27 -0
  122. package/dist/esm/runtime/input-active.d.ts.map +1 -0
  123. package/dist/esm/runtime/input-active.js +54 -0
  124. package/dist/esm/runtime/input-active.js.map +1 -0
  125. package/dist/esm/runtime/types.d.ts +29 -2
  126. package/dist/esm/runtime/types.d.ts.map +1 -1
  127. package/dist/esm/script/index.d.ts +53 -17
  128. package/dist/esm/script/index.d.ts.map +1 -1
  129. package/dist/esm/script/index.js +80 -13
  130. package/dist/esm/script/index.js.map +1 -1
  131. package/dist/esm/session/bars.d.ts +15 -1
  132. package/dist/esm/session/bars.d.ts.map +1 -1
  133. package/dist/esm/session/bars.js +50 -6
  134. package/dist/esm/session/bars.js.map +1 -1
  135. package/dist/esm/session/calendar.d.ts +9 -1
  136. package/dist/esm/session/calendar.d.ts.map +1 -1
  137. package/dist/esm/session/calendar.js +35 -3
  138. package/dist/esm/session/calendar.js.map +1 -1
  139. package/dist/esm/session/context.d.ts +75 -0
  140. package/dist/esm/session/context.d.ts.map +1 -0
  141. package/dist/esm/session/context.js +122 -0
  142. package/dist/esm/session/context.js.map +1 -0
  143. package/dist/esm/str/index.d.ts +12 -4
  144. package/dist/esm/str/index.d.ts.map +1 -1
  145. package/dist/esm/str/index.js +33 -12
  146. package/dist/esm/str/index.js.map +1 -1
  147. package/dist/esm/str/numberformat.d.ts +10 -2
  148. package/dist/esm/str/numberformat.d.ts.map +1 -1
  149. package/dist/esm/str/numberformat.js +16 -2
  150. package/dist/esm/str/numberformat.js.map +1 -1
  151. package/dist/esm/ta/index.d.ts +33 -17
  152. package/dist/esm/ta/index.d.ts.map +1 -1
  153. package/dist/esm/ta/index.js +130 -56
  154. package/dist/esm/ta/index.js.map +1 -1
  155. package/dist/esm/ta/limits.d.ts +24 -0
  156. package/dist/esm/ta/limits.d.ts.map +1 -0
  157. package/dist/esm/ta/limits.js +42 -0
  158. package/dist/esm/ta/limits.js.map +1 -0
  159. package/dist/esm/ta/running-sum.d.ts +0 -16
  160. package/dist/esm/ta/running-sum.d.ts.map +1 -1
  161. package/dist/esm/ta/running-sum.js +2 -0
  162. package/dist/esm/ta/running-sum.js.map +1 -1
  163. package/dist/esm/ta-series.d.ts +7 -7
  164. package/dist/esm/ta-series.d.ts.map +1 -1
  165. package/dist/esm/ta-series.js +9 -7
  166. package/dist/esm/ta-series.js.map +1 -1
  167. package/dist/esm/time/index.d.ts +5 -2
  168. package/dist/esm/time/index.d.ts.map +1 -1
  169. package/dist/esm/time/index.js +6 -3
  170. package/dist/esm/time/index.js.map +1 -1
  171. package/dist/esm/time/session.d.ts +17 -1
  172. package/dist/esm/time/session.d.ts.map +1 -1
  173. package/dist/esm/time/session.js +97 -10
  174. package/dist/esm/time/session.js.map +1 -1
  175. package/dist/esm/types/metadata.d.ts +27 -3
  176. package/dist/esm/types/metadata.d.ts.map +1 -1
  177. package/package.json +1 -1
  178. package/src/box/index.ts +8 -2
  179. package/src/callsite/index.ts +150 -100
  180. package/src/drawing/registry.ts +255 -5
  181. package/src/index.ts +36 -1
  182. package/src/label/index.ts +4 -1
  183. package/src/line/index.ts +8 -2
  184. package/src/math/index.ts +2 -0
  185. package/src/polyline/index.ts +3 -1
  186. package/src/runtime/index.ts +3 -0
  187. package/src/runtime/input-active.ts +50 -0
  188. package/src/runtime/types.ts +25 -2
  189. package/src/script/index.ts +123 -23
  190. package/src/session/bars.ts +47 -6
  191. package/src/session/calendar.ts +37 -3
  192. package/src/session/context.ts +160 -0
  193. package/src/str/index.ts +30 -12
  194. package/src/str/numberformat.ts +18 -3
  195. package/src/ta/index.ts +148 -66
  196. package/src/ta/limits.ts +47 -0
  197. package/src/ta/running-sum.ts +2 -0
  198. package/src/ta-series.ts +16 -14
  199. package/src/time/index.ts +6 -3
  200. package/src/time/session.ts +89 -9
  201. package/src/types/metadata.ts +27 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/box/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEhE,KAAK,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;AACxC,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CACrB,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,UAAU,EACxB,YAAY,CAAC,EAAE,KAAK,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,EAC5C,MAAM,CAAC,EAAE,SAAS,EAClB,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,KAAK,EACf,IAAI,CAAC,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAC3B,UAAU,CAAC,EAAE,KAAK,EAClB,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,EACzC,WAAW,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,EACzC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAC3B,gBAAgB,CAAC,EAAE,SAAS,GAAG,WAAW,EAC1C,aAAa,CAAC,EAAE,OAAO,EACvB,eAAe,CAAC,EAAE,MAAM,GACvB,GAAG,CAAC;AACP,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,M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AI,CAExC;AAQD;;GAEG;AACH,wBAAgB,GAAG,IAAI,GAAG,EAAE,CAE3B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,GAAG,GAAG,CAKlE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,GAAG,GAAG,CAKtE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,CAIpE;AAGD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,CAAC;AAC1B,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,CAAC"}
@@ -80,6 +80,8 @@ function new_box(...args) {
80
80
  force_overlay,
81
81
  text_formatting
82
82
  ] = rest;
83
+ (0, import_registry.checkBarIndex)("box.new", "left", left, xloc);
84
+ (0, import_registry.checkBarIndex)("box.new", "right", right, xloc);
83
85
  return (0, import_registry.register)("box", {
84
86
  left,
85
87
  top,
@@ -88,7 +90,7 @@ function new_box(...args) {
88
90
  xloc: xloc ?? "bar_index",
89
91
  extend: extend ?? "none",
90
92
  border_color,
91
- border_width: border_width || 1,
93
+ border_width: border_width ?? 1,
92
94
  border_style: border_style || "solid",
93
95
  bgcolor,
94
96
  text,
@@ -119,11 +121,13 @@ function copy(id) {
119
121
  }
120
122
  function set_left(id, left) {
121
123
  if ((0, import_registry.isDeleted)(id)) return id;
124
+ (0, import_registry.checkBarIndex)("box.set_(left*/xloc)", "left", left, id.xloc);
122
125
  id.left = left;
123
126
  return id;
124
127
  }
125
128
  function set_right(id, right) {
126
129
  if ((0, import_registry.isDeleted)(id)) return id;
130
+ (0, import_registry.checkBarIndex)("box.set_(right*/xlock)", "right", right, id.xloc);
127
131
  id.right = right;
128
132
  return id;
129
133
  }
@@ -139,12 +143,14 @@ function set_bottom(id, bottom) {
139
143
  }
140
144
  function set_lefttop(id, left, top) {
141
145
  if ((0, import_registry.isDeleted)(id)) return id;
146
+ (0, import_registry.checkBarIndex)("box.set_(left*/xloc)", "left", left, id.xloc);
142
147
  id.left = left;
143
148
  id.top = top;
144
149
  return id;
145
150
  }
146
151
  function set_rightbottom(id, right, bottom) {
147
152
  if ((0, import_registry.isDeleted)(id)) return id;
153
+ (0, import_registry.checkBarIndex)("box.set_(right*/xlock)", "right", right, id.xloc);
148
154
  id.right = right;
149
155
  id.bottom = bottom;
150
156
  return id;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/box/index.ts"],
4
- "sourcesContent": ["/**\n * Box namespace\n * Functions for creating and manipulating box drawing objects.\n *\n * @remarks\n * Box objects represent rectangular areas on the chart. The getter functions\n * (get_top, get_bottom, get_left, get_right) enable computational use cases like:\n * - Gap detection and tracking (detecting when price fills gaps)\n * - Range breakout analysis (detecting when price breaks out of consolidation)\n * - Rectangle pattern recognition\n *\n * @version 6\n */\n\nimport { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Box, color } from '../types/index.js';\n\ntype BoxXloc = 'bar_index' | 'bar_time';\ntype BoxExtend = 'none' | 'left' | 'right' | 'both';\n\n/**\n * Creates a new box (PineScript `box.new`), with two chart points or with coordinates, in PineScript's\n * parameter order:\n *\n * - `box.new(top_left, bottom_right, border_color?, border_width?, border_style?, extend?, xloc?, bgcolor?,\n * text?, text_size?, text_color?, text_halign?, text_valign?, text_wrap?, text_font_family?,\n * force_overlay?, text_formatting?)`\n * - `box.new(left, top, right, bottom, border_color?, border_width?, border_style?, extend?, xloc?, ...)`\n *\n * With chart points, x is `point.index` for `bar_index` boxes and `point.time` for `bar_time` boxes.\n *\n * @example\n * ```typescript\n * // Gap box from bar 10 to 20, between 100 and 105, extended to the right\n * const gap = box.new(10, 105, 20, 100, '#2196F3', 1, 'solid', 'right');\n * ```\n */\nexport function new_box(\n top_left: ChartPoint,\n bottom_right: ChartPoint,\n border_color?: color,\n border_width?: number,\n border_style?: 'solid' | 'dotted' | 'dashed',\n extend?: BoxExtend,\n xloc?: BoxXloc,\n bgcolor?: color,\n text?: string,\n text_size?: string | number,\n text_color?: color,\n text_halign?: 'left' | 'center' | 'right',\n text_valign?: 'top' | 'center' | 'bottom',\n text_wrap?: 'none' | 'auto',\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Box;\nexport function new_box(\n left: number,\n top: number,\n right: number,\n bottom: number,\n border_color?: color,\n border_width?: number,\n border_style?: 'solid' | 'dotted' | 'dashed',\n extend?: BoxExtend,\n xloc?: BoxXloc,\n bgcolor?: color,\n text?: string,\n text_size?: string | number,\n text_color?: color,\n text_halign?: 'left' | 'center' | 'right',\n text_valign?: 'top' | 'center' | 'bottom',\n text_wrap?: 'none' | 'auto',\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Box;\nexport function new_box(...args: unknown[]): Box {\n let left: number, top: number, right: number, bottom: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const [tl, br, ...others] = args as [ChartPoint, ChartPoint, ...unknown[]];\n const xloc = (others[4] as BoxXloc | undefined) ?? 'bar_index';\n [left, top, right, bottom, rest] = [pointX(tl, xloc), tl.price, pointX(br, xloc), br.price, others];\n } else {\n [left, top, right, bottom] = args as [number, number, number, number];\n rest = args.slice(4);\n }\n const [border_color, border_width, border_style, extend, xloc, bgcolor, text, text_size, text_color,\n text_halign, text_valign, text_wrap, text_font_family, force_overlay, text_formatting] = rest as [\n color?, number?, ('solid' | 'dotted' | 'dashed')?, BoxExtend?, BoxXloc?, color?, string?,\n (string | number)?, color?, ('left' | 'center' | 'right')?, ('top' | 'center' | 'bottom')?,\n ('none' | 'auto')?, ('default' | 'monospace')?, boolean?, number?,\n ];\n return register('box', {\n left,\n top,\n right,\n bottom,\n xloc: xloc ?? 'bar_index',\n extend: extend ?? 'none',\n border_color,\n border_width: border_width || 1,\n border_style: border_style || 'solid',\n bgcolor,\n text,\n text_size,\n text_color,\n text_halign,\n text_valign,\n text_wrap,\n text_font_family,\n force_overlay: force_overlay ?? false,\n text_formatting,\n });\n}\n\n/**\n * Returns the left border x coordinate.\n *\n * @param id - Box object\n * @returns Left border coordinate (bar index or timestamp)\n *\n * @remarks\n * **COMPUTATIONAL USE**: Calculate gap duration, validate range timeframes\n *\n * @example\n * ```typescript\n * const gap = box.new(10, 105, 20, 100);\n * const currentBar = 30;\n * const duration = currentBar - box.get_left(gap); // Returns 20\n *\n * if (duration > 50) {\n * console.log('Gap has been open for 50+ bars');\n * }\n * ```\n */\nexport function get_left(id: Box): number {\n return id.left;\n}\n\n/**\n * Returns the right border x coordinate.\n *\n * @param id - Box object\n * @returns Right border coordinate (bar index or timestamp)\n *\n * @remarks\n * **COMPUTATIONAL USE**: Calculate gap duration, update trailing edges\n *\n * @example\n * ```typescript\n * const range = box.new(100, 155, 150, 145);\n * const width = box.get_right(range) - box.get_left(range); // Returns 50 bars\n * ```\n */\nexport function get_right(id: Box): number {\n return id.right;\n}\n\n/**\n * Returns the top border price level.\n *\n * @param id - Box object\n * @returns Top border price\n *\n * @remarks\n * **COMPUTATIONAL USE**: Detect breakouts above resistance, check gap fills\n *\n * @example\n * ```typescript\n * const gap = box.new(10, 105, 20, 100); // Bearish gap\n *\n * // Check if price has filled gap from below\n * const high = 106;\n * if (high > box.get_top(gap)) {\n * console.log('Gap completely filled!');\n * }\n * ```\n */\nexport function get_top(id: Box): number {\n return id.top;\n}\n\n/**\n * Returns the bottom border price level.\n *\n * @param id - Box object\n * @returns Bottom border price\n *\n * @remarks\n * **COMPUTATIONAL USE**: Detect breakouts below support, check gap fills\n *\n * @example\n * ```typescript\n * const gap = box.new(10, 105, 20, 100); // Bearish gap\n *\n * // Check if price has touched gap from above\n * const low = 104;\n * if (low < box.get_top(gap) && low > box.get_bottom(gap)) {\n * console.log('Price entered the gap!');\n * }\n * ```\n */\nexport function get_bottom(id: Box): number {\n return id.bottom;\n}\n\n/**\n * Creates a copy of the box object.\n *\n * @param id - Box object to copy\n * @returns New box object with same properties\n *\n * @remarks\n * Creates a shallow copy of the box. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const originalBox = box.new(10, 105, 20, 100);\n * const copiedBox = box.copy(originalBox);\n *\n * // Modify copy without affecting original\n * copiedBox.top = 110;\n * ```\n */\nexport function copy(id: Box): Box {\n return register('box', { ...id });\n}\n\n// =============================================================================\n// COORDINATE SETTERS\n// =============================================================================\n\n/**\n * Sets the left border x coordinate.\n *\n * @param id - Box object to modify\n * @param left - New left border coordinate\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_left(box, 15); // Move left edge to bar 15\n * ```\n */\nexport function set_left(id: Box, left: number): Box {\n if (isDeleted(id)) return id;\n id.left = left;\n return id;\n}\n\n/**\n * Sets the right border x coordinate.\n *\n * @param id - Box object to modify\n * @param right - New right border coordinate\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_right(box, 25); // Move right edge to bar 25\n * ```\n */\nexport function set_right(id: Box, right: number): Box {\n if (isDeleted(id)) return id;\n id.right = right;\n return id;\n}\n\n/**\n * Sets the top border price level.\n *\n * @param id - Box object to modify\n * @param top - New top border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_top(box, 110); // Move top edge to price 110\n * ```\n */\nexport function set_top(id: Box, top: number): Box {\n if (isDeleted(id)) return id;\n id.top = top;\n return id;\n}\n\n/**\n * Sets the bottom border price level.\n *\n * @param id - Box object to modify\n * @param bottom - New bottom border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_bottom(box, 95); // Move bottom edge to price 95\n * ```\n */\nexport function set_bottom(id: Box, bottom: number): Box {\n if (isDeleted(id)) return id;\n id.bottom = bottom;\n return id;\n}\n\n/**\n * Sets the left and top coordinates.\n *\n * @param id - Box object to modify\n * @param left - New left border coordinate\n * @param top - New top border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_lefttop(box, 12, 108); // Move top-left corner\n * ```\n */\nexport function set_lefttop(id: Box, left: number, top: number): Box {\n if (isDeleted(id)) return id;\n id.left = left;\n id.top = top;\n return id;\n}\n\n/**\n * Sets the right and bottom coordinates.\n *\n * @param id - Box object to modify\n * @param right - New right border coordinate\n * @param bottom - New bottom border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_rightbottom(box, 25, 98); // Move bottom-right corner\n * ```\n */\nexport function set_rightbottom(id: Box, right: number, bottom: number): Box {\n if (isDeleted(id)) return id;\n id.right = right;\n id.bottom = bottom;\n return id;\n}\n\n/**\n * Sets the coordinate system for the box.\n *\n * @param id - Box object to modify\n * @param left - New left border coordinate\n * @param right - New right border coordinate\n * @param xloc - New coordinate system ('bar_index' or 'bar_time')\n * @returns Modified box object\n *\n * @remarks\n * When changing xloc, you must provide appropriate x coordinates for the new system.\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * // Change to timestamp-based coordinates\n * box.set_xloc(box, 1609459200000, 1609545600000, 'bar_time');\n * ```\n */\nexport function set_xloc(id: Box, left: number, right: number, xloc: 'bar_index' | 'bar_time'): Box {\n if (isDeleted(id)) return id;\n id.left = left;\n id.right = right;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the horizontal extension mode.\n *\n * @param id - Box object to modify\n * @param extend - New extension mode\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_extend(box, 'right'); // Extend box to the right\n * ```\n */\nexport function set_extend(id: Box, extend: 'none' | 'left' | 'right' | 'both'): Box {\n if (isDeleted(id)) return id;\n id.extend = extend;\n return id;\n}\n\n// =============================================================================\n// STYLING SETTERS\n// =============================================================================\n\n/**\n * Sets the border color.\n *\n * @param id - Box object to modify\n * @param borderColor - New border color\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_border_color(box, '#FF0000'); // Red border\n * ```\n */\nexport function set_border_color(id: Box, borderColor: color): Box {\n if (isDeleted(id)) return id;\n id.border_color = borderColor;\n return id;\n}\n\n/**\n * Sets the border width.\n *\n * @param id - Box object to modify\n * @param width - New border width in pixels\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_border_width(box, 2); // Thicker border\n * ```\n */\nexport function set_border_width(id: Box, width: number): Box {\n if (isDeleted(id)) return id;\n id.border_width = width;\n return id;\n}\n\n/**\n * Sets the border style.\n *\n * @param id - Box object to modify\n * @param style - New border style\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_border_style(box, 'dashed'); // Dashed border\n * ```\n */\nexport function set_border_style(id: Box, style: 'solid' | 'dotted' | 'dashed'): Box {\n if (isDeleted(id)) return id;\n id.border_style = style;\n return id;\n}\n\n/**\n * Sets the background fill color.\n *\n * @param id - Box object to modify\n * @param bgColor - New background color\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_bgcolor(box, '#00FF0030'); // Transparent green fill\n * ```\n */\nexport function set_bgcolor(id: Box, bgColor: color): Box {\n if (isDeleted(id)) return id;\n id.bgcolor = bgColor;\n return id;\n}\n\n// =============================================================================\n// TEXT SETTERS\n// =============================================================================\n\n/**\n * Sets the text content.\n *\n * @param id - Box object to modify\n * @param text - New text content\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text(box, 'Gap Filled'); // Update text\n * ```\n */\nexport function set_text(id: Box, text: string): Box {\n if (isDeleted(id)) return id;\n id.text = text;\n return id;\n}\n\n/**\n * Sets the text color.\n *\n * @param id - Box object to modify\n * @param textColor - New text color\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_color(box, '#FFFFFF'); // White text\n * ```\n */\nexport function set_text_color(id: Box, textColor: color): Box {\n if (isDeleted(id)) return id;\n id.text_color = textColor;\n return id;\n}\n\n/**\n * Sets the text size.\n *\n * @param id - Box object to modify\n * @param size - New text size\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_size(box, 'large'); // Larger text\n * ```\n */\nexport function set_text_size(id: Box, size: string | number): Box {\n if (isDeleted(id)) return id;\n id.text_size = size;\n return id;\n}\n\n/**\n * Sets the horizontal text alignment.\n *\n * @param id - Box object to modify\n * @param align - New horizontal alignment\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_halign(box, 'center'); // Center text horizontally\n * ```\n */\nexport function set_text_halign(id: Box, align: 'left' | 'center' | 'right'): Box {\n if (isDeleted(id)) return id;\n id.text_halign = align;\n return id;\n}\n\n/**\n * Sets the vertical text alignment.\n *\n * @param id - Box object to modify\n * @param align - New vertical alignment\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_valign(box, 'center'); // Center text vertically\n * ```\n */\nexport function set_text_valign(id: Box, align: 'top' | 'center' | 'bottom'): Box {\n if (isDeleted(id)) return id;\n id.text_valign = align;\n return id;\n}\n\n/**\n * Sets the text wrapping mode.\n *\n * @param id - Box object to modify\n * @param wrap - New text wrap mode\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_wrap(box, 'auto'); // Enable text wrapping\n * ```\n */\nexport function set_text_wrap(id: Box, wrap: 'none' | 'auto'): Box {\n if (isDeleted(id)) return id;\n id.text_wrap = wrap;\n return id;\n}\n\n/**\n * Sets the text font family.\n *\n * @param id - Box object to modify\n * @param font - New font family\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_font_family(box, 'monospace'); // Monospace font\n * ```\n */\nexport function set_text_font_family(id: Box, font: 'default' | 'monospace'): Box {\n if (isDeleted(id)) return id;\n id.text_font_family = font;\n return id;\n}\n\n/**\n * Deletes the box object.\n *\n * @param id - Box object to delete\n *\n * @remarks\n * Removes the box from `box.all()`. As in PineScript, the deleted box is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect.\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.delete(box);\n * // box.all() no longer contains it\n * ```\n */\nexport function delete_box(id: Box): void {\n remove('box', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live boxes, in creation order (PineScript `box.all`). A new array.\n */\nexport function all(): Box[] {\n return allDrawings('box');\n}\n\n/**\n * Sets the left and top borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).\n */\nexport function set_top_left_point(id: Box, point: ChartPoint): Box {\n if (isDeleted(id)) return id;\n id.left = pointX(point, id.xloc);\n id.top = point.price;\n return id;\n}\n\n/**\n * Sets the right and bottom borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).\n */\nexport function set_bottom_right_point(id: Box, point: ChartPoint): Box {\n if (isDeleted(id)) return id;\n id.right = pointX(point, id.xloc);\n id.bottom = point.price;\n return id;\n}\n\n/**\n * Sets the text formatting: `text.format_none`, `text.format_bold`, `text.format_italic`,\n * or `text.format_bold + text.format_italic`.\n */\nexport function set_text_formatting(id: Box, formatting: number): Box {\n if (isDeleted(id)) return id;\n id.text_formatting = formatting;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_box as new };\nexport { delete_box as delete };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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D,SAAO,KAAK;AACd;AAKO,SAAS,MAAa;AAC3B,aAAO,gBAAAC,KAAY,KAAK;AAC1B;AAKO,SAAS,mBAAmB,IAAS,OAAwB;AAClE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,OAAO,OAAO,OAAO,GAAG,IAAI;AAC/B,KAAG,MAAM,MAAM;AACf,SAAO;AACT;AAKO,SAAS,uBAAuB,IAAS,OAAwB;AACtE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,QAAQ,OAAO,OAAO,GAAG,IAAI;AAChC,KAAG,SAAS,MAAM;AAClB,SAAO;AACT;AAMO,SAAS,oBAAoB,IAAS,YAAyB;AACpE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,kBAAkB;AACrB,SAAO;AACT;",
4
+ "sourcesContent": ["/**\n * Box namespace\n * Functions for creating and manipulating box drawing objects.\n *\n * @remarks\n * Box objects represent rectangular areas on the chart. The getter functions\n * (get_top, get_bottom, get_left, get_right) enable computational use cases like:\n * - Gap detection and tracking (detecting when price fills gaps)\n * - Range breakout analysis (detecting when price breaks out of consolidation)\n * - Rectangle pattern recognition\n *\n * @version 6\n */\n\nimport { all as allDrawings, checkBarIndex, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Box, color } from '../types/index.js';\n\ntype BoxXloc = 'bar_index' | 'bar_time';\ntype BoxExtend = 'none' | 'left' | 'right' | 'both';\n\n/**\n * Creates a new box (PineScript `box.new`), with two chart points or with coordinates, in PineScript's\n * parameter order:\n *\n * - `box.new(top_left, bottom_right, border_color?, border_width?, border_style?, extend?, xloc?, bgcolor?,\n * text?, text_size?, text_color?, text_halign?, text_valign?, text_wrap?, text_font_family?,\n * force_overlay?, text_formatting?)`\n * - `box.new(left, top, right, bottom, border_color?, border_width?, border_style?, extend?, xloc?, ...)`\n *\n * With chart points, x is `point.index` for `bar_index` boxes and `point.time` for `bar_time` boxes.\n *\n * @example\n * ```typescript\n * // Gap box from bar 10 to 20, between 100 and 105, extended to the right\n * const gap = box.new(10, 105, 20, 100, '#2196F3', 1, 'solid', 'right');\n * ```\n */\nexport function new_box(\n top_left: ChartPoint,\n bottom_right: ChartPoint,\n border_color?: color,\n border_width?: number,\n border_style?: 'solid' | 'dotted' | 'dashed',\n extend?: BoxExtend,\n xloc?: BoxXloc,\n bgcolor?: color,\n text?: string,\n text_size?: string | number,\n text_color?: color,\n text_halign?: 'left' | 'center' | 'right',\n text_valign?: 'top' | 'center' | 'bottom',\n text_wrap?: 'none' | 'auto',\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Box;\nexport function new_box(\n left: number,\n top: number,\n right: number,\n bottom: number,\n border_color?: color,\n border_width?: number,\n border_style?: 'solid' | 'dotted' | 'dashed',\n extend?: BoxExtend,\n xloc?: BoxXloc,\n bgcolor?: color,\n text?: string,\n text_size?: string | number,\n text_color?: color,\n text_halign?: 'left' | 'center' | 'right',\n text_valign?: 'top' | 'center' | 'bottom',\n text_wrap?: 'none' | 'auto',\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Box;\nexport function new_box(...args: unknown[]): Box {\n let left: number, top: number, right: number, bottom: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const [tl, br, ...others] = args as [ChartPoint, ChartPoint, ...unknown[]];\n const xloc = (others[4] as BoxXloc | undefined) ?? 'bar_index';\n [left, top, right, bottom, rest] = [pointX(tl, xloc), tl.price, pointX(br, xloc), br.price, others];\n } else {\n [left, top, right, bottom] = args as [number, number, number, number];\n rest = args.slice(4);\n }\n const [border_color, border_width, border_style, extend, xloc, bgcolor, text, text_size, text_color,\n text_halign, text_valign, text_wrap, text_font_family, force_overlay, text_formatting] = rest as [\n color?, number?, ('solid' | 'dotted' | 'dashed')?, BoxExtend?, BoxXloc?, color?, string?,\n (string | number)?, color?, ('left' | 'center' | 'right')?, ('top' | 'center' | 'bottom')?,\n ('none' | 'auto')?, ('default' | 'monospace')?, boolean?, number?,\n ];\n checkBarIndex('box.new', 'left', left, xloc);\n checkBarIndex('box.new', 'right', right, xloc);\n return register('box', {\n left,\n top,\n right,\n bottom,\n xloc: xloc ?? 'bar_index',\n extend: extend ?? 'none',\n border_color,\n border_width: border_width ?? 1,\n border_style: border_style || 'solid',\n bgcolor,\n text,\n text_size,\n text_color,\n text_halign,\n text_valign,\n text_wrap,\n text_font_family,\n force_overlay: force_overlay ?? false,\n text_formatting,\n });\n}\n\n/**\n * Returns the left border x coordinate.\n *\n * @param id - Box object\n * @returns Left border coordinate (bar index or timestamp)\n *\n * @remarks\n * **COMPUTATIONAL USE**: Calculate gap duration, validate range timeframes\n *\n * @example\n * ```typescript\n * const gap = box.new(10, 105, 20, 100);\n * const currentBar = 30;\n * const duration = currentBar - box.get_left(gap); // Returns 20\n *\n * if (duration > 50) {\n * console.log('Gap has been open for 50+ bars');\n * }\n * ```\n */\nexport function get_left(id: Box): number {\n return id.left;\n}\n\n/**\n * Returns the right border x coordinate.\n *\n * @param id - Box object\n * @returns Right border coordinate (bar index or timestamp)\n *\n * @remarks\n * **COMPUTATIONAL USE**: Calculate gap duration, update trailing edges\n *\n * @example\n * ```typescript\n * const range = box.new(100, 155, 150, 145);\n * const width = box.get_right(range) - box.get_left(range); // Returns 50 bars\n * ```\n */\nexport function get_right(id: Box): number {\n return id.right;\n}\n\n/**\n * Returns the top border price level.\n *\n * @param id - Box object\n * @returns Top border price\n *\n * @remarks\n * **COMPUTATIONAL USE**: Detect breakouts above resistance, check gap fills\n *\n * @example\n * ```typescript\n * const gap = box.new(10, 105, 20, 100); // Bearish gap\n *\n * // Check if price has filled gap from below\n * const high = 106;\n * if (high > box.get_top(gap)) {\n * console.log('Gap completely filled!');\n * }\n * ```\n */\nexport function get_top(id: Box): number {\n return id.top;\n}\n\n/**\n * Returns the bottom border price level.\n *\n * @param id - Box object\n * @returns Bottom border price\n *\n * @remarks\n * **COMPUTATIONAL USE**: Detect breakouts below support, check gap fills\n *\n * @example\n * ```typescript\n * const gap = box.new(10, 105, 20, 100); // Bearish gap\n *\n * // Check if price has touched gap from above\n * const low = 104;\n * if (low < box.get_top(gap) && low > box.get_bottom(gap)) {\n * console.log('Price entered the gap!');\n * }\n * ```\n */\nexport function get_bottom(id: Box): number {\n return id.bottom;\n}\n\n/**\n * Creates a copy of the box object.\n *\n * @param id - Box object to copy\n * @returns New box object with same properties\n *\n * @remarks\n * Creates a shallow copy of the box. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const originalBox = box.new(10, 105, 20, 100);\n * const copiedBox = box.copy(originalBox);\n *\n * // Modify copy without affecting original\n * copiedBox.top = 110;\n * ```\n */\nexport function copy(id: Box): Box {\n return register('box', { ...id });\n}\n\n// =============================================================================\n// COORDINATE SETTERS\n// =============================================================================\n\n/**\n * Sets the left border x coordinate.\n *\n * @param id - Box object to modify\n * @param left - New left border coordinate\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_left(box, 15); // Move left edge to bar 15\n * ```\n */\nexport function set_left(id: Box, left: number): Box {\n if (isDeleted(id)) return id;\n checkBarIndex('box.set_(left*/xloc)', 'left', left, id.xloc);\n id.left = left;\n return id;\n}\n\n/**\n * Sets the right border x coordinate.\n *\n * @param id - Box object to modify\n * @param right - New right border coordinate\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_right(box, 25); // Move right edge to bar 25\n * ```\n */\nexport function set_right(id: Box, right: number): Box {\n if (isDeleted(id)) return id;\n checkBarIndex('box.set_(right*/xlock)', 'right', right, id.xloc);\n id.right = right;\n return id;\n}\n\n/**\n * Sets the top border price level.\n *\n * @param id - Box object to modify\n * @param top - New top border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_top(box, 110); // Move top edge to price 110\n * ```\n */\nexport function set_top(id: Box, top: number): Box {\n if (isDeleted(id)) return id;\n id.top = top;\n return id;\n}\n\n/**\n * Sets the bottom border price level.\n *\n * @param id - Box object to modify\n * @param bottom - New bottom border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_bottom(box, 95); // Move bottom edge to price 95\n * ```\n */\nexport function set_bottom(id: Box, bottom: number): Box {\n if (isDeleted(id)) return id;\n id.bottom = bottom;\n return id;\n}\n\n/**\n * Sets the left and top coordinates.\n *\n * @param id - Box object to modify\n * @param left - New left border coordinate\n * @param top - New top border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_lefttop(box, 12, 108); // Move top-left corner\n * ```\n */\nexport function set_lefttop(id: Box, left: number, top: number): Box {\n if (isDeleted(id)) return id;\n checkBarIndex('box.set_(left*/xloc)', 'left', left, id.xloc);\n id.left = left;\n id.top = top;\n return id;\n}\n\n/**\n * Sets the right and bottom coordinates.\n *\n * @param id - Box object to modify\n * @param right - New right border coordinate\n * @param bottom - New bottom border price\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_rightbottom(box, 25, 98); // Move bottom-right corner\n * ```\n */\nexport function set_rightbottom(id: Box, right: number, bottom: number): Box {\n if (isDeleted(id)) return id;\n checkBarIndex('box.set_(right*/xlock)', 'right', right, id.xloc);\n id.right = right;\n id.bottom = bottom;\n return id;\n}\n\n/**\n * Sets the coordinate system for the box.\n *\n * @param id - Box object to modify\n * @param left - New left border coordinate\n * @param right - New right border coordinate\n * @param xloc - New coordinate system ('bar_index' or 'bar_time')\n * @returns Modified box object\n *\n * @remarks\n * When changing xloc, you must provide appropriate x coordinates for the new system.\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * // Change to timestamp-based coordinates\n * box.set_xloc(box, 1609459200000, 1609545600000, 'bar_time');\n * ```\n */\nexport function set_xloc(id: Box, left: number, right: number, xloc: 'bar_index' | 'bar_time'): Box {\n if (isDeleted(id)) return id;\n id.left = left;\n id.right = right;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the horizontal extension mode.\n *\n * @param id - Box object to modify\n * @param extend - New extension mode\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_extend(box, 'right'); // Extend box to the right\n * ```\n */\nexport function set_extend(id: Box, extend: 'none' | 'left' | 'right' | 'both'): Box {\n if (isDeleted(id)) return id;\n id.extend = extend;\n return id;\n}\n\n// =============================================================================\n// STYLING SETTERS\n// =============================================================================\n\n/**\n * Sets the border color.\n *\n * @param id - Box object to modify\n * @param borderColor - New border color\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_border_color(box, '#FF0000'); // Red border\n * ```\n */\nexport function set_border_color(id: Box, borderColor: color): Box {\n if (isDeleted(id)) return id;\n id.border_color = borderColor;\n return id;\n}\n\n/**\n * Sets the border width.\n *\n * @param id - Box object to modify\n * @param width - New border width in pixels\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_border_width(box, 2); // Thicker border\n * ```\n */\nexport function set_border_width(id: Box, width: number): Box {\n if (isDeleted(id)) return id;\n id.border_width = width;\n return id;\n}\n\n/**\n * Sets the border style.\n *\n * @param id - Box object to modify\n * @param style - New border style\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_border_style(box, 'dashed'); // Dashed border\n * ```\n */\nexport function set_border_style(id: Box, style: 'solid' | 'dotted' | 'dashed'): Box {\n if (isDeleted(id)) return id;\n id.border_style = style;\n return id;\n}\n\n/**\n * Sets the background fill color.\n *\n * @param id - Box object to modify\n * @param bgColor - New background color\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_bgcolor(box, '#00FF0030'); // Transparent green fill\n * ```\n */\nexport function set_bgcolor(id: Box, bgColor: color): Box {\n if (isDeleted(id)) return id;\n id.bgcolor = bgColor;\n return id;\n}\n\n// =============================================================================\n// TEXT SETTERS\n// =============================================================================\n\n/**\n * Sets the text content.\n *\n * @param id - Box object to modify\n * @param text - New text content\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text(box, 'Gap Filled'); // Update text\n * ```\n */\nexport function set_text(id: Box, text: string): Box {\n if (isDeleted(id)) return id;\n id.text = text;\n return id;\n}\n\n/**\n * Sets the text color.\n *\n * @param id - Box object to modify\n * @param textColor - New text color\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_color(box, '#FFFFFF'); // White text\n * ```\n */\nexport function set_text_color(id: Box, textColor: color): Box {\n if (isDeleted(id)) return id;\n id.text_color = textColor;\n return id;\n}\n\n/**\n * Sets the text size.\n *\n * @param id - Box object to modify\n * @param size - New text size\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_size(box, 'large'); // Larger text\n * ```\n */\nexport function set_text_size(id: Box, size: string | number): Box {\n if (isDeleted(id)) return id;\n id.text_size = size;\n return id;\n}\n\n/**\n * Sets the horizontal text alignment.\n *\n * @param id - Box object to modify\n * @param align - New horizontal alignment\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_halign(box, 'center'); // Center text horizontally\n * ```\n */\nexport function set_text_halign(id: Box, align: 'left' | 'center' | 'right'): Box {\n if (isDeleted(id)) return id;\n id.text_halign = align;\n return id;\n}\n\n/**\n * Sets the vertical text alignment.\n *\n * @param id - Box object to modify\n * @param align - New vertical alignment\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_valign(box, 'center'); // Center text vertically\n * ```\n */\nexport function set_text_valign(id: Box, align: 'top' | 'center' | 'bottom'): Box {\n if (isDeleted(id)) return id;\n id.text_valign = align;\n return id;\n}\n\n/**\n * Sets the text wrapping mode.\n *\n * @param id - Box object to modify\n * @param wrap - New text wrap mode\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_wrap(box, 'auto'); // Enable text wrapping\n * ```\n */\nexport function set_text_wrap(id: Box, wrap: 'none' | 'auto'): Box {\n if (isDeleted(id)) return id;\n id.text_wrap = wrap;\n return id;\n}\n\n/**\n * Sets the text font family.\n *\n * @param id - Box object to modify\n * @param font - New font family\n * @returns Modified box object\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.set_text_font_family(box, 'monospace'); // Monospace font\n * ```\n */\nexport function set_text_font_family(id: Box, font: 'default' | 'monospace'): Box {\n if (isDeleted(id)) return id;\n id.text_font_family = font;\n return id;\n}\n\n/**\n * Deletes the box object.\n *\n * @param id - Box object to delete\n *\n * @remarks\n * Removes the box from `box.all()`. As in PineScript, the deleted box is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect.\n *\n * @example\n * ```typescript\n * const box = box.new(10, 105, 20, 100);\n * box.delete(box);\n * // box.all() no longer contains it\n * ```\n */\nexport function delete_box(id: Box): void {\n remove('box', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live boxes, in creation order (PineScript `box.all`). A new array.\n */\nexport function all(): Box[] {\n return allDrawings('box');\n}\n\n/**\n * Sets the left and top borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).\n */\nexport function set_top_left_point(id: Box, point: ChartPoint): Box {\n if (isDeleted(id)) return id;\n id.left = pointX(point, id.xloc);\n id.top = point.price;\n return id;\n}\n\n/**\n * Sets the right and bottom borders from a chart point (`point.index` or `point.time` by xloc, and `point.price`).\n */\nexport function set_bottom_right_point(id: Box, point: ChartPoint): Box {\n if (isDeleted(id)) return id;\n id.right = pointX(point, id.xloc);\n id.bottom = point.price;\n return id;\n}\n\n/**\n * Sets the text formatting: `text.format_none`, `text.format_bold`, `text.format_italic`,\n * or `text.format_bold + text.format_italic`.\n */\nexport function set_text_formatting(id: Box, formatting: number): Box {\n if (isDeleted(id)) return id;\n id.text_formatting = formatting;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_box as new };\nexport { delete_box as delete };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,sBAA+E;AA+DxE,SAAS,WAAW,MAAsB;AAC/C,MAAI,MAAc,KAAa,OAAe,QAAgB;AAC9D,MAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AACnD,UAAM,CAAC,IAAI,IAAI,GAAG,MAAM,IAAI;AAC5B,UAAMA,QAAQ,OAAO,CAAC,KAA6B;AACnD,KAAC,MAAM,KAAK,OAAO,QAAQ,IAAI,IAAI,CAAC,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,MAAM;AAAA,EACpG,OAAO;AACL,KAAC,MAAM,KAAK,OAAO,MAAM,IAAI;AAC7B,WAAO,KAAK,MAAM,CAAC;AAAA,EACrB;AACA,QAAM;AAAA,IAAC;AAAA,IAAc;AAAA,IAAc;AAAA,IAAc;AAAA,IAAQ;AAAA,IAAM;AAAA,IAAS;AAAA,IAAM;AAAA,IAAW;AAAA,IACvF;AAAA,IAAa;AAAA,IAAa;AAAA,IAAW;AAAA,IAAkB;AAAA,IAAe;AAAA,EAAe,IAAI;AAK3F,qCAAc,WAAW,QAAQ,MAAM,IAAI;AA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AU,EAAE,EAAG,QAAO;AAC1B,KAAG,YAAY;AACf,SAAO;AACT;AAeO,SAAS,gBAAgB,IAAS,OAAyC;AAChF,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,cAAc;AACjB,SAAO;AACT;AAeO,SAAS,gBAAgB,IAAS,OAAyC;AAChF,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,cAAc;AACjB,SAAO;AACT;AAeO,SAAS,cAAc,IAAS,MAA4B;AACjE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,YAAY;AACf,SAAO;AACT;AAeO,SAAS,qBAAqB,IAAS,MAAoC;AAChF,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,mBAAmB;AACtB,SAAO;AACT;AAkBO,SAAS,WAAW,IAAe;AACxC,8BAAO,OAAO,EAAE;AAClB;AAGA,SAAS,OAAO,OAAmB,MAAwC;AACzE,QAAM,IAAI,SAAS,aAAa,MAAM,OAAO,MAAM;AACnD,SAAO,KAAK;AACd;AAKO,SAAS,MAAa;AAC3B,aAAO,gBAAAC,KAAY,KAAK;AAC1B;AAKO,SAAS,mBAAmB,IAAS,OAAwB;AAClE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,OAAO,OAAO,OAAO,GAAG,IAAI;AAC/B,KAAG,MAAM,MAAM;AACf,SAAO;AACT;AAKO,SAAS,uBAAuB,IAAS,OAAwB;AACtE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,QAAQ,OAAO,OAAO,GAAG,IAAI;AAChC,KAAG,SAAS,MAAM;AAClB,SAAO;AACT;AAMO,SAAS,oBAAoB,IAAS,YAAyB;AACpE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,kBAAkB;AACrB,SAAO;AACT;",
6
6
  "names": ["xloc", "allDrawings"]
7
7
  }
@@ -9,10 +9,11 @@
9
9
  * - {@link whenCalled}: vectorized, when the bars of the calls are known in advance.
10
10
  * - {@link crossover} / {@link crossunder} / {@link cross} / {@link barssince}: one stateful call site for bar
11
11
  * loops, called only on the bars where the Pine call runs.
12
- * - {@link lowest} / {@link highest}: `ta.lowest` / `ta.highest` with a series length (a different length on each
13
- * call), which PineScript computes with a state kept between calls.
14
- * - {@link lowestByBar} / {@link highestByBar} / {@link linreg}: `ta.lowest` / `ta.highest` / `ta.linreg` in a
15
- * conditional block, whose history is kept by bar (not by call).
12
+ * - {@link lowestByBar} / {@link highestByBar} / {@link lowestbars} / {@link highestbars} / {@link pivothigh} /
13
+ * {@link pivotlow}: `ta.lowest` / `ta.highest` / `ta.lowestbars` / `ta.highestbars` / `ta.pivothigh` /
14
+ * `ta.pivotlow` in a conditional block or a loop, also with a length that changes on each call. They keep the
15
+ * non-na values of their calls; {@link lowest} / {@link highest} are the same sites called with `(value, length)`.
16
+ * - {@link linreg}: `ta.linreg` in a conditional block, whose history is kept by bar (not by call).
16
17
  * - {@link sum} / {@link sma}: `math.sum` / `ta.sma` in a `for` / `while` loop, called several times on one bar.
17
18
  *
18
19
  * Since PineScript v6, `and` / `or` are lazy: the right operand runs only when the left operand does not decide
@@ -74,16 +75,9 @@ export declare function barssince(): (condition: boolean | number) => number;
74
75
  */
75
76
  export declare function cross(): (a: number, b: number) => boolean;
76
77
  /**
77
- * One `ta.lowest(source, length)` call site with a series length (a different length on each call), called with
78
- * `(value, length)`.
79
- *
80
- * PineScript rules (measured with a length that changes on each bar):
81
- * - the extreme is kept with its bar; a new value that passes it replaces it; when the kept extreme is `length`
82
- * calls old, the last `length` values are scanned again (na skipped, the oldest wins a tie)
83
- * - a length smaller than on the previous call: the last `length` values are scanned again
84
- * - a length larger than on the previous call: the values that enter the window at its old end are compared with the
85
- * extreme; when one of them is na, the extreme restarts from the current value (the values in between are not read)
86
- * - an na value gives na and resets the extreme; na before call `length - 1`
78
+ * One `ta.lowest(source, length)` call site, called with `(value, length, barIndex?)`: the same site as
79
+ * {@link lowestByBar} (same rules). Pass the bar index when the call does not run on every bar; without it every
80
+ * call counts as one bar, which is right for a call on every bar (for example with a length that changes).
87
81
  *
88
82
  * @example
89
83
  * ```typescript
@@ -92,26 +86,28 @@ export declare function cross(): (a: number, b: number) => boolean;
92
86
  * const out = closes.map((_, i) => lowPrice(i > 0 ? closes[i - 1]! : NaN, lookback[i]!));
93
87
  * ```
94
88
  */
95
- export declare function lowest(): (value: number, length: number) => number;
89
+ export declare function lowest(): (value: number, length: number, barIndex?: number) => number;
96
90
  /**
97
- * One `ta.highest(source, length)` call site with a series length (a different length on each call), called with
98
- * `(value, length)`. Same rules as {@link lowest}.
91
+ * One `ta.highest(source, length)` call site, called with `(value, length, barIndex?)`. Same rules as
92
+ * {@link lowest}.
99
93
  */
100
- export declare function highest(): (value: number, length: number) => number;
94
+ export declare function highest(): (value: number, length: number, barIndex?: number) => number;
101
95
  /**
102
- * One `ta.lowest(source, length)` call site in a conditional block whose history is kept by bar (not by call), called
103
- * with `(barIndex, value, length)` on the bars where the Pine call runs.
96
+ * One `ta.lowest(source, length)` call site in a conditional block or a loop, called with
97
+ * `(barIndex, value, length)` on the bars (and loop turns) where the Pine call runs. The length can change from one
98
+ * call to the next.
104
99
  *
105
- * PineScript rules (measured on a call in a ternary branch, length 6):
106
- * - the values are kept in a ring of `length + 1` slots indexed by the bar index, filled with 0 at the start and
107
- * written only on the bars where the call runs: a bar before the first call counts as 0, and a bar without a call
108
- * holds the value of the call `length + 1` bars earlier (0 if there was none)
109
- * - on a call, the value replaces the kept extreme when there is none or when it is strictly lower; only otherwise,
110
- * when the kept extreme is `length` bars old, the last `length` bars are read again from the ring (the oldest bar
111
- * wins a tie)
112
- * - na before bar `length - 1` (by bar, not by call)
100
+ * PineScript rules (measured in `if` blocks, ternaries, user functions and `for` loops, with constant lengths and
101
+ * lengths that change, on sources with and without na):
102
+ * - the call site keeps the non-na values it received, each with its bar; nothing is kept for a bar without a call
103
+ * or for an na value
104
+ * - the result is na while `barIndex < length - 1` (by bar, not by call) and while no value was received
105
+ * - otherwise it is the lowest of the last `length` kept values, or of all of them when there are fewer: the first
106
+ * call after bar `length - 1` gives its own value. A call with an na value also gives this result
107
+ * - in a loop (several calls on one bar), a bar has one kept value: each call replaces the value of the earlier
108
+ * calls of that bar, so a call gives the lowest of its value and the values of the bars before
113
109
  *
114
- * {@link lowest} keeps the history by call instead; both rules were measured, on different scripts.
110
+ * Called on every bar, it equals `ta.lowest`.
115
111
  *
116
112
  * @example
117
113
  * ```typescript
@@ -122,11 +118,56 @@ export declare function highest(): (value: number, length: number) => number;
122
118
  */
123
119
  export declare function lowestByBar(): (barIndex: number, value: number, length: number) => number;
124
120
  /**
125
- * One `ta.highest(source, length)` call site in a conditional block whose history is kept by bar, called with
126
- * `(barIndex, value, length)`. Same rules as {@link lowestByBar} (a value replaces the kept extreme when it is
127
- * strictly higher).
121
+ * One `ta.highest(source, length)` call site in a conditional block or a loop, called with
122
+ * `(barIndex, value, length)`. Same rules as {@link lowestByBar}.
128
123
  */
129
124
  export declare function highestByBar(): (barIndex: number, value: number, length: number) => number;
125
+ /**
126
+ * One `ta.lowestbars(source, length)` call site in a conditional block or a loop, called with
127
+ * `(barIndex, value, length)`: the offset (0 or negative) from this bar to the bar of the lowest of the last `length`
128
+ * kept values, the newest one on equal values. The values are kept as in {@link lowestByBar}; the offset counts
129
+ * bars, not calls, so it can be below `-(length - 1)`.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * // Pine: off = cond ? ta.lowestbars(low, 10) : na
134
+ * const site = callsite.lowestbars();
135
+ * const off = lows.map((v, i) => (cond[i] ? site(i, v, 10) : NaN));
136
+ * ```
137
+ */
138
+ export declare function lowestbars(): (barIndex: number, value: number, length: number) => number;
139
+ /**
140
+ * One `ta.highestbars(source, length)` call site in a conditional block or a loop, called with
141
+ * `(barIndex, value, length)`. Same rules as {@link lowestbars}.
142
+ */
143
+ export declare function highestbars(): (barIndex: number, value: number, length: number) => number;
144
+ /**
145
+ * One `ta.pivothigh(source, leftbars, rightbars)` call site in a conditional block, called with
146
+ * `(barIndex, value, leftbars, rightbars)` on the bars where the Pine call runs. The lengths can change from one call
147
+ * to the next (the lengths of the current call are used).
148
+ *
149
+ * PineScript rules (measured in `if` blocks and ternaries, and on sources with na):
150
+ * - the call site keeps the non-na values it received, each with its bar
151
+ * - on a call it takes the last `leftbars + rightbars + 1` kept values (all of them when there are fewer) and finds
152
+ * the highest, the newest one on equal values
153
+ * - there is a pivot only when that value is on the bar `rightbars` BARS back (by bar index, not by call); the
154
+ * result is its value, na otherwise and before bar `leftbars + rightbars`
155
+ *
156
+ * Called on every bar, it equals `ta.pivothigh`.
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * // Pine: ph = useFilter ? ta.pivothigh(src, 5, 5) : na
161
+ * const site = callsite.pivothigh();
162
+ * const ph = src.map((v, i) => (useFilter[i] ? site(i, v, 5, 5) : NaN));
163
+ * ```
164
+ */
165
+ export declare function pivothigh(): (barIndex: number, value: number, leftbars: number, rightbars: number) => number;
166
+ /**
167
+ * One `ta.pivotlow(source, leftbars, rightbars)` call site in a conditional block, called with
168
+ * `(barIndex, value, leftbars, rightbars)`. Same rules as {@link pivothigh} (the lowest value).
169
+ */
170
+ export declare function pivotlow(): (barIndex: number, value: number, leftbars: number, rightbars: number) => number;
130
171
  /**
131
172
  * One `ta.linreg(source, length, offset)` call site in a conditional block, called with
132
173
  * `(barIndex, value, length, offset)` on the bars where the Pine call runs.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/callsite/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,EACnD,MAAM,EAAE,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,EACnC,EAAE,EAAE,CAAC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ars: () => highestbars,
27
28
  linreg: () => linreg,
28
29
  lowest: () => lowest,
29
30
  lowestByBar: () => lowestByBar,
31
+ lowestbars: () => lowestbars,
32
+ pivothigh: () => pivothigh,
33
+ pivotlow: () => pivotlow,
30
34
  random: () => random,
31
35
  sma: () => sma,
32
36
  stdev: () => stdev,
@@ -36,6 +40,7 @@ __export(callsite_exports, {
36
40
  module.exports = __toCommonJS(callsite_exports);
37
41
  var import_ta = require("../ta/index.js");
38
42
  var import_running_sum = require("../ta/running-sum.js");
43
+ var import_limits = require("../ta/limits.js");
39
44
  var import_math = require("../math/index.js");
40
45
  function whenCalled(called, fn, ...sources) {
41
46
  const bars = [];
@@ -83,84 +88,82 @@ function cross() {
83
88
  return result;
84
89
  };
85
90
  }
86
- function extremeSite(isLowest) {
87
- const better = isLowest ? (a, b) => a < b : (a, b) => a > b;
88
- const values = [];
89
- let extreme = NaN;
90
- let extremeAt = -1;
91
- let prevLength = NaN;
92
- const keep = (v, at) => {
93
- extreme = v;
94
- extremeAt = at;
95
- };
96
- const rescan = (i, length) => {
97
- extreme = NaN;
98
- for (let b = i; b > i - length && b >= 0; b--) {
99
- const v = values[b];
100
- if (!Number.isNaN(v) && (Number.isNaN(extreme) || !better(extreme, v))) keep(v, b);
91
+ class KeptCalls {
92
+ values = [];
93
+ bars = [];
94
+ /** Keeps a non-na value; a later call on the same bar (a loop) replaces the value of that bar. */
95
+ add(barIndex, value) {
96
+ if (Number.isNaN(value)) return;
97
+ const last = this.values.length - 1;
98
+ if (last >= 0 && this.bars[last] === barIndex) this.values[last] = value;
99
+ else {
100
+ this.values.push(value);
101
+ this.bars.push(barIndex);
101
102
  }
102
- };
103
- return (value, length) => {
104
- const i = values.length;
105
- values.push(value);
106
- if (Number.isNaN(value)) {
107
- extreme = NaN;
108
- prevLength = length;
109
- return NaN;
103
+ }
104
+ /** Position of the best of the last `count` kept values (the newest one on ties), -1 when there is none. */
105
+ best(count, isLowest) {
106
+ const last = this.values.length - 1;
107
+ if (last < 0 || !(count >= 1)) return -1;
108
+ let best = last;
109
+ for (let k = last - 1; k >= 0 && k > last - count; k--) {
110
+ if (isLowest ? this.values[k] < this.values[best] : this.values[k] > this.values[best]) best = k;
110
111
  }
111
- if (length > prevLength) {
112
- const from = Math.max(0, i - length + 1);
113
- const to = Math.max(0, i - prevLength + 1);
114
- if (values.slice(from, to).some(Number.isNaN)) keep(value, i);
115
- else {
116
- for (let b = from; b < to; b++) if (Number.isNaN(extreme) || better(values[b], extreme)) keep(values[b], b);
117
- if (Number.isNaN(extreme) || better(value, extreme)) keep(value, i);
118
- }
119
- } else if (length < prevLength || Number.isNaN(extreme) || i - extremeAt >= length) rescan(i, length);
120
- else if (better(value, extreme)) keep(value, i);
121
- prevLength = length;
122
- return i < length - 1 ? NaN : extreme;
112
+ return best;
113
+ }
114
+ }
115
+ function extremeByBarSite(isLowest, offsets) {
116
+ const kept = new KeptCalls();
117
+ const name = (isLowest ? "lowest" : "highest") + (offsets ? "bars" : "");
118
+ return (barIndex, value, length) => {
119
+ (0, import_limits.checkWindowLength)(name, length, barIndex);
120
+ kept.add(barIndex, value);
121
+ const len = Math.trunc(length);
122
+ if (barIndex < len - 1) return NaN;
123
+ const best = kept.best(len, isLowest);
124
+ if (best < 0) return NaN;
125
+ return offsets ? -(barIndex - kept.bars[best]) : kept.values[best];
123
126
  };
124
127
  }
128
+ function extremeSite(isLowest) {
129
+ const site = extremeByBarSite(isLowest, false);
130
+ let calls = 0;
131
+ return (value, length, barIndex) => site(barIndex ?? calls++, value, length);
132
+ }
125
133
  function lowest() {
126
134
  return extremeSite(true);
127
135
  }
128
136
  function highest() {
129
137
  return extremeSite(false);
130
138
  }
131
- function extremeByBarSite(isLowest) {
132
- const better = isLowest ? (a, b) => a < b : (a, b) => a > b;
133
- let ring = [];
134
- let extreme = NaN;
135
- let extremeAt = -1;
136
- return (barIndex, value, length) => {
137
- const len = Math.floor(length);
138
- if (ring.length !== len + 1) {
139
- ring = new Array(len + 1).fill(0);
140
- extreme = NaN;
141
- }
142
- ring[barIndex % (len + 1)] = value;
143
- if (Number.isNaN(extreme) || better(value, extreme)) {
144
- extreme = value;
145
- extremeAt = barIndex;
146
- } else if (barIndex - extremeAt >= len) {
147
- extreme = NaN;
148
- for (let b = barIndex - len + 1; b <= barIndex; b++) {
149
- const v = ring[b % (len + 1)];
150
- if (!Number.isNaN(v) && (Number.isNaN(extreme) || better(v, extreme))) {
151
- extreme = v;
152
- extremeAt = b;
153
- }
154
- }
155
- }
156
- return barIndex < len - 1 ? NaN : extreme;
157
- };
158
- }
159
139
  function lowestByBar() {
160
- return extremeByBarSite(true);
140
+ return extremeByBarSite(true, false);
161
141
  }
162
142
  function highestByBar() {
163
- return extremeByBarSite(false);
143
+ return extremeByBarSite(false, false);
144
+ }
145
+ function lowestbars() {
146
+ return extremeByBarSite(true, true);
147
+ }
148
+ function highestbars() {
149
+ return extremeByBarSite(false, true);
150
+ }
151
+ function pivotSite(isLowest) {
152
+ const kept = new KeptCalls();
153
+ return (barIndex, value, leftbars, rightbars) => {
154
+ kept.add(barIndex, value);
155
+ const left = Math.trunc(leftbars);
156
+ const right = Math.trunc(rightbars);
157
+ if (!(barIndex >= left + right)) return NaN;
158
+ const best = kept.best(left + right + 1, isLowest);
159
+ return best >= 0 && kept.bars[best] === barIndex - right ? kept.values[best] : NaN;
160
+ };
161
+ }
162
+ function pivothigh() {
163
+ return pivotSite(false);
164
+ }
165
+ function pivotlow() {
166
+ return pivotSite(true);
164
167
  }
165
168
  function linreg() {
166
169
  let ring = [];
@@ -181,6 +184,7 @@ function loopSumSite(name, squares) {
181
184
  return (barIndex, value, length) => {
182
185
  const len = Math.floor(length);
183
186
  if (!(len >= 1)) throw new Error(`callsite.${name}: length must be at least 1 (got ${length})`);
187
+ (0, import_limits.checkSumLength)(name === "sum" ? "math.sum" : `ta.${name}`, len, barIndex);
184
188
  if (barIndex !== lastBar) {
185
189
  if (pending) {
186
190
  running.commit();