oakscriptjs 0.19.0 → 0.20.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.
- package/dist/cjs/box/index.d.ts +3 -3
- package/dist/cjs/box/index.d.ts.map +1 -1
- package/dist/cjs/box/index.js.map +2 -2
- package/dist/cjs/drawing/output.d.ts +2 -1
- package/dist/cjs/drawing/output.d.ts.map +1 -1
- package/dist/cjs/drawing/output.js +5 -4
- package/dist/cjs/drawing/output.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/label/index.d.ts +2 -2
- package/dist/cjs/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/line/index.d.ts +4 -4
- package/dist/cjs/line/index.d.ts.map +1 -1
- package/dist/cjs/line/index.js +1 -1
- package/dist/cjs/line/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +2 -2
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/script/constants.d.ts +6 -1
- package/dist/cjs/script/constants.d.ts.map +1 -1
- package/dist/cjs/script/constants.js +2 -1
- package/dist/cjs/script/constants.js.map +2 -2
- package/dist/cjs/script/index.d.ts +44 -17
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +54 -5
- package/dist/cjs/script/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +13 -11
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +3 -1
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/types/metadata.d.ts +12 -8
- package/dist/cjs/types/metadata.d.ts.map +1 -1
- package/dist/cjs/types/metadata.js.map +1 -1
- package/dist/esm/box/index.d.ts +3 -3
- package/dist/esm/box/index.d.ts.map +1 -1
- package/dist/esm/box/index.js +1 -1
- package/dist/esm/box/index.js.map +1 -1
- package/dist/esm/drawing/output.d.ts +2 -1
- package/dist/esm/drawing/output.d.ts.map +1 -1
- package/dist/esm/drawing/output.js +9 -7
- package/dist/esm/drawing/output.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/label/index.d.ts +2 -2
- package/dist/esm/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/line/index.d.ts +4 -4
- package/dist/esm/line/index.d.ts.map +1 -1
- package/dist/esm/line/index.js +3 -3
- package/dist/esm/line/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +2 -2
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +1 -1
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/script/constants.d.ts +6 -1
- package/dist/esm/script/constants.d.ts.map +1 -1
- package/dist/esm/script/constants.js +6 -1
- package/dist/esm/script/constants.js.map +1 -1
- package/dist/esm/script/index.d.ts +44 -17
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +56 -3
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +13 -11
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +3 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/metadata.d.ts +12 -8
- package/dist/esm/types/metadata.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/oakscript/reference/pine-differences.md +2 -0
- package/skills/oakscript/reference/plotting.md +24 -1
- package/src/box/index.ts +4 -4
- package/src/drawing/output.ts +12 -8
- package/src/index.ts +1 -1
- package/src/label/index.ts +3 -3
- package/src/line/index.ts +6 -6
- package/src/polyline/index.ts +2 -2
- package/src/script/constants.ts +6 -1
- package/src/script/index.ts +78 -7
- package/src/types/index.ts +13 -11
- package/src/types/metadata.ts +12 -8
package/dist/cjs/box/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @version 6
|
|
13
13
|
*/
|
|
14
14
|
import type { ChartPoint, Box, color } from '../types/index.js';
|
|
15
|
-
type BoxXloc = 'bar_index' | 'bar_time';
|
|
15
|
+
type BoxXloc = 'bar_index' | 'bar_time' | 'pane';
|
|
16
16
|
type BoxExtend = 'none' | 'left' | 'right' | 'both';
|
|
17
17
|
/**
|
|
18
18
|
* Creates a new box (PineScript `box.new`), with two chart points or with coordinates, in PineScript's
|
|
@@ -223,7 +223,7 @@ export declare function set_rightbottom(id: Box, right: number, bottom: number):
|
|
|
223
223
|
* @param id - Box object to modify
|
|
224
224
|
* @param left - New left border coordinate
|
|
225
225
|
* @param right - New right border coordinate
|
|
226
|
-
* @param xloc - New coordinate system ('bar_index' or '
|
|
226
|
+
* @param xloc - New coordinate system ('bar_index', 'bar_time' or 'pane')
|
|
227
227
|
* @returns Modified box object
|
|
228
228
|
*
|
|
229
229
|
* @remarks
|
|
@@ -236,7 +236,7 @@ export declare function set_rightbottom(id: Box, right: number, bottom: number):
|
|
|
236
236
|
* box.set_xloc(box, 1609459200000, 1609545600000, 'bar_time');
|
|
237
237
|
* ```
|
|
238
238
|
*/
|
|
239
|
-
export declare function set_xloc(id: Box, left: number, right: number, xloc: 'bar_index' | 'bar_time'): Box;
|
|
239
|
+
export declare function set_xloc(id: Box, left: number, right: number, xloc: 'bar_index' | 'bar_time' | 'pane'): Box;
|
|
240
240
|
/**
|
|
241
241
|
* Sets the horizontal extension mode.
|
|
242
242
|
*
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/box/index.ts"],"names":[],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AE,MAAM,GAAG,GAAG,CAIpE;AAGD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,CAAC;AAC1B,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -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, 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 left = checkBarIndex('box.new', 'left', left, xloc);\n right = 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 left = 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 right = 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 left = 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 right = 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"],
|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SAAS,OAAO,GAAG,IAAI;AACvE,KAAG,QAAQ;AACX,KAAG,SAAS;AACZ,SAAO;AACT;AAqBO,SAAS,SAAS,IAAS,MAAc,OAAe,
|
|
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' | 'pane';\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 left = checkBarIndex('box.new', 'left', left, xloc);\n right = 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 left = 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 right = 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 left = 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 right = 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', 'bar_time' or 'pane')\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' | 'pane'): 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' | 'pane'): 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;A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AA4B;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,MAAiD;AAClF,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
|
}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* Conversion rules:
|
|
6
6
|
* - x coordinates become bar times: a `bar_index` x is the time of that bar, or of a future bar after the last bar
|
|
7
7
|
* (see {@link barTime}); a `bar_time` x (UNIX ms, as PineScript) is converted to the unit of the bar times and the
|
|
8
|
-
* object keeps `xloc: 'bar_time'` (a renderer places a time after the last bar on the chart's own calendar)
|
|
8
|
+
* object keeps `xloc: 'bar_time'` (a renderer places a time after the last bar on the chart's own calendar); a `pane`
|
|
9
|
+
* x (percent of the pane's width) is kept in the time fields, with `xloc: 'pane'`
|
|
9
10
|
* - an object with an `na` coordinate (or a bar index before the first bar) is not drawn, as in PineScript
|
|
10
11
|
* - a property the script did not set is omitted (the renderer uses the PineScript default); a colour set to `na`
|
|
11
12
|
* is 'transparent'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/drawing/output.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/drawing/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,eAAe,EACf,YAAY,EACZ,YAAY,EAEZ,SAAS,EACV,MAAM,sBAAsB,CAAC;AAE9B,sFAAsF;AACtF,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;CACtB;AAsBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,QAAQ,GAAE,GAAG,GAAG,IAAU,GAAG,cAAc,CAiKhH"}
|
|
@@ -33,11 +33,11 @@ function compact(obj) {
|
|
|
33
33
|
return obj;
|
|
34
34
|
}
|
|
35
35
|
const overlay = (flag) => flag ? true : void 0;
|
|
36
|
-
const xlocOut = (xloc) => xloc === "bar_time"
|
|
36
|
+
const xlocOut = (xloc) => xloc === "bar_time" || xloc === "pane" ? xloc : void 0;
|
|
37
37
|
function drawingOutputs(bars, timeUnit = "s") {
|
|
38
38
|
const interval = (0, import_bar_time.barInterval)(bars);
|
|
39
39
|
const msUnit = timeUnit === "ms" ? 1 : 1e3;
|
|
40
|
-
const xTime = (x, xloc) => xloc === "bar_time" ? x / msUnit : (0, import_bar_time.barTime)(bars, x, interval);
|
|
40
|
+
const xTime = (x, xloc) => xloc === "pane" ? x : xloc === "bar_time" ? x / msUnit : (0, import_bar_time.barTime)(bars, x, interval);
|
|
41
41
|
const ok = (...values) => values.every(Number.isFinite);
|
|
42
42
|
const lineData = (l) => {
|
|
43
43
|
const time1 = xTime(l.x1, l.xloc);
|
|
@@ -58,7 +58,8 @@ function drawingOutputs(bars, timeUnit = "s") {
|
|
|
58
58
|
};
|
|
59
59
|
const labelData = (l) => {
|
|
60
60
|
const time = xTime(l.x, l.xloc);
|
|
61
|
-
|
|
61
|
+
const yloc = l.xloc === "pane" ? "price" : l.yloc;
|
|
62
|
+
if (!ok(time) || yloc === "price" && !ok(l.y)) return void 0;
|
|
62
63
|
return compact({
|
|
63
64
|
time,
|
|
64
65
|
price: l.y,
|
|
@@ -68,7 +69,7 @@ function drawingOutputs(bars, timeUnit = "s") {
|
|
|
68
69
|
textColor: colorOut(l.textcolor),
|
|
69
70
|
style: l.style,
|
|
70
71
|
size: l.size,
|
|
71
|
-
yloc
|
|
72
|
+
yloc,
|
|
72
73
|
textAlign: l.textalign,
|
|
73
74
|
tooltip: l.tooltip,
|
|
74
75
|
fontFamily: l.text_font_family,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/drawing/output.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Renderable form of the live drawing objects (labels, lines, boxes, linefills, polylines, tables): the\n * `IndicatorResult` fields `labels`, `lines`, `boxes`, `linefills`, `polylines` and `tables`.\n *\n * Conversion rules:\n * - x coordinates become bar times: a `bar_index` x is the time of that bar, or of a future bar after the last bar\n * (see {@link barTime}); a `bar_time` x (UNIX ms, as PineScript) is converted to the unit of the bar times and the\n * object keeps `xloc: 'bar_time'` (a renderer places a time after the last bar on the chart's own calendar)
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Renderable form of the live drawing objects (labels, lines, boxes, linefills, polylines, tables): the\n * `IndicatorResult` fields `labels`, `lines`, `boxes`, `linefills`, `polylines` and `tables`.\n *\n * Conversion rules:\n * - x coordinates become bar times: a `bar_index` x is the time of that bar, or of a future bar after the last bar\n * (see {@link barTime}); a `bar_time` x (UNIX ms, as PineScript) is converted to the unit of the bar times and the\n * object keeps `xloc: 'bar_time'` (a renderer places a time after the last bar on the chart's own calendar); a `pane`\n * x (percent of the pane's width) is kept in the time fields, with `xloc: 'pane'`\n * - an object with an `na` coordinate (or a bar index before the first bar) is not drawn, as in PineScript\n * - a property the script did not set is omitted (the renderer uses the PineScript default); a colour set to `na`\n * is 'transparent'\n * - `force_overlay` is kept only when true\n *\n * @module drawing/output\n */\n\nimport { all } from './registry.js';\nimport { barInterval, barTime } from './bar-time.js';\nimport type { Box, ChartPoint, Label, Line, Polyline, Table, color } from '../types/index.js';\nimport type {\n BoxData,\n LabelData,\n LineDrawingData,\n LinefillData,\n PolylineData,\n TableCellData,\n TableData,\n} from '../types/metadata.js';\n\n/** Drawing fields of an IndicatorResult; a kind without live objects is undefined. */\nexport interface DrawingOutputs {\n labels?: LabelData[];\n lines?: LineDrawingData[];\n boxes?: BoxData[];\n linefills?: LinefillData[];\n polylines?: PolylineData[];\n tables?: TableData[];\n}\n\n/** A colour of the result: 'transparent' for na (null), '#rrggbb' for a numeric colour. */\nfunction colorOut(c: color | null | undefined): string | undefined {\n if (c === undefined) return undefined;\n if (c === null || (typeof c === 'number' && Number.isNaN(c))) return 'transparent';\n return typeof c === 'number' ? `#${(c & 0xffffff).toString(16).padStart(6, '0')}` : c;\n}\n\n/** The object without its undefined fields (so that the result has only the properties that were set). */\nfunction compact<T extends object>(obj: T): T {\n for (const k of Object.keys(obj) as Array<keyof T>) if (obj[k] === undefined) delete obj[k];\n return obj;\n}\n\nconst overlay = (flag: boolean | undefined): true | undefined => (flag ? true : undefined);\n\ntype Xloc = 'bar_index' | 'bar_time' | 'pane';\n\n/** xloc of the result: omitted for bar indexes. */\nconst xlocOut = (xloc: Xloc): 'bar_time' | 'pane' | undefined => (xloc === 'bar_time' || xloc === 'pane' ? xloc : undefined);\n\n/**\n * Converts the live drawing objects of the registry. `bars` are the chart bars (their `time` in `timeUnit`, 's' by\n * default as lightweight-charts); they give the time of a bar index.\n */\nexport function drawingOutputs(bars: ReadonlyArray<{ time: number }>, timeUnit: 's' | 'ms' = 's'): DrawingOutputs {\n const interval = barInterval(bars);\n const msUnit = timeUnit === 'ms' ? 1 : 1000;\n const xTime = (x: number, xloc: Xloc): number =>\n xloc === 'pane' ? x : xloc === 'bar_time' ? x / msUnit : barTime(bars, x, interval);\n const ok = (...values: number[]): boolean => values.every(Number.isFinite);\n\n const lineData = (l: Line): LineDrawingData | undefined => {\n const time1 = xTime(l.x1, l.xloc);\n const time2 = xTime(l.x2, l.xloc);\n if (!ok(time1, time2, l.y1, l.y2)) return undefined;\n return compact({\n time1,\n price1: l.y1,\n time2,\n price2: l.y2,\n xloc: xlocOut(l.xloc),\n color: colorOut(l.color),\n width: l.width,\n style: l.style,\n extend: l.extend,\n forceOverlay: overlay(l.force_overlay),\n });\n };\n\n const labelData = (l: Label): LabelData | undefined => {\n const time = xTime(l.x, l.xloc);\n // abovebar / belowbar labels are placed at the bar, not at y; a label placed on the pane has no bar: at y\n const yloc = l.xloc === 'pane' ? 'price' : l.yloc;\n if (!ok(time) || (yloc === 'price' && !ok(l.y))) return undefined;\n return compact({\n time,\n price: l.y,\n xloc: xlocOut(l.xloc),\n text: l.text ?? '',\n color: colorOut(l.color),\n textColor: colorOut(l.textcolor),\n style: l.style,\n size: l.size as LabelData['size'],\n yloc,\n textAlign: l.textalign,\n tooltip: l.tooltip,\n fontFamily: l.text_font_family,\n textFormatting: l.text_formatting,\n forceOverlay: overlay(l.force_overlay),\n });\n };\n\n const boxData = (b: Box): BoxData | undefined => {\n const time1 = xTime(b.left, b.xloc);\n const time2 = xTime(b.right, b.xloc);\n if (!ok(time1, time2, b.top, b.bottom)) return undefined;\n return compact({\n time1,\n price1: b.top,\n time2,\n price2: b.bottom,\n xloc: xlocOut(b.xloc),\n bgColor: colorOut(b.bgcolor),\n borderColor: colorOut(b.border_color),\n borderWidth: b.border_width,\n borderStyle: b.border_style,\n text: b.text,\n textColor: colorOut(b.text_color),\n textSize: b.text_size as BoxData['textSize'],\n textHAlign: b.text_halign,\n textVAlign: b.text_valign,\n textWrap: b.text_wrap,\n fontFamily: b.text_font_family,\n textFormatting: b.text_formatting,\n extend: b.extend,\n forceOverlay: overlay(b.force_overlay),\n });\n };\n\n const polylineData = (p: Polyline): PolylineData | undefined => {\n const points: PolylineData['points'] = [];\n for (const point of p.points as ChartPoint[]) {\n const x = p.xloc === 'bar_time' ? point.time : point.index;\n const time = x === null ? NaN : xTime(x, p.xloc);\n if (ok(time, point.price)) points.push({ time, price: point.price });\n }\n if (points.length === 0) return undefined;\n return compact({\n points,\n xloc: xlocOut(p.xloc),\n curved: p.curved,\n closed: p.closed,\n lineColor: colorOut(p.line_color),\n fillColor: p.fill_color === null ? undefined : colorOut(p.fill_color),\n lineStyle: p.line_style,\n lineWidth: p.line_width,\n forceOverlay: overlay(p.force_overlay),\n });\n };\n\n const tableData = (t: Table): TableData => {\n const cells: TableCellData[] = [];\n for (const [key, c] of t.cells ?? []) {\n const [column, row] = key.split(',').map(Number) as [number, number];\n cells.push(\n compact({\n row,\n column,\n text: c.text ?? '',\n bgColor: colorOut(c.bgcolor),\n textColor: colorOut(c.text_color),\n textSize: c.text_size as TableCellData['textSize'],\n width: c.width,\n height: c.height,\n textHAlign: c.text_halign,\n textVAlign: c.text_valign,\n tooltip: c.tooltip,\n fontFamily: c.text_font_family,\n textFormatting: c.text_formatting,\n })\n );\n }\n cells.sort((a, b) => a.row - b.row || a.column - b.column);\n const merges = (t.merges ?? []).map((m) => ({\n startColumn: m.start_column,\n startRow: m.start_row,\n endColumn: m.end_column,\n endRow: m.end_row,\n }));\n return compact({\n position: t.position,\n columns: t.columns,\n rows: t.rows,\n cells,\n merges: merges.length ? merges : undefined,\n bgColor: colorOut(t.bgcolor),\n frameColor: colorOut(t.frame_color),\n frameWidth: t.frame_width,\n borderColor: colorOut(t.border_color),\n borderWidth: t.border_width,\n forceOverlay: overlay(t.force_overlay),\n });\n };\n\n const convert = <T, R>(items: T[], fn: (item: T) => R | undefined): R[] | undefined => {\n const out: R[] = [];\n for (const item of items) {\n const r = fn(item);\n if (r !== undefined) out.push(r);\n }\n return out.length ? out : undefined;\n };\n\n return {\n labels: convert(all('label'), labelData),\n lines: convert(all('line'), lineData),\n boxes: convert(all('box'), boxData),\n linefills: convert(all('linefill'), (f): LinefillData | undefined => {\n const line1 = lineData(f.line1);\n const line2 = lineData(f.line2);\n return line1 && line2 ? compact({ line1, line2, color: colorOut(f.color) }) : undefined;\n }),\n polylines: convert(all('polyline'), polylineData),\n tables: convert(all('table'), tableData),\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,sBAAoB;AACpB,sBAAqC;AAuBrC,SAAS,SAAS,GAAiD;AACjE,MAAI,MAAM,OAAW,QAAO;AAC5B,MAAI,MAAM,QAAS,OAAO,MAAM,YAAY,OAAO,MAAM,CAAC,EAAI,QAAO;AACrE,SAAO,OAAO,MAAM,WAAW,KAAK,IAAI,UAAU,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,KAAK;AACtF;AAGA,SAAS,QAA0B,KAAW;AAC5C,aAAW,KAAK,OAAO,KAAK,GAAG,EAAqB,KAAI,IAAI,CAAC,MAAM,OAAW,QAAO,IAAI,CAAC;AAC1F,SAAO;AACT;AAEA,MAAM,UAAU,CAAC,SAAiD,OAAO,OAAO;AAKhF,MAAM,UAAU,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AQ;AAAA,MACb,UAAU,EAAE;AAAA,MACZ,SAAS,EAAE;AAAA,MACX,MAAM,EAAE;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,SAAS,SAAS;AAAA,MACjC,SAAS,SAAS,EAAE,OAAO;AAAA,MAC3B,YAAY,SAAS,EAAE,WAAW;AAAA,MAClC,YAAY,EAAE;AAAA,MACd,aAAa,SAAS,EAAE,YAAY;AAAA,MACpC,aAAa,EAAE;AAAA,MACf,cAAc,QAAQ,EAAE,aAAa;AAAA,IACvC,CAAC;AAAA,EACH;AAEA,QAAM,UAAU,CAAO,OAAY,OAAoD;AACrF,UAAM,MAAW,CAAC;AAClB,eAAW,QAAQ,OAAO;AACxB,YAAM,IAAI,GAAG,IAAI;AACjB,UAAI,MAAM,OAAW,KAAI,KAAK,CAAC;AAAA,IACjC;AACA,WAAO,IAAI,SAAS,MAAM;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL,QAAQ,YAAQ,qBAAI,OAAO,GAAG,SAAS;AAAA,IACvC,OAAO,YAAQ,qBAAI,MAAM,GAAG,QAAQ;AAAA,IACpC,OAAO,YAAQ,qBAAI,KAAK,GAAG,OAAO;AAAA,IAClC,WAAW,YAAQ,qBAAI,UAAU,GAAG,CAAC,MAAgC;AACnE,YAAM,QAAQ,SAAS,EAAE,KAAK;AAC9B,YAAM,QAAQ,SAAS,EAAE,KAAK;AAC9B,aAAO,SAAS,QAAQ,QAAQ,EAAE,OAAO,OAAO,OAAO,SAAS,EAAE,KAAK,EAAE,CAAC,IAAI;AAAA,IAChF,CAAC;AAAA,IACD,WAAW,YAAQ,qBAAI,UAAU,GAAG,YAAY;AAAA,IAChD,QAAQ,YAAQ,qBAAI,OAAO,GAAG,SAAS;AAAA,EACzC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type * from './strategy/index.js';
|
|
|
66
66
|
export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
67
67
|
export type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
68
68
|
export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
|
|
69
|
-
export declare const VERSION = "0.
|
|
69
|
+
export declare const VERSION = "0.20.0";
|
|
70
70
|
/**
|
|
71
71
|
* Library information
|
|
72
72
|
*/
|
package/dist/cjs/index.js
CHANGED
|
@@ -213,7 +213,7 @@ var import_input_active = require("./runtime/input-active.js");
|
|
|
213
213
|
var import_strategy = require("./strategy/index.js");
|
|
214
214
|
var import_LightweightChartsAdapter = require("./runtime/adapters/LightweightChartsAdapter.js");
|
|
215
215
|
var import_SimpleInputAdapter = require("./runtime/adapters/SimpleInputAdapter.js");
|
|
216
|
-
const VERSION = "0.
|
|
216
|
+
const VERSION = "0.20.0";
|
|
217
217
|
const info = {
|
|
218
218
|
name: "OakScriptJS",
|
|
219
219
|
version: VERSION,
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// ta.* one bar at a time (step / commit), for incremental calculations (#196)\nexport { taStep, type BarStep } from './ta/step.js';\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Drawing registry limits (PineScript indicator(max_lines_count / max_labels_count / max_boxes_count / max_polylines_count)),\n// and the drawing checkpoint of a port with its own bar loop (live updates of the forming bar, #203)\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\n createdDrawingKinds,\n saveDrawingCheckpoint,\n restoreDrawingCheckpoint,\n type DrawingCheckpoint,\n type DrawingKind,\n type DrawingLimits,\n type DrawingVariable,\n} from './drawing/registry.js';\n\n// The session of a chart context without a script run: time(tf, session, timezone), time_close(...), time_tradingday,\n// session.* flags, request.security periods with the session and holidays, and bars after the last bar on the trading\n// calendar\nexport {\n chartSessions,\n sessionPeriods,\n periodTime,\n periodClose,\n tradingDayTime,\n chartSessionFlags,\n resampleSession,\n barTimeAfter,\n barsUntil,\n type SessionContext,\n type ChartSessions,\n type SessionPeriods,\n type SessionResample,\n} from './session/context.js';\nexport { TradingCalendar, type SessionSpec } from './session/calendar.js';\nexport { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';\n\n// Same-symbol request.security on a higher timeframe (completion and lookahead rules) and ticker.heikinashi\nexport { resample, periodsOf, afterCompletion, mapToChart, heikinAshi, type Resampled } from './security/resample.js';\n// request.security of another symbol: which bar of the other symbol each chart bar shows (#179)\nexport {\n securityOther,\n securityOtherValues,\n securityLowerTf,\n MAX_INTRABARS,\n type OtherSymbolChart,\n type OtherSymbolOptions,\n type SymbolCalendar,\n} from './security/other.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\nexport { setSourceResolver, externalSource, BUILTIN_SOURCES, type SourceResolver } from './utils/source-resolver.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_text_area,\n input_source,\n input_timeframe,\n input_session,\n input_symbol,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n ShapeConfig,\n BarColorConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.
|
|
4
|
+
"sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// ta.* one bar at a time (step / commit), for incremental calculations (#196)\nexport { taStep, type BarStep } from './ta/step.js';\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Drawing registry limits (PineScript indicator(max_lines_count / max_labels_count / max_boxes_count / max_polylines_count)),\n// and the drawing checkpoint of a port with its own bar loop (live updates of the forming bar, #203)\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\n createdDrawingKinds,\n saveDrawingCheckpoint,\n restoreDrawingCheckpoint,\n type DrawingCheckpoint,\n type DrawingKind,\n type DrawingLimits,\n type DrawingVariable,\n} from './drawing/registry.js';\n\n// The session of a chart context without a script run: time(tf, session, timezone), time_close(...), time_tradingday,\n// session.* flags, request.security periods with the session and holidays, and bars after the last bar on the trading\n// calendar\nexport {\n chartSessions,\n sessionPeriods,\n periodTime,\n periodClose,\n tradingDayTime,\n chartSessionFlags,\n resampleSession,\n barTimeAfter,\n barsUntil,\n type SessionContext,\n type ChartSessions,\n type SessionPeriods,\n type SessionResample,\n} from './session/context.js';\nexport { TradingCalendar, type SessionSpec } from './session/calendar.js';\nexport { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';\n\n// Same-symbol request.security on a higher timeframe (completion and lookahead rules) and ticker.heikinashi\nexport { resample, periodsOf, afterCompletion, mapToChart, heikinAshi, type Resampled } from './security/resample.js';\n// request.security of another symbol: which bar of the other symbol each chart bar shows (#179)\nexport {\n securityOther,\n securityOtherValues,\n securityLowerTf,\n MAX_INTRABARS,\n type OtherSymbolChart,\n type OtherSymbolOptions,\n type SymbolCalendar,\n} from './security/other.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\nexport { setSourceResolver, externalSource, BUILTIN_SOURCES, type SourceResolver } from './utils/source-resolver.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_text_area,\n input_source,\n input_timeframe,\n input_session,\n input_symbol,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n ShapeConfig,\n BarColorConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.20.0';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
|
|
5
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;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;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAS,CAAC,cAAc,QAAQ,SAAS,SAAS;AAAA,IAClD,WAAW,CAAC,aAAa,SAAS,cAAc,YAAY;AAAA,EAC9D;AACF;AAUO,SAAS,eAAe,YAAqB,QAAiB,UAAyB;AAE9F;",
|
|
6
6
|
"names": ["import_utils"]
|
|
7
7
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @version 6
|
|
11
11
|
*/
|
|
12
12
|
import type { ChartPoint, Label, color } from '../types/index.js';
|
|
13
|
-
type LabelXloc = 'bar_index' | 'bar_time';
|
|
13
|
+
type LabelXloc = 'bar_index' | 'bar_time' | 'pane';
|
|
14
14
|
type LabelYloc = 'price' | 'abovebar' | 'belowbar';
|
|
15
15
|
type LabelStyle = NonNullable<Label['style']>;
|
|
16
16
|
/**
|
|
@@ -149,7 +149,7 @@ export declare function set_xy(id: Label, x: number, y: number): Label;
|
|
|
149
149
|
* label.set_xloc(label, 1609459200000, 'bar_time'); // Change to timestamp
|
|
150
150
|
* ```
|
|
151
151
|
*/
|
|
152
|
-
export declare function set_xloc(id: Label, x: number, xloc: 'bar_index' | 'bar_time'): Label;
|
|
152
|
+
export declare function set_xloc(id: Label, x: number, xloc: 'bar_index' | 'bar_time' | 'pane'): Label;
|
|
153
153
|
/**
|
|
154
154
|
* Sets the y-location mode of the label (PineScript `label.set_yloc(id, yloc)`): `price` uses the
|
|
155
155
|
* label's y, `abovebar` / `belowbar` place it above / below the bar.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/label/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAElE,KAAK,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/label/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;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AAE,KAAK,EAAE,UAAU,GAAG,KAAK,CAK7D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,CAIxE;AAGD,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC;AAC5B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/label/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Label namespace\n * Functions for creating and manipulating label drawing objects.\n *\n * @remarks\n * Labels are primarily used for annotations and marking points on the chart.\n * They have limited computational value compared to lines and boxes, but getters\n * allow retrieving position and text for conditional logic.\n *\n * @version 6\n */\n\nimport { all as allDrawings, checkBarIndex, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Label, color } from '../types/index.js';\n\ntype LabelXloc = 'bar_index' | 'bar_time';\ntype LabelYloc = 'price' | 'abovebar' | 'belowbar';\ntype LabelStyle = NonNullable<Label['style']>;\n\n/**\n * Creates a new label (PineScript `label.new`), with a chart point or with coordinates:\n *\n * - `label.new(point, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n * - `label.new(x, y, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n *\n * With a chart point, x is `point.index` for `bar_index` labels and `point.time` for `bar_time` labels.\n *\n * @example\n * ```typescript\n * const signal = label.new(10, 105.5, 'BUY');\n * const atPoint = label.new(chartPoint.from_index(10, 105.5), 'BUY');\n * ```\n */\nexport function new_label(\n point: ChartPoint,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(\n x: number,\n y: number,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(...args: unknown[]): Label {\n let x: number, y: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const point = args[0] as ChartPoint;\n rest = args.slice(1);\n x = pointX(point, (rest[1] as LabelXloc | undefined) ?? 'bar_index');\n y = point.price;\n } else {\n [x, y] = args as [number, number];\n rest = args.slice(2);\n }\n const [text, xloc, yloc, labelColor, style, textcolor, size, textalign, tooltip, text_font_family,\n force_overlay, text_formatting] = rest as [\n string?, LabelXloc?, LabelYloc?, color?, LabelStyle?, color?, (string | number)?,\n ('left' | 'center' | 'right')?, string?, ('default' | 'monospace')?, boolean?, number?,\n ];\n x = checkBarIndex('label.new', 'x', x, xloc);\n return register('label', {\n x,\n y,\n xloc: xloc ?? 'bar_index',\n yloc: yloc ?? 'price',\n // PineScript: a label without text has the text \"\" (label.get_text gives \"\")\n text: text ?? '',\n tooltip,\n color: labelColor,\n style,\n textcolor,\n size,\n textalign,\n text_font_family,\n force_overlay: force_overlay ?? false,\n text_formatting,\n });\n}\n\n/**\n * Returns the x coordinate.\n *\n * @param id - Label object\n * @returns X coordinate (bar index or timestamp)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const x = label.get_x(label); // Returns 50\n * ```\n */\nexport function get_x(id: Label): number {\n return id.x;\n}\n\n/**\n * Returns the y coordinate (price level).\n *\n * @param id - Label object\n * @returns Y coordinate (price)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const y = label.get_y(label); // Returns 155.5\n * ```\n */\nexport function get_y(id: Label): number {\n return id.y;\n}\n\n/**\n * Returns the label text content.\n *\n * @param id - Label object\n * @returns Text content (or undefined if no text)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot High');\n * const text = label.get_text(label); // Returns 'Pivot High'\n * ```\n */\nexport function get_text(id: Label): string | undefined {\n return id.text;\n}\n\n/**\n * Creates a copy of the label object.\n *\n * @param id - Label object to copy\n * @returns New label object with same properties\n *\n * @remarks\n * Creates a shallow copy of the label. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const original = label.new(50, 155.5, 'Pivot');\n * const copied = label.copy(original);\n *\n * // Modify copy without affecting original\n * copied.text = 'New Text';\n * ```\n */\nexport function copy(id: Label): Label {\n return register('label', { ...id });\n}\n\n// =============================================================================\n// POSITION SETTERS\n// =============================================================================\n\n/**\n * Sets the x coordinate.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_x(label, 55); // Move to bar 55\n * ```\n */\nexport function set_x(id: Label, x: number): Label {\n if (isDeleted(id)) return id;\n x = checkBarIndex('label.set_x', 'x', x, id.xloc);\n id.x = x;\n return id;\n}\n\n/**\n * Sets the y coordinate (price level).\n *\n * @param id - Label object to modify\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_y(label, 160); // Move to price 160\n * ```\n */\nexport function set_y(id: Label, y: number): Label {\n if (isDeleted(id)) return id;\n id.y = y;\n return id;\n}\n\n/**\n * Sets both x and y coordinates.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xy(label, 60, 160); // Move to (60, 160)\n * ```\n */\nexport function set_xy(id: Label, x: number, y: number): Label {\n if (isDeleted(id)) return id;\n x = checkBarIndex('label.set_x', 'x', x, id.xloc);\n id.x = x;\n id.y = y;\n return id;\n}\n\n/**\n * Sets the x-axis coordinate system.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param xloc - New coordinate system\n * @returns Modified label object\n *\n * @remarks\n * When changing xloc, you must provide an appropriate x coordinate for the new system.\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xloc(label, 1609459200000, 'bar_time'); // Change to timestamp\n * ```\n */\nexport function set_xloc(id: Label, x: number, xloc: 'bar_index' | 'bar_time'): Label {\n if (isDeleted(id)) return id;\n id.x = x;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the y-location mode of the label (PineScript `label.set_yloc(id, yloc)`): `price` uses the\n * label's y, `abovebar` / `belowbar` place it above / below the bar.\n */\nexport function set_yloc(id: Label, yloc: 'price' | 'abovebar' | 'belowbar'): Label {\n if (isDeleted(id)) return id;\n id.yloc = yloc;\n return id;\n}\n\n// =============================================================================\n// CONTENT SETTERS\n// =============================================================================\n\n/**\n * Sets the text content.\n *\n * @param id - Label object to modify\n * @param text - New text content\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text(label, 'Updated Text');\n * ```\n */\nexport function set_text(id: Label, text: string): Label {\n if (isDeleted(id)) return id;\n id.text = text;\n return id;\n}\n\n/**\n * Sets the tooltip text.\n *\n * @param id - Label object to modify\n * @param tooltip - New tooltip text\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_tooltip(label, 'Resistance level formed at 155.5');\n * ```\n */\nexport function set_tooltip(id: Label, tooltip: string): Label {\n if (isDeleted(id)) return id;\n id.tooltip = tooltip;\n return id;\n}\n\n// =============================================================================\n// STYLING SETTERS\n// =============================================================================\n\n/**\n * Sets the label color (border and arrow).\n *\n * @param id - Label object to modify\n * @param labelColor - New color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_color(label, '#FF0000'); // Red label\n * ```\n */\nexport function set_color(id: Label, labelColor: color): Label {\n if (isDeleted(id)) return id;\n id.color = labelColor;\n return id;\n}\n\n/**\n * Sets the text color.\n *\n * @param id - Label object to modify\n * @param textColor - New text color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textcolor(label, '#FFFFFF'); // White text\n * ```\n */\nexport function set_textcolor(id: Label, textColor: color): Label {\n if (isDeleted(id)) return id;\n id.textcolor = textColor;\n return id;\n}\n\n/**\n * Sets the label style.\n *\n * @param id - Label object to modify\n * @param style - New label style\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_style(label, 'label_down'); // Arrow pointing down\n * ```\n */\nexport function set_style(\n id: Label,\n style: 'none' | 'xcross' | 'cross' | 'triangleup' | 'triangledown' | 'flag' | 'circle' |\n 'arrowup' | 'arrowdown' | 'label_up' | 'label_down' | 'label_left' | 'label_right' |\n 'label_lower_left' | 'label_lower_right' | 'label_upper_left' | 'label_upper_right' |\n 'label_center' | 'square' | 'diamond' | 'text_outline'\n): Label {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the label size.\n *\n * @param id - Label object to modify\n * @param size - New size\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_size(label, 'large'); // Larger label\n * ```\n */\nexport function set_size(id: Label, size: string | number): Label {\n if (isDeleted(id)) return id;\n id.size = size;\n return id;\n}\n\n/**\n * Sets the text alignment.\n *\n * @param id - Label object to modify\n * @param align - New text alignment\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textalign(label, 'center'); // Center-aligned text\n * ```\n */\nexport function set_textalign(id: Label, align: 'left' | 'center' | 'right'): Label {\n if (isDeleted(id)) return id;\n id.textalign = align;\n return id;\n}\n\n/**\n * Sets the text font family.\n *\n * @param id - Label object to modify\n * @param font - New font family\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text_font_family(label, 'monospace');\n * ```\n */\nexport function set_text_font_family(id: Label, font: 'default' | 'monospace'): Label {\n if (isDeleted(id)) return id;\n id.text_font_family = font;\n return id;\n}\n\n/**\n * Deletes the label object.\n *\n * @param id - Label object to delete\n *\n * @remarks\n * Removes the label from `label.all()`. As in PineScript, the deleted label 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 label = label.new(50, 155.5, 'Pivot');\n * label.delete(label);\n * // label.all() no longer contains it\n * ```\n */\nexport function delete_label(id: Label): void {\n remove('label', 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 labels, in creation order (PineScript `label.all`). A new array.\n */\nexport function all(): Label[] {\n return allDrawings('label');\n}\n\n/**\n * Sets the label position from a chart point: `point.index` for `bar_index` labels, `point.time`\n * for `bar_time` labels, and `point.price`.\n */\nexport function set_point(id: Label, point: ChartPoint): Label {\n if (isDeleted(id)) return id;\n id.x = pointX(point, id.xloc);\n id.y = 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: Label, formatting: number): Label {\n if (isDeleted(id)) return id;\n id.text_formatting = formatting;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_label as new };\nexport { delete_label as delete };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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G,IAAI;AAChD,KAAG,IAAI;AACP,SAAO;AACT;AAeO,SAAS,MAAM,IAAW,GAAkB;AACjD,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,IAAI;AACP,SAAO;AACT;AAgBO,SAAS,OAAO,IAAW,GAAW,GAAkB;AAC7D,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,UAAI,+BAAc,eAAe,KAAK,GAAG,GAAG,IAAI;AAChD,KAAG,IAAI;AACP,KAAG,IAAI;AACP,SAAO;AACT;AAmBO,SAAS,SAAS,IAAW,GAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * Label namespace\n * Functions for creating and manipulating label drawing objects.\n *\n * @remarks\n * Labels are primarily used for annotations and marking points on the chart.\n * They have limited computational value compared to lines and boxes, but getters\n * allow retrieving position and text for conditional logic.\n *\n * @version 6\n */\n\nimport { all as allDrawings, checkBarIndex, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Label, color } from '../types/index.js';\n\ntype LabelXloc = 'bar_index' | 'bar_time' | 'pane';\ntype LabelYloc = 'price' | 'abovebar' | 'belowbar';\ntype LabelStyle = NonNullable<Label['style']>;\n\n/**\n * Creates a new label (PineScript `label.new`), with a chart point or with coordinates:\n *\n * - `label.new(point, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n * - `label.new(x, y, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n *\n * With a chart point, x is `point.index` for `bar_index` labels and `point.time` for `bar_time` labels.\n *\n * @example\n * ```typescript\n * const signal = label.new(10, 105.5, 'BUY');\n * const atPoint = label.new(chartPoint.from_index(10, 105.5), 'BUY');\n * ```\n */\nexport function new_label(\n point: ChartPoint,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(\n x: number,\n y: number,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(...args: unknown[]): Label {\n let x: number, y: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const point = args[0] as ChartPoint;\n rest = args.slice(1);\n x = pointX(point, (rest[1] as LabelXloc | undefined) ?? 'bar_index');\n y = point.price;\n } else {\n [x, y] = args as [number, number];\n rest = args.slice(2);\n }\n const [text, xloc, yloc, labelColor, style, textcolor, size, textalign, tooltip, text_font_family,\n force_overlay, text_formatting] = rest as [\n string?, LabelXloc?, LabelYloc?, color?, LabelStyle?, color?, (string | number)?,\n ('left' | 'center' | 'right')?, string?, ('default' | 'monospace')?, boolean?, number?,\n ];\n x = checkBarIndex('label.new', 'x', x, xloc);\n return register('label', {\n x,\n y,\n xloc: xloc ?? 'bar_index',\n yloc: yloc ?? 'price',\n // PineScript: a label without text has the text \"\" (label.get_text gives \"\")\n text: text ?? '',\n tooltip,\n color: labelColor,\n style,\n textcolor,\n size,\n textalign,\n text_font_family,\n force_overlay: force_overlay ?? false,\n text_formatting,\n });\n}\n\n/**\n * Returns the x coordinate.\n *\n * @param id - Label object\n * @returns X coordinate (bar index or timestamp)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const x = label.get_x(label); // Returns 50\n * ```\n */\nexport function get_x(id: Label): number {\n return id.x;\n}\n\n/**\n * Returns the y coordinate (price level).\n *\n * @param id - Label object\n * @returns Y coordinate (price)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const y = label.get_y(label); // Returns 155.5\n * ```\n */\nexport function get_y(id: Label): number {\n return id.y;\n}\n\n/**\n * Returns the label text content.\n *\n * @param id - Label object\n * @returns Text content (or undefined if no text)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot High');\n * const text = label.get_text(label); // Returns 'Pivot High'\n * ```\n */\nexport function get_text(id: Label): string | undefined {\n return id.text;\n}\n\n/**\n * Creates a copy of the label object.\n *\n * @param id - Label object to copy\n * @returns New label object with same properties\n *\n * @remarks\n * Creates a shallow copy of the label. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const original = label.new(50, 155.5, 'Pivot');\n * const copied = label.copy(original);\n *\n * // Modify copy without affecting original\n * copied.text = 'New Text';\n * ```\n */\nexport function copy(id: Label): Label {\n return register('label', { ...id });\n}\n\n// =============================================================================\n// POSITION SETTERS\n// =============================================================================\n\n/**\n * Sets the x coordinate.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_x(label, 55); // Move to bar 55\n * ```\n */\nexport function set_x(id: Label, x: number): Label {\n if (isDeleted(id)) return id;\n x = checkBarIndex('label.set_x', 'x', x, id.xloc);\n id.x = x;\n return id;\n}\n\n/**\n * Sets the y coordinate (price level).\n *\n * @param id - Label object to modify\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_y(label, 160); // Move to price 160\n * ```\n */\nexport function set_y(id: Label, y: number): Label {\n if (isDeleted(id)) return id;\n id.y = y;\n return id;\n}\n\n/**\n * Sets both x and y coordinates.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xy(label, 60, 160); // Move to (60, 160)\n * ```\n */\nexport function set_xy(id: Label, x: number, y: number): Label {\n if (isDeleted(id)) return id;\n x = checkBarIndex('label.set_x', 'x', x, id.xloc);\n id.x = x;\n id.y = y;\n return id;\n}\n\n/**\n * Sets the x-axis coordinate system.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param xloc - New coordinate system\n * @returns Modified label object\n *\n * @remarks\n * When changing xloc, you must provide an appropriate x coordinate for the new system.\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xloc(label, 1609459200000, 'bar_time'); // Change to timestamp\n * ```\n */\nexport function set_xloc(id: Label, x: number, xloc: 'bar_index' | 'bar_time' | 'pane'): Label {\n if (isDeleted(id)) return id;\n id.x = x;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the y-location mode of the label (PineScript `label.set_yloc(id, yloc)`): `price` uses the\n * label's y, `abovebar` / `belowbar` place it above / below the bar.\n */\nexport function set_yloc(id: Label, yloc: 'price' | 'abovebar' | 'belowbar'): Label {\n if (isDeleted(id)) return id;\n id.yloc = yloc;\n return id;\n}\n\n// =============================================================================\n// CONTENT SETTERS\n// =============================================================================\n\n/**\n * Sets the text content.\n *\n * @param id - Label object to modify\n * @param text - New text content\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text(label, 'Updated Text');\n * ```\n */\nexport function set_text(id: Label, text: string): Label {\n if (isDeleted(id)) return id;\n id.text = text;\n return id;\n}\n\n/**\n * Sets the tooltip text.\n *\n * @param id - Label object to modify\n * @param tooltip - New tooltip text\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_tooltip(label, 'Resistance level formed at 155.5');\n * ```\n */\nexport function set_tooltip(id: Label, tooltip: string): Label {\n if (isDeleted(id)) return id;\n id.tooltip = tooltip;\n return id;\n}\n\n// =============================================================================\n// STYLING SETTERS\n// =============================================================================\n\n/**\n * Sets the label color (border and arrow).\n *\n * @param id - Label object to modify\n * @param labelColor - New color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_color(label, '#FF0000'); // Red label\n * ```\n */\nexport function set_color(id: Label, labelColor: color): Label {\n if (isDeleted(id)) return id;\n id.color = labelColor;\n return id;\n}\n\n/**\n * Sets the text color.\n *\n * @param id - Label object to modify\n * @param textColor - New text color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textcolor(label, '#FFFFFF'); // White text\n * ```\n */\nexport function set_textcolor(id: Label, textColor: color): Label {\n if (isDeleted(id)) return id;\n id.textcolor = textColor;\n return id;\n}\n\n/**\n * Sets the label style.\n *\n * @param id - Label object to modify\n * @param style - New label style\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_style(label, 'label_down'); // Arrow pointing down\n * ```\n */\nexport function set_style(\n id: Label,\n style: 'none' | 'xcross' | 'cross' | 'triangleup' | 'triangledown' | 'flag' | 'circle' |\n 'arrowup' | 'arrowdown' | 'label_up' | 'label_down' | 'label_left' | 'label_right' |\n 'label_lower_left' | 'label_lower_right' | 'label_upper_left' | 'label_upper_right' |\n 'label_center' | 'square' | 'diamond' | 'text_outline'\n): Label {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the label size.\n *\n * @param id - Label object to modify\n * @param size - New size\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_size(label, 'large'); // Larger label\n * ```\n */\nexport function set_size(id: Label, size: string | number): Label {\n if (isDeleted(id)) return id;\n id.size = size;\n return id;\n}\n\n/**\n * Sets the text alignment.\n *\n * @param id - Label object to modify\n * @param align - New text alignment\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textalign(label, 'center'); // Center-aligned text\n * ```\n */\nexport function set_textalign(id: Label, align: 'left' | 'center' | 'right'): Label {\n if (isDeleted(id)) return id;\n id.textalign = align;\n return id;\n}\n\n/**\n * Sets the text font family.\n *\n * @param id - Label object to modify\n * @param font - New font family\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text_font_family(label, 'monospace');\n * ```\n */\nexport function set_text_font_family(id: Label, font: 'default' | 'monospace'): Label {\n if (isDeleted(id)) return id;\n id.text_font_family = font;\n return id;\n}\n\n/**\n * Deletes the label object.\n *\n * @param id - Label object to delete\n *\n * @remarks\n * Removes the label from `label.all()`. As in PineScript, the deleted label 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 label = label.new(50, 155.5, 'Pivot');\n * label.delete(label);\n * // label.all() no longer contains it\n * ```\n */\nexport function delete_label(id: Label): void {\n remove('label', 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' | 'pane'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live labels, in creation order (PineScript `label.all`). A new array.\n */\nexport function all(): Label[] {\n return allDrawings('label');\n}\n\n/**\n * Sets the label position from a chart point: `point.index` for `bar_index` labels, `point.time`\n * for `bar_time` labels, and `point.price`.\n */\nexport function set_point(id: Label, point: ChartPoint): Label {\n if (isDeleted(id)) return id;\n id.x = pointX(point, id.xloc);\n id.y = 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: Label, formatting: number): Label {\n if (isDeleted(id)) return id;\n id.text_formatting = formatting;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_label as new };\nexport { delete_label as delete };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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,IAAW,OAA2C;AAClF,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,YAAY;AACf,SAAO;AACT;AAeO,SAAS,qBAAqB,IAAW,MAAsC;AACpF,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,mBAAmB;AACtB,SAAO;AACT;AAkBO,SAAS,aAAa,IAAiB;AAC5C,8BAAO,SAAS,EAAE;AACpB;AAGA,SAAS,OAAO,OAAmB,MAAiD;AAClF,QAAM,IAAI,SAAS,aAAa,MAAM,OAAO,MAAM;AACnD,SAAO,KAAK;AACd;AAKO,SAAS,MAAe;AAC7B,aAAO,gBAAAA,KAAY,OAAO;AAC5B;AAMO,SAAS,UAAU,IAAW,OAA0B;AAC7D,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,IAAI,OAAO,OAAO,GAAG,IAAI;AAC5B,KAAG,IAAI,MAAM;AACb,SAAO;AACT;AAMO,SAAS,oBAAoB,IAAW,YAA2B;AACxE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,kBAAkB;AACrB,SAAO;AACT;",
|
|
6
6
|
"names": ["allDrawings"]
|
|
7
7
|
}
|
package/dist/cjs/line/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @version 6
|
|
11
11
|
*/
|
|
12
12
|
import type { ChartPoint, Line, color } from '../types/index.js';
|
|
13
|
-
type LineXloc = 'bar_index' | 'bar_time';
|
|
13
|
+
type LineXloc = 'bar_index' | 'bar_time' | 'pane';
|
|
14
14
|
type LineExtend = 'none' | 'left' | 'right' | 'both';
|
|
15
15
|
type LineStyle = 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both';
|
|
16
16
|
/**
|
|
@@ -44,7 +44,7 @@ export declare function new_line(x1: number, y1: number, x2: number, y2: number,
|
|
|
44
44
|
* As in PineScript (#174):
|
|
45
45
|
* - the line is read as extended on both sides whatever its `extend`: a point before x1 or after x2 has a price
|
|
46
46
|
* - the price is `y1 + (y2 - y1) * (x - x1) / (x2 - x1)`, in that order (bit for bit)
|
|
47
|
-
* - a line placed with `xloc.bar_time` throws "'line.get_price' must be used with lines created using
|
|
47
|
+
* - a line placed with `xloc.bar_time` (or `xloc.pane`) throws "'line.get_price' must be used with lines created using
|
|
48
48
|
* 'xloc=xloc.bar_index'." (runtime error RE10119)
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
@@ -220,7 +220,7 @@ export declare function set_xy2(id: Line, x: number, y: number): Line;
|
|
|
220
220
|
* @param id - Line object to modify
|
|
221
221
|
* @param x1 - New first point x coordinate
|
|
222
222
|
* @param x2 - New second point x coordinate
|
|
223
|
-
* @param xloc - New coordinate system ('bar_index' or '
|
|
223
|
+
* @param xloc - New coordinate system ('bar_index', 'bar_time' or 'pane')
|
|
224
224
|
* @returns Modified line object
|
|
225
225
|
*
|
|
226
226
|
* @remarks
|
|
@@ -233,7 +233,7 @@ export declare function set_xy2(id: Line, x: number, y: number): Line;
|
|
|
233
233
|
* line.set_xloc(line, 1609459200000, 1609545600000, 'bar_time');
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
|
-
export declare function set_xloc(id: Line, x1: number, x2: number, xloc: 'bar_index' | 'bar_time'): Line;
|
|
236
|
+
export declare function set_xloc(id: Line, x1: number, x2: number, xloc: 'bar_index' | 'bar_time' | 'pane'): Line;
|
|
237
237
|
/**
|
|
238
238
|
* Sets the extension mode of the line.
|
|
239
239
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/line/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEjE,KAAK,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/line/index.ts"],"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UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAIrF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAI1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,IAAI,CAI5H;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAIvD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,IAAI,GAAG,IAAI,CAE1C;AAQD;;GAEG;AACH,wBAAgB,GAAG,IAAI,IAAI,EAAE,CAE5B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAKjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAKlE;AAGD,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,CAAC;AAC3B,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,CAAC"}
|
package/dist/cjs/line/index.js
CHANGED
|
@@ -73,7 +73,7 @@ function new_line(...args) {
|
|
|
73
73
|
}
|
|
74
74
|
function get_price(id, x) {
|
|
75
75
|
const { x1, y1, x2, y2, xloc } = id;
|
|
76
|
-
if (xloc
|
|
76
|
+
if (xloc !== "bar_index") {
|
|
77
77
|
throw new Error("'line.get_price' must be used with lines created using 'xloc=xloc.bar_index'.");
|
|
78
78
|
}
|
|
79
79
|
if (x2 === x1) return NaN;
|