oakscriptjs 0.11.3 → 0.11.5
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/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/input.d.ts +19 -3
- package/dist/cjs/input.d.ts.map +1 -1
- package/dist/cjs/input.js +24 -1
- package/dist/cjs/input.js.map +2 -2
- package/dist/cjs/lib/zigzag/zigzag.d.ts +8 -3
- package/dist/cjs/lib/zigzag/zigzag.d.ts.map +1 -1
- package/dist/cjs/lib/zigzag/zigzag.js +16 -3
- package/dist/cjs/lib/zigzag/zigzag.js.map +2 -2
- package/dist/cjs/runtime/index.d.ts +1 -1
- package/dist/cjs/runtime/index.d.ts.map +1 -1
- package/dist/cjs/runtime/index.js +1 -0
- package/dist/cjs/runtime/index.js.map +2 -2
- package/dist/cjs/runtime/inputs.d.ts +9 -0
- package/dist/cjs/runtime/inputs.d.ts.map +1 -1
- package/dist/cjs/runtime/inputs.js +8 -0
- package/dist/cjs/runtime/inputs.js.map +2 -2
- package/dist/cjs/runtime/types.d.ts +4 -3
- package/dist/cjs/runtime/types.d.ts.map +1 -1
- package/dist/cjs/runtime/types.js.map +1 -1
- package/dist/cjs/script/index.d.ts +38 -4
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +49 -6
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/security/other.d.ts +2 -1
- package/dist/cjs/security/other.d.ts.map +1 -1
- package/dist/cjs/security/other.js +1 -1
- package/dist/cjs/security/other.js.map +2 -2
- package/dist/cjs/ta/index.d.ts +1 -0
- package/dist/cjs/ta/index.d.ts.map +1 -1
- package/dist/cjs/ta/index.js +1 -1
- package/dist/cjs/ta/index.js.map +2 -2
- package/dist/cjs/time/index.d.ts +2 -0
- package/dist/cjs/time/index.d.ts.map +1 -1
- package/dist/cjs/time/index.js +1 -1
- package/dist/cjs/time/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/utils/index.d.ts +5 -3
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +6 -0
- package/dist/cjs/utils/index.js.map +2 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input.d.ts +19 -3
- package/dist/esm/input.d.ts.map +1 -1
- package/dist/esm/input.js +24 -1
- package/dist/esm/input.js.map +1 -1
- package/dist/esm/lib/zigzag/zigzag.d.ts +8 -3
- package/dist/esm/lib/zigzag/zigzag.d.ts.map +1 -1
- package/dist/esm/lib/zigzag/zigzag.js +19 -4
- package/dist/esm/lib/zigzag/zigzag.js.map +1 -1
- package/dist/esm/runtime/index.d.ts +1 -1
- package/dist/esm/runtime/index.d.ts.map +1 -1
- package/dist/esm/runtime/index.js +1 -1
- package/dist/esm/runtime/index.js.map +1 -1
- package/dist/esm/runtime/inputs.d.ts +9 -0
- package/dist/esm/runtime/inputs.d.ts.map +1 -1
- package/dist/esm/runtime/inputs.js +15 -0
- package/dist/esm/runtime/inputs.js.map +1 -1
- package/dist/esm/runtime/types.d.ts +4 -3
- package/dist/esm/runtime/types.d.ts.map +1 -1
- package/dist/esm/script/index.d.ts +38 -4
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +59 -4
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/security/other.d.ts +2 -1
- package/dist/esm/security/other.d.ts.map +1 -1
- package/dist/esm/security/other.js +4 -2
- package/dist/esm/security/other.js.map +1 -1
- package/dist/esm/ta/index.d.ts +1 -0
- package/dist/esm/ta/index.d.ts.map +1 -1
- package/dist/esm/ta/index.js +3 -1
- package/dist/esm/ta/index.js.map +1 -1
- package/dist/esm/time/index.d.ts +2 -0
- package/dist/esm/time/index.d.ts.map +1 -1
- package/dist/esm/time/index.js +4 -1
- package/dist/esm/time/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/index.d.ts +5 -3
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +5 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/input.ts +28 -4
- package/src/lib/zigzag/zigzag.ts +20 -6
- package/src/runtime/index.ts +1 -0
- package/src/runtime/inputs.ts +16 -0
- package/src/runtime/types.ts +4 -3
- package/src/script/index.ts +83 -7
- package/src/security/other.ts +5 -2
- package/src/ta/index.ts +3 -1
- package/src/time/index.ts +4 -1
- package/src/types/index.ts +1 -0
- package/src/utils/index.ts +8 -3
package/dist/cjs/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export { indicator, type IndicatorMetadataConfig, type InputDefinition, type Ind
|
|
|
56
56
|
export { input, type InputValue, type IntInputOptions, type FloatInputOptions, type SourceInputOptions, type BoolInputOptions, type StringInputOptions, type TimeInputOptions, type SourceType, } from './input.js';
|
|
57
57
|
export { plot as plotHelper, createPlot, type Time, type TimeValuePair, type PlotOptions as PlotHelperOptions, type PlotResult, } from './plot.js';
|
|
58
58
|
export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, } from './runtime/runtime.js';
|
|
59
|
-
export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_symbol, input_time, } from './runtime/inputs.js';
|
|
59
|
+
export { input_int, input_float, input_bool, input_string, input_text_area, input_source, input_timeframe, input_session, input_symbol, input_time, } from './runtime/inputs.js';
|
|
60
60
|
export { isInputActive } from './runtime/input-active.js';
|
|
61
61
|
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputCondition, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, CandleConfig, } from './runtime/types.js';
|
|
62
62
|
export { STRATEGY_CONSTANTS, STRATEGY_DEFAULTS, STRATEGY_NUMBER_VARIABLES, STRATEGY_TEXT_VARIABLES, } from './strategy/index.js';
|
|
@@ -64,7 +64,7 @@ export type * from './strategy/index.js';
|
|
|
64
64
|
export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
65
65
|
export type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
66
66
|
export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
|
|
67
|
-
export declare const VERSION = "0.11.
|
|
67
|
+
export declare const VERSION = "0.11.5";
|
|
68
68
|
/**
|
|
69
69
|
* Library information
|
|
70
70
|
*/
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAGpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO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,WAAW,EACX,YAAY,GACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,mBAAmB,qBAAqB,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,YAAY,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAG9E,eAAO,MAAM,OAAO,WAAW,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAKF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAE5F"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -95,6 +95,7 @@ __export(index_exports, {
|
|
|
95
95
|
input_source: () => import_inputs.input_source,
|
|
96
96
|
input_string: () => import_inputs.input_string,
|
|
97
97
|
input_symbol: () => import_inputs.input_symbol,
|
|
98
|
+
input_text_area: () => import_inputs.input_text_area,
|
|
98
99
|
input_time: () => import_inputs.input_time,
|
|
99
100
|
input_timeframe: () => import_inputs.input_timeframe,
|
|
100
101
|
isInputActive: () => import_input_active.isInputActive,
|
|
@@ -202,7 +203,7 @@ var import_input_active = require("./runtime/input-active.js");
|
|
|
202
203
|
var import_strategy = require("./strategy/index.js");
|
|
203
204
|
var import_LightweightChartsAdapter = require("./runtime/adapters/LightweightChartsAdapter.js");
|
|
204
205
|
var import_SimpleInputAdapter = require("./runtime/adapters/SimpleInputAdapter.js");
|
|
205
|
-
const VERSION = "0.11.
|
|
206
|
+
const VERSION = "0.11.5";
|
|
206
207
|
const info = {
|
|
207
208
|
name: "OakScriptJS",
|
|
208
209
|
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// 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))\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\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 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';\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_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} 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.11.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;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AAyBpB,uBAAkG;AAClG,kBAAgG;AAChG,mBAA2D;AAG3D,mBAAsG;AAGtG,0BAAc,2BAhId;AAmIA,IAAAA,gBAAqC;AAGrC,uBAOO;AAEP,mBAUO;AAEP,kBAOO;AAGP,qBASO;AAEP,
|
|
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// 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))\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\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 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';\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} 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.11.5';\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
|
+
"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;AA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,MAAM,CAAC,MAAM,QAAQ,SAAS,OAAO,OAAO,SAAS,QAAQ,aAAa,QAAQ;AAAA,IAClF,SAAS,CAAC,QAAQ,OAAO,SAAS,YAAY,cAAc,YAAY,SAAS,MAAM;AAAA,IACvF,SAAS,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
|
}
|
package/dist/cjs/input.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export interface InputValue<T> {
|
|
10
10
|
/** Input type identifier */
|
|
11
|
-
type: 'int' | 'float' | 'source' | 'bool' | 'string' | 'timeframe' | 'session' | 'time' | 'symbol';
|
|
11
|
+
type: 'int' | 'float' | 'source' | 'bool' | 'string' | 'text_area' | 'timeframe' | 'session' | 'time' | 'symbol';
|
|
12
12
|
/** Default value */
|
|
13
13
|
defaultValue: T;
|
|
14
14
|
/** Current value (initially equals defaultValue) */
|
|
@@ -81,9 +81,9 @@ export interface TimeInputOptions {
|
|
|
81
81
|
title?: string;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Source type for price data
|
|
84
|
+
* Source type for price data (PineScript `input.source` built-in sources, `volume` included)
|
|
85
85
|
*/
|
|
86
|
-
export type SourceType = 'open' | 'high' | 'low' | 'close' | 'hl2' | 'hlc3' | 'ohlc4' | 'hlcc4';
|
|
86
|
+
export type SourceType = 'open' | 'high' | 'low' | 'close' | 'hl2' | 'hlc3' | 'ohlc4' | 'hlcc4' | 'volume';
|
|
87
87
|
/**
|
|
88
88
|
* Input helper functions for creating indicator parameters
|
|
89
89
|
*/
|
|
@@ -153,6 +153,22 @@ export declare const input: {
|
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
155
|
string(defaultValue: string, options?: StringInputOptions): InputValue<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Create a multi-line text input parameter (PineScript `input.text_area`, #184)
|
|
158
|
+
* @param defaultValue - Default text; lines are separated by "
|
|
159
|
+
"
|
|
160
|
+
* @param options - Additional options (title)
|
|
161
|
+
* @returns Input value object
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const list = input.text_area('AAPL, MSFT
|
|
166
|
+
BTCUSD', { title: 'Symbol list' });
|
|
167
|
+
* console.log(list.value); // 'AAPL, MSFT
|
|
168
|
+
BTCUSD'
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
text_area(defaultValue: string, options?: TimeInputOptions): InputValue<string>;
|
|
156
172
|
/**
|
|
157
173
|
* Create a timeframe input parameter (PineScript `input.timeframe`)
|
|
158
174
|
* @param defaultValue - Default timeframe string ("60", "1D", "W"); "" means the chart timeframe
|
package/dist/cjs/input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,4BAA4B;IAC5B,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,4BAA4B;IAC5B,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IACjH,oBAAoB;IACpB,YAAY,EAAE,CAAC,C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EG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE3G;;GAEG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;;;;;;OAWG;sBACe,MAAM,YAAW,eAAe,GAAQ,UAAU,CAAC,MAAM,CAAC;IAY5E;;;;;;;;;;;OAWG;wBACiB,MAAM,YAAW,iBAAiB,GAAQ,UAAU,CAAC,MAAM,CAAC;IAYhF;;;;;;;;;;;OAWG;0BACkB,UAAU,YAAqB,kBAAkB,GAAQ,UAAU,CAAC,UAAU,CAAC;IAUpG;;;;;;;;;;;OAWG;uBACgB,OAAO,YAAW,gBAAgB,GAAQ,UAAU,CAAC,OAAO,CAAC;IAShF;;;;;;;;;;;OAWG;yBACkB,MAAM,YAAW,kBAAkB,GAAQ,UAAU,CAAC,MAAM,CAAC;IAUlF;;;;;;;;;;;;;;OAcG;4BACqB,MAAM,YAAW,gBAAgB,GAAQ,UAAU,CAAC,MAAM,CAAC;IASnF;;;;;;;;;;;OAWG;4BACqB,MAAM,YAAW,kBAAkB,GAAQ,UAAU,CAAC,MAAM,CAAC;IAUrF;;;;;;;;;;;OAWG;0BACmB,MAAM,YAAW,kBAAkB,GAAQ,UAAU,CAAC,MAAM,CAAC;IAUnF;;;;;;OAMG;yBACkB,MAAM,YAAW,kBAAkB,GAAQ,UAAU,CAAC,MAAM,CAAC;IAUlF;;;;;;;;;;;OAWG;uBACgB,MAAM,YAAW,gBAAgB,GAAQ,UAAU,CAAC,MAAM,CAAC;CAQ/E,CAAC"}
|
package/dist/cjs/input.js
CHANGED
|
@@ -86,7 +86,7 @@ const input = {
|
|
|
86
86
|
defaultValue,
|
|
87
87
|
value: defaultValue,
|
|
88
88
|
title: options.title,
|
|
89
|
-
options: ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4", "hlcc4"]
|
|
89
|
+
options: ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4", "hlcc4", "volume"]
|
|
90
90
|
};
|
|
91
91
|
},
|
|
92
92
|
/**
|
|
@@ -130,6 +130,29 @@ const input = {
|
|
|
130
130
|
options: options.options
|
|
131
131
|
};
|
|
132
132
|
},
|
|
133
|
+
/**
|
|
134
|
+
* Create a multi-line text input parameter (PineScript `input.text_area`, #184)
|
|
135
|
+
* @param defaultValue - Default text; lines are separated by "
|
|
136
|
+
"
|
|
137
|
+
* @param options - Additional options (title)
|
|
138
|
+
* @returns Input value object
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const list = input.text_area('AAPL, MSFT
|
|
143
|
+
BTCUSD', { title: 'Symbol list' });
|
|
144
|
+
* console.log(list.value); // 'AAPL, MSFT
|
|
145
|
+
BTCUSD'
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
text_area(defaultValue, options = {}) {
|
|
149
|
+
return {
|
|
150
|
+
type: "text_area",
|
|
151
|
+
defaultValue,
|
|
152
|
+
value: defaultValue,
|
|
153
|
+
title: options.title
|
|
154
|
+
};
|
|
155
|
+
},
|
|
133
156
|
/**
|
|
134
157
|
* Create a timeframe input parameter (PineScript `input.timeframe`)
|
|
135
158
|
* @param defaultValue - Default timeframe string ("60", "1D", "W"); "" means the chart timeframe
|
package/dist/cjs/input.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/input.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Input helper functions for indicator parameters\n * These functions create input definitions that can be used with the indicator system.\n * @module input\n */\n\n/**\n * Input value with its configuration\n */\nexport interface InputValue<T> {\n /** Input type identifier */\n type: 'int' | 'float' | 'source' | 'bool' | 'string' | 'timeframe' | 'session' | 'time' | 'symbol';\n /** Default value */\n defaultValue: T;\n /** Current value (initially equals defaultValue) */\n value: T;\n /** Display title */\n title?: string;\n /** Minimum value (for numeric inputs) */\n min?: number;\n /** Maximum value (for numeric inputs) */\n max?: number;\n /** Step size (for numeric inputs) */\n step?: number;\n /** Available options (for source/string/timeframe/session types) */\n options?: string[];\n}\n\n/**\n * Options for integer input\n */\nexport interface IntInputOptions {\n /** Minimum value */\n min?: number;\n /** Maximum value */\n max?: number;\n /** Step size */\n step?: number;\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for float input\n */\nexport interface FloatInputOptions {\n /** Minimum value */\n min?: number;\n /** Maximum value */\n max?: number;\n /** Step size */\n step?: number;\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for source input\n */\nexport interface SourceInputOptions {\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for boolean input\n */\nexport interface BoolInputOptions {\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for string input\n */\nexport interface StringInputOptions {\n /** Display title */\n title?: string;\n /** Available options for dropdown */\n options?: string[];\n}\n\n/**\n * Options for time input\n */\nexport interface TimeInputOptions {\n /** Display title */\n title?: string;\n}\n\n/**\n * Source type for price data\n */\nexport type SourceType = 'open' | 'high' | 'low' | 'close' | 'hl2' | 'hlc3' | 'ohlc4' | 'hlcc4';\n\n/**\n * Input helper functions for creating indicator parameters\n */\nexport const input = {\n /**\n * Create an integer input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (min, max, step, title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const length = input.int(14, { min: 1, max: 500, title: 'Length' });\n * console.log(length.value); // 14\n * ```\n */\n int(defaultValue: number, options: IntInputOptions = {}): InputValue<number> {\n return {\n type: 'int' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n min: options.min,\n max: options.max,\n step: options.step ?? 1,\n };\n },\n\n /**\n * Create a float input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (min, max, step, title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const multiplier = input.float(2.5, { min: 0.1, max: 10, step: 0.1, title: 'Multiplier' });\n * console.log(multiplier.value); // 2.5\n * ```\n */\n float(defaultValue: number, options: FloatInputOptions = {}): InputValue<number> {\n return {\n type: 'float' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n min: options.min,\n max: options.max,\n step: options.step ?? 0.1,\n };\n },\n\n /**\n * Create a source input parameter (for selecting price data type)\n * @param defaultValue - Default source type (default: 'close')\n * @param options - Additional options (title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const src = input.source('close', { title: 'Source' });\n * console.log(src.value); // 'close'\n * ```\n */\n source(defaultValue: SourceType = 'close', options: SourceInputOptions = {}): InputValue<SourceType> {\n return {\n type: 'source' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: ['open', 'high', 'low', 'close', 'hl2', 'hlc3', 'ohlc4', 'hlcc4'],\n };\n },\n\n /**\n * Create a boolean input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const showSignal = input.bool(true, { title: 'Show Signal' });\n * console.log(showSignal.value); // true\n * ```\n */\n bool(defaultValue: boolean, options: BoolInputOptions = {}): InputValue<boolean> {\n return {\n type: 'bool' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n };\n },\n\n /**\n * Create a string input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const maType = input.string('SMA', { title: 'MA Type', options: ['SMA', 'EMA', 'WMA'] });\n * console.log(maType.value); // 'SMA'\n * ```\n */\n string(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'string' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a timeframe input parameter (PineScript `input.timeframe`)\n * @param defaultValue - Default timeframe string (\"60\", \"1D\", \"W\"); \"\" means the chart timeframe\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n *\n * @example\n * ```typescript\n * const htf = input.timeframe('1D', { title: 'Higher timeframe' });\n * console.log(htf.value); // '1D'\n * ```\n */\n timeframe(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'timeframe' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a session input parameter (PineScript `input.session`)\n * @param defaultValue - Default session string (\"0930-1600\", \"0930-1600:23456\")\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n *\n * @example\n * ```typescript\n * const rth = input.session('0930-1600', { title: 'Regular hours' });\n * console.log(rth.value); // '0930-1600'\n * ```\n */\n session(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'session' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a symbol input parameter (PineScript `input.symbol`): a ticker id (\"NASDAQ:MSFT\") that an application can\n * edit with a symbol picker (#180)\n * @param defaultValue - Default ticker id\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n */\n symbol(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'symbol' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a date/time input parameter (PineScript `input.time`)\n * @param defaultValue - Default UNIX time in milliseconds, e.g. `time.timestamp('2024-01-01')`\n * @param options - Additional options (title)\n * @returns Input value object\n *\n * @example\n * ```typescript\n * const start = input.time(time.timestamp('2024-01-01'), { title: 'Start' });\n * console.log(start.value); // 1704067200000\n * ```\n */\n time(defaultValue: number, options: TimeInputOptions = {}): InputValue<number> {\n return {\n type: 'time' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n };\n },\n};\n\n// Freeze the input object to prevent accidental modifications\nObject.freeze(input);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkGO,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAanB,IAAI,cAAsB,UAA2B,CAAC,GAAuB;AAC3E,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,OAAO;AAAA,MACP,OAAO,QAAQ;AAAA,MACf,KAAK,QAAQ;AAAA,MACb,KAAK,QAAQ;AAAA,MACb,MAAM,QAAQ,QAAQ;AAAA,IACxB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,cAAsB,UAA6B,CAAC,GAAuB;AAC/E,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,OAAO;AAAA,MACP,OAAO,QAAQ;AAAA,MACf,KAAK,QAAQ;AAAA,MACb,KAAK,QAAQ;AAAA,MACb,MAAM,QAAQ,QAAQ;AAAA,IACxB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,OAAO,eAA2B,SAAS,UAA8B,CAAC,GAA2B;AACnG,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,OAAO;AAAA,MACP,OAAO,QAAQ;AAAA,MACf,SAAS,CAAC,QAAQ,QAAQ,OAAO,SAAS,OAAO,QAAQ,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Input helper functions for indicator parameters\n * These functions create input definitions that can be used with the indicator system.\n * @module input\n */\n\n/**\n * Input value with its configuration\n */\nexport interface InputValue<T> {\n /** Input type identifier */\n type: 'int' | 'float' | 'source' | 'bool' | 'string' | 'text_area' | 'timeframe' | 'session' | 'time' | 'symbol';\n /** Default value */\n defaultValue: T;\n /** Current value (initially equals defaultValue) */\n value: T;\n /** Display title */\n title?: string;\n /** Minimum value (for numeric inputs) */\n min?: number;\n /** Maximum value (for numeric inputs) */\n max?: number;\n /** Step size (for numeric inputs) */\n step?: number;\n /** Available options (for source/string/timeframe/session types) */\n options?: string[];\n}\n\n/**\n * Options for integer input\n */\nexport interface IntInputOptions {\n /** Minimum value */\n min?: number;\n /** Maximum value */\n max?: number;\n /** Step size */\n step?: number;\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for float input\n */\nexport interface FloatInputOptions {\n /** Minimum value */\n min?: number;\n /** Maximum value */\n max?: number;\n /** Step size */\n step?: number;\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for source input\n */\nexport interface SourceInputOptions {\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for boolean input\n */\nexport interface BoolInputOptions {\n /** Display title */\n title?: string;\n}\n\n/**\n * Options for string input\n */\nexport interface StringInputOptions {\n /** Display title */\n title?: string;\n /** Available options for dropdown */\n options?: string[];\n}\n\n/**\n * Options for time input\n */\nexport interface TimeInputOptions {\n /** Display title */\n title?: string;\n}\n\n/**\n * Source type for price data (PineScript `input.source` built-in sources, `volume` included)\n */\nexport type SourceType = 'open' | 'high' | 'low' | 'close' | 'hl2' | 'hlc3' | 'ohlc4' | 'hlcc4' | 'volume';\n\n/**\n * Input helper functions for creating indicator parameters\n */\nexport const input = {\n /**\n * Create an integer input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (min, max, step, title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const length = input.int(14, { min: 1, max: 500, title: 'Length' });\n * console.log(length.value); // 14\n * ```\n */\n int(defaultValue: number, options: IntInputOptions = {}): InputValue<number> {\n return {\n type: 'int' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n min: options.min,\n max: options.max,\n step: options.step ?? 1,\n };\n },\n\n /**\n * Create a float input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (min, max, step, title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const multiplier = input.float(2.5, { min: 0.1, max: 10, step: 0.1, title: 'Multiplier' });\n * console.log(multiplier.value); // 2.5\n * ```\n */\n float(defaultValue: number, options: FloatInputOptions = {}): InputValue<number> {\n return {\n type: 'float' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n min: options.min,\n max: options.max,\n step: options.step ?? 0.1,\n };\n },\n\n /**\n * Create a source input parameter (for selecting price data type)\n * @param defaultValue - Default source type (default: 'close')\n * @param options - Additional options (title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const src = input.source('close', { title: 'Source' });\n * console.log(src.value); // 'close'\n * ```\n */\n source(defaultValue: SourceType = 'close', options: SourceInputOptions = {}): InputValue<SourceType> {\n return {\n type: 'source' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: ['open', 'high', 'low', 'close', 'hl2', 'hlc3', 'ohlc4', 'hlcc4', 'volume'],\n };\n },\n\n /**\n * Create a boolean input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (title)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const showSignal = input.bool(true, { title: 'Show Signal' });\n * console.log(showSignal.value); // true\n * ```\n */\n bool(defaultValue: boolean, options: BoolInputOptions = {}): InputValue<boolean> {\n return {\n type: 'bool' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n };\n },\n\n /**\n * Create a string input parameter\n * @param defaultValue - Default value for the input\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n * \n * @example\n * ```typescript\n * const maType = input.string('SMA', { title: 'MA Type', options: ['SMA', 'EMA', 'WMA'] });\n * console.log(maType.value); // 'SMA'\n * ```\n */\n string(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'string' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a multi-line text input parameter (PineScript `input.text_area`, #184)\n * @param defaultValue - Default text; lines are separated by \"\n\"\n * @param options - Additional options (title)\n * @returns Input value object\n *\n * @example\n * ```typescript\n * const list = input.text_area('AAPL, MSFT\nBTCUSD', { title: 'Symbol list' });\n * console.log(list.value); // 'AAPL, MSFT\nBTCUSD'\n * ```\n */\n text_area(defaultValue: string, options: TimeInputOptions = {}): InputValue<string> {\n return {\n type: 'text_area' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n };\n },\n\n /**\n * Create a timeframe input parameter (PineScript `input.timeframe`)\n * @param defaultValue - Default timeframe string (\"60\", \"1D\", \"W\"); \"\" means the chart timeframe\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n *\n * @example\n * ```typescript\n * const htf = input.timeframe('1D', { title: 'Higher timeframe' });\n * console.log(htf.value); // '1D'\n * ```\n */\n timeframe(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'timeframe' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a session input parameter (PineScript `input.session`)\n * @param defaultValue - Default session string (\"0930-1600\", \"0930-1600:23456\")\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n *\n * @example\n * ```typescript\n * const rth = input.session('0930-1600', { title: 'Regular hours' });\n * console.log(rth.value); // '0930-1600'\n * ```\n */\n session(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'session' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a symbol input parameter (PineScript `input.symbol`): a ticker id (\"NASDAQ:MSFT\") that an application can\n * edit with a symbol picker (#180)\n * @param defaultValue - Default ticker id\n * @param options - Additional options (title, options for dropdown)\n * @returns Input value object\n */\n symbol(defaultValue: string, options: StringInputOptions = {}): InputValue<string> {\n return {\n type: 'symbol' as const,\n defaultValue,\n value: defaultValue,\n title: options.title,\n options: options.options,\n };\n },\n\n /**\n * Create a date/time input parameter (PineScript `input.time`)\n * @param defaultValue - Default UNIX time in milliseconds, e.g. `time.timestamp('2024-01-01')`\n * @param options - Additional options (title)\n * @returns Input value object\n *\n * @example\n * ```typescript\n * const start = input.time(time.timestamp('2024-01-01'), { title: 'Start' });\n * console.log(start.value); // 1704067200000\n * ```\n */\n time(defaultValue: number, options: TimeInputOptions = {}): InputValue<number> {\n return {\n type: 'time' as const,\n defaultValue,\n value: defaultValue,\n title: options.title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B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,KAAK,cAAsB,UAA4B,CAAC,GAAuB;AAC7E,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,OAAO;AAAA,MACP,OAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AACF;AAGA,OAAO,OAAO,KAAK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -38,9 +38,9 @@ export interface ZigZagPoint {
|
|
|
38
38
|
export interface ZigZagPivot {
|
|
39
39
|
/** True if this is a pivot high, false for pivot low */
|
|
40
40
|
isHigh: boolean;
|
|
41
|
-
/** Cumulative volume from start to end */
|
|
41
|
+
/** Cumulative volume from start to end: the sum of `volume[depth]` over the bars that built the pivot */
|
|
42
42
|
volume: number;
|
|
43
|
-
/** Starting point of this segment */
|
|
43
|
+
/** Starting point of this segment (the first pivot starts on its own end point) */
|
|
44
44
|
start: ZigZagPoint;
|
|
45
45
|
/** Ending point (the pivot) of this segment */
|
|
46
46
|
end: ZigZagPoint;
|
|
@@ -59,7 +59,11 @@ export declare class ZigZag {
|
|
|
59
59
|
private highBuffer;
|
|
60
60
|
private lowBuffer;
|
|
61
61
|
private timeBuffer;
|
|
62
|
+
private volumeBuffer;
|
|
62
63
|
private barCount;
|
|
64
|
+
/** math.sum(volume, max(depth, 1)) of the current bar, for the extension */
|
|
65
|
+
private remVol;
|
|
66
|
+
private readonly remVolSum;
|
|
63
67
|
constructor(settings?: Partial<ZigZagSettings>);
|
|
64
68
|
/**
|
|
65
69
|
* Process a single bar, detecting pivots.
|
|
@@ -72,7 +76,8 @@ export declare class ZigZag {
|
|
|
72
76
|
*/
|
|
73
77
|
lastPivot(): ZigZagPivot | null;
|
|
74
78
|
/**
|
|
75
|
-
* Get extension line to current bar (if extendLast enabled)
|
|
79
|
+
* Get extension line to current bar (if extendLast enabled). Call it after {@link update} of `currentBar`: its
|
|
80
|
+
* volume is the cumulative volume plus the volume of the last max(depth, 1) bars (na before that many bars).
|
|
76
81
|
*/
|
|
77
82
|
getExtension(currentBar: Bar, barIndex: number): ZigZagPivot | null;
|
|
78
83
|
private tryFindPivot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zigzag.d.ts","sourceRoot":"","sources":["../../../../src/lib/zigzag/zigzag.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"zigzag.d.ts","sourceRoot":"","sources":["../../../../src/lib/zigzag/zigzag.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAKhD,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,UAAU,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,oBAAoB,EAAE,OAAO,CAAC;IAC9B,0DAA0D;IAC1D,uBAAuB,EAAE,OAAO,CAAC;IACjC,+DAA+D;IAC/D,0BAA0B,EAAE,OAAO,CAAC;IACpC,+EAA+E;IAC/E,mBAAmB,EAAE,UAAU,GAAG,SAAS,CAAC;IAC5C,gEAAgE;IAChE,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;IAChB,yGAAyG;IACzG,MAAM,EAAE,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
|
|
@@ -23,6 +23,7 @@ __export(zigzag_exports, {
|
|
|
23
23
|
defaultSettings: () => defaultSettings
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(zigzag_exports);
|
|
26
|
+
var import_running_sum = require("../../ta/running-sum.js");
|
|
26
27
|
const defaultSettings = {
|
|
27
28
|
devThreshold: 5,
|
|
28
29
|
depth: 10,
|
|
@@ -41,7 +42,11 @@ class ZigZag {
|
|
|
41
42
|
highBuffer = [];
|
|
42
43
|
lowBuffer = [];
|
|
43
44
|
timeBuffer = [];
|
|
45
|
+
volumeBuffer = [];
|
|
44
46
|
barCount = 0;
|
|
47
|
+
/** math.sum(volume, max(depth, 1)) of the current bar, for the extension */
|
|
48
|
+
remVol = NaN;
|
|
49
|
+
remVolSum = new import_running_sum.RunningSum();
|
|
45
50
|
constructor(settings) {
|
|
46
51
|
this.settings = { ...defaultSettings, ...settings };
|
|
47
52
|
}
|
|
@@ -54,9 +59,15 @@ class ZigZag {
|
|
|
54
59
|
this.highBuffer.push(bar.high);
|
|
55
60
|
this.lowBuffer.push(bar.low);
|
|
56
61
|
this.timeBuffer.push(bar.time);
|
|
62
|
+
const volume = bar.volume ?? NaN;
|
|
63
|
+
this.volumeBuffer.push(volume);
|
|
57
64
|
this.barCount++;
|
|
58
65
|
const depth = Math.max(2, Math.floor(this.settings.depth / 2));
|
|
59
|
-
this.
|
|
66
|
+
const pastVolume = this.volumeBuffer[this.volumeBuffer.length - 1 - depth];
|
|
67
|
+
this.sumVol += pastVolume === void 0 || Number.isNaN(pastVolume) ? 0 : pastVolume;
|
|
68
|
+
const sumLength = Math.max(depth, 1);
|
|
69
|
+
this.remVol = (0, import_running_sum.isNa)(volume) ? this.remVolSum.stepNa(sumLength) : this.remVolSum.step(volume, sumLength);
|
|
70
|
+
this.remVolSum.commit();
|
|
60
71
|
if (this.barCount < depth * 2 + 1) return false;
|
|
61
72
|
let somethingChanged = this.tryFindPivot(true, depth, barIndex);
|
|
62
73
|
somethingChanged = this.tryFindPivot(
|
|
@@ -76,7 +87,8 @@ class ZigZag {
|
|
|
76
87
|
return last !== void 0 ? last : null;
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
79
|
-
* Get extension line to current bar (if extendLast enabled)
|
|
90
|
+
* Get extension line to current bar (if extendLast enabled). Call it after {@link update} of `currentBar`: its
|
|
91
|
+
* volume is the cumulative volume plus the volume of the last max(depth, 1) bars (na before that many bars).
|
|
80
92
|
*/
|
|
81
93
|
getExtension(currentBar, barIndex) {
|
|
82
94
|
if (!this.settings.extendLast) return null;
|
|
@@ -86,7 +98,7 @@ class ZigZag {
|
|
|
86
98
|
const price = isHigh ? currentBar.high : currentBar.low;
|
|
87
99
|
return {
|
|
88
100
|
isHigh,
|
|
89
|
-
volume: this.sumVol,
|
|
101
|
+
volume: this.sumVol + this.remVol,
|
|
90
102
|
start: last.end,
|
|
91
103
|
end: { time: currentBar.time, barIndex, price }
|
|
92
104
|
};
|
|
@@ -160,6 +172,7 @@ class ZigZag {
|
|
|
160
172
|
if (last.isHigh === isHigh) {
|
|
161
173
|
const isMoreExtreme = isHigh ? point.price > last.end.price : point.price < last.end.price;
|
|
162
174
|
if (isMoreExtreme) {
|
|
175
|
+
if (this.pivots.length === 1) last.start = point;
|
|
163
176
|
last.end = point;
|
|
164
177
|
last.volume += this.sumVol;
|
|
165
178
|
this.sumVol = 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/zigzag/zigzag.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * ZigZag Library\n *\n * Identifies trend reversals by connecting pivot highs and lows\n * that exceed a specified percentage deviation threshold.\n *\n * Based on the PineScript ZigZag library v8.\n */\n\nimport type { Bar } from '../../types/index.js';\n\n// ============ Types ============\n\nexport interface ZigZagSettings {\n /** Minimum percentage deviation from previous pivot to register reversal (default: 5.0) */\n devThreshold: number;\n /** Number of bars required for pivot point detection (default: 10) */\n depth: number;\n /** Line color for ZigZag drawing (default: '#2962FF') */\n lineColor: string;\n /** Extend line from last pivot to current bar (default: true) */\n extendLast: boolean;\n /** Display reversal price in labels (default: true) */\n displayReversalPrice: boolean;\n /** Display cumulative volume in labels (default: true) */\n displayCumulativeVolume: boolean;\n /** Display price change from previous pivot (default: true) */\n displayReversalPriceChange: boolean;\n /** Price change display mode: 'Absolute' or 'Percent' (default: 'Absolute') */\n differencePriceMode: 'Absolute' | 'Percent';\n /** Allow both pivot high and low on same bar (default: true) */\n allowZigZagOnOneBar: boolean;\n}\n\nexport interface ZigZagPoint {\n /** Bar timestamp */\n time: number;\n /** Bar index position */\n barIndex: number;\n /** Price at this point */\n price: number;\n}\n\nexport interface ZigZagPivot {\n /** True if this is a pivot high, false for pivot low */\n isHigh: boolean;\n /** Cumulative volume from start to end */\n volume: number;\n /** Starting point of this segment */\n start: ZigZagPoint;\n /** Ending point (the pivot) of this segment */\n end: ZigZagPoint;\n}\n\nexport interface ZigZagResult {\n /** Array of confirmed pivots */\n pivots: ZigZagPivot[];\n /** Extension line to current bar (if extendLast enabled) */\n extension: ZigZagPivot | null;\n}\n\n// ============ Default Settings ============\n\nexport const defaultSettings: ZigZagSettings = {\n devThreshold: 5.0,\n depth: 10,\n lineColor: '#2962FF',\n extendLast: true,\n displayReversalPrice: true,\n displayCumulativeVolume: true,\n displayReversalPriceChange: true,\n differencePriceMode: 'Absolute',\n allowZigZagOnOneBar: true,\n};\n\n// ============ ZigZag Class ============\n\nexport class ZigZag {\n settings: ZigZagSettings;\n pivots: ZigZagPivot[] = [];\n sumVol: number = 0;\n\n private highBuffer: number[] = [];\n private lowBuffer: number[] = [];\n private timeBuffer: number[] = [];\n private barCount: number = 0;\n\n constructor(settings?: Partial<ZigZagSettings>) {\n this.settings = { ...defaultSettings, ...settings };\n }\n\n /**\n * Process a single bar, detecting pivots.\n * Must be called sequentially for each bar.\n * @returns true if a new pivot was detected or updated\n */\n update(bar: Bar, barIndex: number): boolean {\n // Store price data in buffers for lookback\n this.highBuffer.push(bar.high);\n this.lowBuffer.push(bar.low);\n this.timeBuffer.push(bar.time);\n this.barCount++;\n\n const depth = Math.max(2, Math.floor(this.settings.depth / 2));\n this.sumVol += bar.volume ?? 0;\n\n // Need enough bars for pivot detection (depth bars before and after)\n if (this.barCount < depth * 2 + 1) return false;\n\n let somethingChanged = this.tryFindPivot(true, depth, barIndex);\n somethingChanged = this.tryFindPivot(\n false,\n depth,\n barIndex,\n this.settings.allowZigZagOnOneBar || !somethingChanged\n ) || somethingChanged;\n\n return somethingChanged;\n }\n\n /**\n * Get the last confirmed pivot\n */\n lastPivot(): ZigZagPivot | null {\n if (this.pivots.length === 0) return null;\n const last = this.pivots[this.pivots.length - 1];\n return last !== undefined ? last : null;\n }\n\n /**\n * Get extension line to current bar (if extendLast enabled)\n */\n getExtension(currentBar: Bar, barIndex: number): ZigZagPivot | null {\n if (!this.settings.extendLast) return null;\n\n const last = this.lastPivot();\n if (!last) return null;\n\n // Extension goes opposite direction from last pivot\n const isHigh = !last.isHigh;\n const price = isHigh ? currentBar.high : currentBar.low;\n\n return {\n isHigh,\n volume: this.sumVol,\n start: last.end,\n end: { time: currentBar.time, barIndex, price },\n };\n }\n\n // ============ Private Methods ============\n\n private tryFindPivot(\n isHigh: boolean,\n depth: number,\n currentBarIndex: number,\n registerPivot: boolean = true\n ): boolean {\n const point = this.findPivotPoint(isHigh, depth, currentBarIndex);\n if (!point || !registerPivot) return false;\n return this.newPivotPointFound(isHigh, point);\n }\n\n /**\n * Check if a bar from `depth` bars back is a pivot point.\n * A pivot high has prices below it on both sides.\n * A pivot low has prices above it on both sides.\n */\n private findPivotPoint(\n isHigh: boolean,\n depth: number,\n currentBarIndex: number\n ): ZigZagPoint | null {\n const buffer = isHigh ? this.highBuffer : this.lowBuffer;\n const pivotBufferIdx = buffer.length - 1 - depth;\n\n if (pivotBufferIdx < depth) return null;\n\n const pivotPrice = buffer[pivotBufferIdx];\n if (pivotPrice === undefined) return null;\n\n // Check bars AFTER the potential pivot (more recent bars)\n // For a pivot high, subsequent bars must be strictly lower\n // For a pivot low, subsequent bars must be strictly higher\n for (let i = pivotBufferIdx + 1; i < buffer.length; i++) {\n const price = buffer[i];\n if (price === undefined) return null;\n if (isHigh) {\n if (price > pivotPrice) return null;\n } else {\n if (price < pivotPrice) return null;\n }\n }\n\n // Check bars BEFORE the potential pivot (older bars)\n // For a pivot high, previous bars must be lower or equal\n // For a pivot low, previous bars must be higher or equal\n for (let i = pivotBufferIdx - depth; i < pivotBufferIdx; i++) {\n const price = buffer[i];\n if (price === undefined) return null;\n if (isHigh) {\n if (price >= pivotPrice) return null;\n } else {\n if (price <= pivotPrice) return null;\n }\n }\n\n // It's a valid pivot\n const pivotBarIndex = currentBarIndex - depth;\n const pivotTime = this.timeBuffer[pivotBufferIdx];\n if (pivotTime === undefined) return null;\n\n return {\n time: pivotTime,\n barIndex: pivotBarIndex,\n price: pivotPrice,\n };\n }\n\n /**\n * Calculate percentage deviation from base price to new price\n */\n private calcDev(basePrice: number, price: number): number {\n return 100 * (price - basePrice) / Math.abs(basePrice);\n }\n\n /**\n * Handle a newly detected pivot point.\n * Either updates existing pivot (if same direction) or adds new pivot (if direction changed).\n */\n private newPivotPointFound(isHigh: boolean, point: ZigZagPoint): boolean {\n const last = this.lastPivot();\n\n if (!last) {\n // First pivot - create initial entry\n this.pivots.push({\n isHigh,\n volume: this.sumVol,\n start: point,\n end: point,\n });\n this.sumVol = 0;\n return true;\n }\n\n if (last.isHigh === isHigh) {\n // Same direction - check if this is a more extreme price\n const isMoreExtreme = isHigh\n ? point.price > last.end.price\n : point.price < last.end.price;\n\n if (isMoreExtreme) {\n // Update the existing pivot to the new extreme\n last.end = point;\n last.volume += this.sumVol;\n this.sumVol = 0;\n return true;\n }\n } else {\n // Direction change - check if deviation threshold is met\n const dev = this.calcDev(last.end.price, point.price);\n const threshold = this.settings.devThreshold;\n\n // For pivot high -> low transition, need negative deviation\n // For pivot low -> high transition, need positive deviation\n const meetsThreshold = last.isHigh\n ? dev <= -threshold\n : dev >= threshold;\n\n if (meetsThreshold) {\n // Add new pivot\n this.pivots.push({\n isHigh,\n volume: this.sumVol,\n start: last.end,\n end: point,\n });\n this.sumVol = 0;\n return true;\n }\n }\n\n return false;\n }\n}\n\n/**\n * Convenience function to calculate ZigZag on an array of bars.\n * Processes all bars and returns the resulting pivots and extension.\n */\nexport function calculateZigZag(\n bars: Bar[],\n settings?: Partial<ZigZagSettings>\n): ZigZagResult {\n if (bars.length === 0) {\n return { pivots: [], extension: null };\n }\n\n const zz = new ZigZag(settings);\n\n for (let i = 0; i < bars.length; i++) {\n const bar = bars[i];\n if (bar !== undefined) {\n zz.update(bar, i);\n }\n }\n\n const lastBar = bars[bars.length - 1];\n if (lastBar === undefined) {\n return { pivots: zz.pivots, extension: null };\n }\n const extension = zz.getExtension(lastBar, bars.length - 1);\n\n return {\n pivots: zz.pivots,\n extension,\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * ZigZag Library\n *\n * Identifies trend reversals by connecting pivot highs and lows\n * that exceed a specified percentage deviation threshold.\n *\n * Based on the PineScript ZigZag library v8.\n */\n\nimport type { Bar } from '../../types/index.js';\nimport { RunningSum, isNa } from '../../ta/running-sum.js';\n\n// ============ Types ============\n\nexport interface ZigZagSettings {\n /** Minimum percentage deviation from previous pivot to register reversal (default: 5.0) */\n devThreshold: number;\n /** Number of bars required for pivot point detection (default: 10) */\n depth: number;\n /** Line color for ZigZag drawing (default: '#2962FF') */\n lineColor: string;\n /** Extend line from last pivot to current bar (default: true) */\n extendLast: boolean;\n /** Display reversal price in labels (default: true) */\n displayReversalPrice: boolean;\n /** Display cumulative volume in labels (default: true) */\n displayCumulativeVolume: boolean;\n /** Display price change from previous pivot (default: true) */\n displayReversalPriceChange: boolean;\n /** Price change display mode: 'Absolute' or 'Percent' (default: 'Absolute') */\n differencePriceMode: 'Absolute' | 'Percent';\n /** Allow both pivot high and low on same bar (default: true) */\n allowZigZagOnOneBar: boolean;\n}\n\nexport interface ZigZagPoint {\n /** Bar timestamp */\n time: number;\n /** Bar index position */\n barIndex: number;\n /** Price at this point */\n price: number;\n}\n\nexport interface ZigZagPivot {\n /** True if this is a pivot high, false for pivot low */\n isHigh: boolean;\n /** Cumulative volume from start to end: the sum of `volume[depth]` over the bars that built the pivot */\n volume: number;\n /** Starting point of this segment (the first pivot starts on its own end point) */\n start: ZigZagPoint;\n /** Ending point (the pivot) of this segment */\n end: ZigZagPoint;\n}\n\nexport interface ZigZagResult {\n /** Array of confirmed pivots */\n pivots: ZigZagPivot[];\n /** Extension line to current bar (if extendLast enabled) */\n extension: ZigZagPivot | null;\n}\n\n// ============ Default Settings ============\n\nexport const defaultSettings: ZigZagSettings = {\n devThreshold: 5.0,\n depth: 10,\n lineColor: '#2962FF',\n extendLast: true,\n displayReversalPrice: true,\n displayCumulativeVolume: true,\n displayReversalPriceChange: true,\n differencePriceMode: 'Absolute',\n allowZigZagOnOneBar: true,\n};\n\n// ============ ZigZag Class ============\n\nexport class ZigZag {\n settings: ZigZagSettings;\n pivots: ZigZagPivot[] = [];\n sumVol: number = 0;\n\n private highBuffer: number[] = [];\n private lowBuffer: number[] = [];\n private timeBuffer: number[] = [];\n private volumeBuffer: number[] = [];\n private barCount: number = 0;\n /** math.sum(volume, max(depth, 1)) of the current bar, for the extension */\n private remVol: number = NaN;\n private readonly remVolSum = new RunningSum();\n\n constructor(settings?: Partial<ZigZagSettings>) {\n this.settings = { ...defaultSettings, ...settings };\n }\n\n /**\n * Process a single bar, detecting pivots.\n * Must be called sequentially for each bar.\n * @returns true if a new pivot was detected or updated\n */\n update(bar: Bar, barIndex: number): boolean {\n // Store price data in buffers for lookback\n this.highBuffer.push(bar.high);\n this.lowBuffer.push(bar.low);\n this.timeBuffer.push(bar.time);\n const volume = bar.volume ?? NaN;\n this.volumeBuffer.push(volume);\n this.barCount++;\n\n const depth = Math.max(2, Math.floor(this.settings.depth / 2));\n // PineScript: sumVol += nz(volume[depth]); the extension adds math.sum(volume, max(depth, 1)) (#184)\n const pastVolume = this.volumeBuffer[this.volumeBuffer.length - 1 - depth];\n this.sumVol += pastVolume === undefined || Number.isNaN(pastVolume) ? 0 : pastVolume;\n const sumLength = Math.max(depth, 1);\n this.remVol = isNa(volume) ? this.remVolSum.stepNa(sumLength) : this.remVolSum.step(volume, sumLength);\n this.remVolSum.commit();\n\n // Need enough bars for pivot detection (depth bars before and after)\n if (this.barCount < depth * 2 + 1) return false;\n\n let somethingChanged = this.tryFindPivot(true, depth, barIndex);\n somethingChanged = this.tryFindPivot(\n false,\n depth,\n barIndex,\n this.settings.allowZigZagOnOneBar || !somethingChanged\n ) || somethingChanged;\n\n return somethingChanged;\n }\n\n /**\n * Get the last confirmed pivot\n */\n lastPivot(): ZigZagPivot | null {\n if (this.pivots.length === 0) return null;\n const last = this.pivots[this.pivots.length - 1];\n return last !== undefined ? last : null;\n }\n\n /**\n * Get extension line to current bar (if extendLast enabled). Call it after {@link update} of `currentBar`: its\n * volume is the cumulative volume plus the volume of the last max(depth, 1) bars (na before that many bars).\n */\n getExtension(currentBar: Bar, barIndex: number): ZigZagPivot | null {\n if (!this.settings.extendLast) return null;\n\n const last = this.lastPivot();\n if (!last) return null;\n\n // Extension goes opposite direction from last pivot\n const isHigh = !last.isHigh;\n const price = isHigh ? currentBar.high : currentBar.low;\n\n return {\n isHigh,\n volume: this.sumVol + this.remVol,\n start: last.end,\n end: { time: currentBar.time, barIndex, price },\n };\n }\n\n // ============ Private Methods ============\n\n private tryFindPivot(\n isHigh: boolean,\n depth: number,\n currentBarIndex: number,\n registerPivot: boolean = true\n ): boolean {\n const point = this.findPivotPoint(isHigh, depth, currentBarIndex);\n if (!point || !registerPivot) return false;\n return this.newPivotPointFound(isHigh, point);\n }\n\n /**\n * Check if a bar from `depth` bars back is a pivot point.\n * A pivot high has prices below it on both sides.\n * A pivot low has prices above it on both sides.\n */\n private findPivotPoint(\n isHigh: boolean,\n depth: number,\n currentBarIndex: number\n ): ZigZagPoint | null {\n const buffer = isHigh ? this.highBuffer : this.lowBuffer;\n const pivotBufferIdx = buffer.length - 1 - depth;\n\n if (pivotBufferIdx < depth) return null;\n\n const pivotPrice = buffer[pivotBufferIdx];\n if (pivotPrice === undefined) return null;\n\n // Check bars AFTER the potential pivot (more recent bars)\n // For a pivot high, subsequent bars must be strictly lower\n // For a pivot low, subsequent bars must be strictly higher\n for (let i = pivotBufferIdx + 1; i < buffer.length; i++) {\n const price = buffer[i];\n if (price === undefined) return null;\n if (isHigh) {\n if (price > pivotPrice) return null;\n } else {\n if (price < pivotPrice) return null;\n }\n }\n\n // Check bars BEFORE the potential pivot (older bars)\n // For a pivot high, previous bars must be lower or equal\n // For a pivot low, previous bars must be higher or equal\n for (let i = pivotBufferIdx - depth; i < pivotBufferIdx; i++) {\n const price = buffer[i];\n if (price === undefined) return null;\n if (isHigh) {\n if (price >= pivotPrice) return null;\n } else {\n if (price <= pivotPrice) return null;\n }\n }\n\n // It's a valid pivot\n const pivotBarIndex = currentBarIndex - depth;\n const pivotTime = this.timeBuffer[pivotBufferIdx];\n if (pivotTime === undefined) return null;\n\n return {\n time: pivotTime,\n barIndex: pivotBarIndex,\n price: pivotPrice,\n };\n }\n\n /**\n * Calculate percentage deviation from base price to new price\n */\n private calcDev(basePrice: number, price: number): number {\n return 100 * (price - basePrice) / Math.abs(basePrice);\n }\n\n /**\n * Handle a newly detected pivot point.\n * Either updates existing pivot (if same direction) or adds new pivot (if direction changed).\n */\n private newPivotPointFound(isHigh: boolean, point: ZigZagPoint): boolean {\n const last = this.lastPivot();\n\n if (!last) {\n // First pivot - create initial entry\n this.pivots.push({\n isHigh,\n volume: this.sumVol,\n start: point,\n end: point,\n });\n this.sumVol = 0;\n return true;\n }\n\n if (last.isHigh === isHigh) {\n // Same direction - check if this is a more extreme price\n const isMoreExtreme = isHigh\n ? point.price > last.end.price\n : point.price < last.end.price;\n\n if (isMoreExtreme) {\n // Update the existing pivot to the new extreme; the first pivot moves its start with its end (#184)\n if (this.pivots.length === 1) last.start = point;\n last.end = point;\n last.volume += this.sumVol;\n this.sumVol = 0;\n return true;\n }\n } else {\n // Direction change - check if deviation threshold is met\n const dev = this.calcDev(last.end.price, point.price);\n const threshold = this.settings.devThreshold;\n\n // For pivot high -> low transition, need negative deviation\n // For pivot low -> high transition, need positive deviation\n const meetsThreshold = last.isHigh\n ? dev <= -threshold\n : dev >= threshold;\n\n if (meetsThreshold) {\n // Add new pivot\n this.pivots.push({\n isHigh,\n volume: this.sumVol,\n start: last.end,\n end: point,\n });\n this.sumVol = 0;\n return true;\n }\n }\n\n return false;\n }\n}\n\n/**\n * Convenience function to calculate ZigZag on an array of bars.\n * Processes all bars and returns the resulting pivots and extension.\n */\nexport function calculateZigZag(\n bars: Bar[],\n settings?: Partial<ZigZagSettings>\n): ZigZagResult {\n if (bars.length === 0) {\n return { pivots: [], extension: null };\n }\n\n const zz = new ZigZag(settings);\n\n for (let i = 0; i < bars.length; i++) {\n const bar = bars[i];\n if (bar !== undefined) {\n zz.update(bar, i);\n }\n }\n\n const lastBar = bars[bars.length - 1];\n if (lastBar === undefined) {\n return { pivots: zz.pivots, extension: null };\n }\n const extension = zz.getExtension(lastBar, bars.length - 1);\n\n return {\n pivots: zz.pivots,\n extension,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,yBAAiC;AAsD1B,MAAM,kBAAkC;AAAA,EAC7C,cAAc;AAAA,EACd,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,4BAA4B;AAAA,EAC5B,qBAAqB;AAAA,EACrB,qBAAqB;AACvB;AAIO,MAAM,OAAO;AAAA,EAClB;AAAA,EACA,SAAwB,CAAC;AAAA,EAC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,UACb,OAAO,KAAK;AAAA,UACZ,KAAK;AAAA,QACP,CAAC;AACD,aAAK,SAAS;AACd,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAMO,SAAS,gBACd,MACA,UACc;AACd,MAAI,KAAK,WAAW,GAAG;AACrB,WAAO,EAAE,QAAQ,CAAC,GAAG,WAAW,KAAK;AAAA,EACvC;AAEA,QAAM,KAAK,IAAI,OAAO,QAAQ;AAE9B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,QAAQ,QAAW;AACrB,SAAG,OAAO,KAAK,CAAC;AAAA,IAClB;AAAA,EACF;AAEA,QAAM,UAAU,KAAK,KAAK,SAAS,CAAC;AACpC,MAAI,YAAY,QAAW;AACzB,WAAO,EAAE,QAAQ,GAAG,QAAQ,WAAW,KAAK;AAAA,EAC9C;AACA,QAAM,YAAY,GAAG,aAAa,SAAS,KAAK,SAAS,CAAC;AAE1D,SAAO;AAAA,IACL,QAAQ,GAAG;AAAA,IACX;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module runtime
|
|
6
6
|
*/
|
|
7
7
|
export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, getActivePlots, } from './runtime.js';
|
|
8
|
-
export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_symbol, input_time, enableAutoRecalculate, disableAutoRecalculate, resetInputs, } from './inputs.js';
|
|
8
|
+
export { input_int, input_float, input_bool, input_string, input_text_area, input_source, input_timeframe, input_session, input_symbol, input_time, enableAutoRecalculate, disableAutoRecalculate, resetInputs, } from './inputs.js';
|
|
9
9
|
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputCondition, InputOptions, OhlcvData, PlotConfig, } from './types.js';
|
|
10
10
|
export { isInputActive } from './input-active.js';
|
|
11
11
|
export { LightweightChartsAdapter } from './adapters/LightweightChartsAdapter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,SAAS,EACP,UAAU,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,YAAY,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,SAAS,EACP,UAAU,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,YAAY,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -34,6 +34,7 @@ __export(runtime_exports, {
|
|
|
34
34
|
input_source: () => import_inputs.input_source,
|
|
35
35
|
input_string: () => import_inputs.input_string,
|
|
36
36
|
input_symbol: () => import_inputs.input_symbol,
|
|
37
|
+
input_text_area: () => import_inputs.input_text_area,
|
|
37
38
|
input_time: () => import_inputs.input_time,
|
|
38
39
|
input_timeframe: () => import_inputs.input_timeframe,
|
|
39
40
|
isInputActive: () => import_input_active.isInputActive,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/runtime/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview OakScriptJS Runtime Module\n * Provides global context management, plot functions, and input handling\n * for indicators that draw through a ChartAdapter\n * @module runtime\n */\n\n// Core runtime exports\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n getActivePlots,\n} from './runtime.js';\n\n// Input function exports\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_source,\n input_timeframe,\n input_session,\n input_symbol,\n input_time,\n enableAutoRecalculate,\n disableAutoRecalculate,\n resetInputs,\n} from './inputs.js';\n\n// Type exports\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n} from './types.js';\n\nexport { isInputActive } from './input-active.js';\n\n// Adapter exports\nexport { LightweightChartsAdapter } from './adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './adapters/SimpleInputAdapter.js';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qBAUO;AAGP,
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview OakScriptJS Runtime Module\n * Provides global context management, plot functions, and input handling\n * for indicators that draw through a ChartAdapter\n * @module runtime\n */\n\n// Core runtime exports\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n getActivePlots,\n} from './runtime.js';\n\n// Input function exports\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 enableAutoRecalculate,\n disableAutoRecalculate,\n resetInputs,\n} from './inputs.js';\n\n// Type exports\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n} from './types.js';\n\nexport { isInputActive } from './input-active.js';\n\n// Adapter exports\nexport { LightweightChartsAdapter } from './adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './adapters/SimpleInputAdapter.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qBAUO;AAGP,oBAcO;AAgBP,0BAA8B;AAG9B,sCAAyC;AAEzC,gCAAmC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -54,6 +54,15 @@ export declare function input_bool(defval: boolean, title?: string): boolean;
|
|
|
54
54
|
* @returns Current string value
|
|
55
55
|
*/
|
|
56
56
|
export declare function input_string(defval: string, title?: string, options?: string[]): string;
|
|
57
|
+
/**
|
|
58
|
+
* Register a multi-line text input (PineScript `input.text_area`, #184)
|
|
59
|
+
* First call registers with defval, subsequent calls return current value
|
|
60
|
+
* @param defval - Default text; lines are separated by "
|
|
61
|
+
"
|
|
62
|
+
* @param title - Display title (optional)
|
|
63
|
+
* @returns Current text
|
|
64
|
+
*/
|
|
65
|
+
export declare function input_text_area(defval: string, title?: string): string;
|
|
57
66
|
/**
|
|
58
67
|
* Register a timeframe input (PineScript `input.timeframe`)
|
|
59
68
|
* First call registers with defval, subsequent calls return current value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/runtime/inputs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,YAAY,CAAC;AAS5D;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAoBD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,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MAAM,EAAE,GAAG,MAAM,CAMvF;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CA+BrE"}
|
|
@@ -27,6 +27,7 @@ __export(inputs_exports, {
|
|
|
27
27
|
input_source: () => input_source,
|
|
28
28
|
input_string: () => input_string,
|
|
29
29
|
input_symbol: () => input_symbol,
|
|
30
|
+
input_text_area: () => input_text_area,
|
|
30
31
|
input_time: () => input_time,
|
|
31
32
|
input_timeframe: () => input_timeframe,
|
|
32
33
|
resetInputs: () => resetInputs
|
|
@@ -178,6 +179,13 @@ function registerOnce(config) {
|
|
|
178
179
|
}
|
|
179
180
|
return context.inputs.getValue(config.id);
|
|
180
181
|
}
|
|
182
|
+
function input_text_area(defval, title) {
|
|
183
|
+
if (!(0, import_runtime.getContext)()) {
|
|
184
|
+
return defval;
|
|
185
|
+
}
|
|
186
|
+
const value = registerOnce({ id: generateInputId(title, defval, "text_area"), type: "text_area", defval, title });
|
|
187
|
+
return typeof value === "string" ? value : defval;
|
|
188
|
+
}
|
|
181
189
|
function input_timeframe(defval, title, options) {
|
|
182
190
|
if (!(0, import_runtime.getContext)()) {
|
|
183
191
|
return defval;
|