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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,MAAW,EAAE,YAAoB;IACpF,IAAI,MAAM,CAAC,MAAM,GAAG,MA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,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7B,KAAK,KAAK,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC,KAAK,KAAK,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC,KAAK,KAAK,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC,KAAK,KAAK,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC;YACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAoB,EACpB,UAAqB;IAErB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC,KAAK;QAC7C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;KACnC,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -179,6 +179,7 @@ export {
|
|
|
179
179
|
input_float,
|
|
180
180
|
input_bool,
|
|
181
181
|
input_string,
|
|
182
|
+
input_text_area,
|
|
182
183
|
input_source,
|
|
183
184
|
input_timeframe,
|
|
184
185
|
input_session,
|
|
@@ -218,7 +219,7 @@ export type { LightweightSeriesDefinitions } from './runtime/adapters/Lightweigh
|
|
|
218
219
|
export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
|
|
219
220
|
|
|
220
221
|
// Version
|
|
221
|
-
export const VERSION = '0.11.
|
|
222
|
+
export const VERSION = '0.11.5';
|
|
222
223
|
|
|
223
224
|
/**
|
|
224
225
|
* Library information
|
package/src/input.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export interface InputValue<T> {
|
|
11
11
|
/** Input type identifier */
|
|
12
|
-
type: 'int' | 'float' | 'source' | 'bool' | 'string' | 'timeframe' | 'session' | 'time' | 'symbol';
|
|
12
|
+
type: 'int' | 'float' | 'source' | 'bool' | 'string' | 'text_area' | 'timeframe' | 'session' | 'time' | 'symbol';
|
|
13
13
|
/** Default value */
|
|
14
14
|
defaultValue: T;
|
|
15
15
|
/** Current value (initially equals defaultValue) */
|
|
@@ -89,9 +89,9 @@ export interface TimeInputOptions {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Source type for price data
|
|
92
|
+
* Source type for price data (PineScript `input.source` built-in sources, `volume` included)
|
|
93
93
|
*/
|
|
94
|
-
export type SourceType = 'open' | 'high' | 'low' | 'close' | 'hl2' | 'hlc3' | 'ohlc4' | 'hlcc4';
|
|
94
|
+
export type SourceType = 'open' | 'high' | 'low' | 'close' | 'hl2' | 'hlc3' | 'ohlc4' | 'hlcc4' | 'volume';
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Input helper functions for creating indicator parameters
|
|
@@ -163,7 +163,7 @@ export const input = {
|
|
|
163
163
|
defaultValue,
|
|
164
164
|
value: defaultValue,
|
|
165
165
|
title: options.title,
|
|
166
|
-
options: ['open', 'high', 'low', 'close', 'hl2', 'hlc3', 'ohlc4', 'hlcc4'],
|
|
166
|
+
options: ['open', 'high', 'low', 'close', 'hl2', 'hlc3', 'ohlc4', 'hlcc4', 'volume'],
|
|
167
167
|
};
|
|
168
168
|
},
|
|
169
169
|
|
|
@@ -210,6 +210,30 @@ export const input = {
|
|
|
210
210
|
};
|
|
211
211
|
},
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Create a multi-line text input parameter (PineScript `input.text_area`, #184)
|
|
215
|
+
* @param defaultValue - Default text; lines are separated by "
|
|
216
|
+
"
|
|
217
|
+
* @param options - Additional options (title)
|
|
218
|
+
* @returns Input value object
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* const list = input.text_area('AAPL, MSFT
|
|
223
|
+
BTCUSD', { title: 'Symbol list' });
|
|
224
|
+
* console.log(list.value); // 'AAPL, MSFT
|
|
225
|
+
BTCUSD'
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
text_area(defaultValue: string, options: TimeInputOptions = {}): InputValue<string> {
|
|
229
|
+
return {
|
|
230
|
+
type: 'text_area' as const,
|
|
231
|
+
defaultValue,
|
|
232
|
+
value: defaultValue,
|
|
233
|
+
title: options.title,
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
|
|
213
237
|
/**
|
|
214
238
|
* Create a timeframe input parameter (PineScript `input.timeframe`)
|
|
215
239
|
* @param defaultValue - Default timeframe string ("60", "1D", "W"); "" means the chart timeframe
|
package/src/lib/zigzag/zigzag.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { Bar } from '../../types/index.js';
|
|
11
|
+
import { RunningSum, isNa } from '../../ta/running-sum.js';
|
|
11
12
|
|
|
12
13
|
// ============ Types ============
|
|
13
14
|
|
|
@@ -44,9 +45,9 @@ export interface ZigZagPoint {
|
|
|
44
45
|
export interface ZigZagPivot {
|
|
45
46
|
/** True if this is a pivot high, false for pivot low */
|
|
46
47
|
isHigh: boolean;
|
|
47
|
-
/** Cumulative volume from start to end */
|
|
48
|
+
/** Cumulative volume from start to end: the sum of `volume[depth]` over the bars that built the pivot */
|
|
48
49
|
volume: number;
|
|
49
|
-
/** Starting point of this segment */
|
|
50
|
+
/** Starting point of this segment (the first pivot starts on its own end point) */
|
|
50
51
|
start: ZigZagPoint;
|
|
51
52
|
/** Ending point (the pivot) of this segment */
|
|
52
53
|
end: ZigZagPoint;
|
|
@@ -83,7 +84,11 @@ export class ZigZag {
|
|
|
83
84
|
private highBuffer: number[] = [];
|
|
84
85
|
private lowBuffer: number[] = [];
|
|
85
86
|
private timeBuffer: number[] = [];
|
|
87
|
+
private volumeBuffer: number[] = [];
|
|
86
88
|
private barCount: number = 0;
|
|
89
|
+
/** math.sum(volume, max(depth, 1)) of the current bar, for the extension */
|
|
90
|
+
private remVol: number = NaN;
|
|
91
|
+
private readonly remVolSum = new RunningSum();
|
|
87
92
|
|
|
88
93
|
constructor(settings?: Partial<ZigZagSettings>) {
|
|
89
94
|
this.settings = { ...defaultSettings, ...settings };
|
|
@@ -99,10 +104,17 @@ export class ZigZag {
|
|
|
99
104
|
this.highBuffer.push(bar.high);
|
|
100
105
|
this.lowBuffer.push(bar.low);
|
|
101
106
|
this.timeBuffer.push(bar.time);
|
|
107
|
+
const volume = bar.volume ?? NaN;
|
|
108
|
+
this.volumeBuffer.push(volume);
|
|
102
109
|
this.barCount++;
|
|
103
110
|
|
|
104
111
|
const depth = Math.max(2, Math.floor(this.settings.depth / 2));
|
|
105
|
-
|
|
112
|
+
// PineScript: sumVol += nz(volume[depth]); the extension adds math.sum(volume, max(depth, 1)) (#184)
|
|
113
|
+
const pastVolume = this.volumeBuffer[this.volumeBuffer.length - 1 - depth];
|
|
114
|
+
this.sumVol += pastVolume === undefined || Number.isNaN(pastVolume) ? 0 : pastVolume;
|
|
115
|
+
const sumLength = Math.max(depth, 1);
|
|
116
|
+
this.remVol = isNa(volume) ? this.remVolSum.stepNa(sumLength) : this.remVolSum.step(volume, sumLength);
|
|
117
|
+
this.remVolSum.commit();
|
|
106
118
|
|
|
107
119
|
// Need enough bars for pivot detection (depth bars before and after)
|
|
108
120
|
if (this.barCount < depth * 2 + 1) return false;
|
|
@@ -128,7 +140,8 @@ export class ZigZag {
|
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
/**
|
|
131
|
-
* Get extension line to current bar (if extendLast enabled)
|
|
143
|
+
* Get extension line to current bar (if extendLast enabled). Call it after {@link update} of `currentBar`: its
|
|
144
|
+
* volume is the cumulative volume plus the volume of the last max(depth, 1) bars (na before that many bars).
|
|
132
145
|
*/
|
|
133
146
|
getExtension(currentBar: Bar, barIndex: number): ZigZagPivot | null {
|
|
134
147
|
if (!this.settings.extendLast) return null;
|
|
@@ -142,7 +155,7 @@ export class ZigZag {
|
|
|
142
155
|
|
|
143
156
|
return {
|
|
144
157
|
isHigh,
|
|
145
|
-
volume: this.sumVol,
|
|
158
|
+
volume: this.sumVol + this.remVol,
|
|
146
159
|
start: last.end,
|
|
147
160
|
end: { time: currentBar.time, barIndex, price },
|
|
148
161
|
};
|
|
@@ -250,7 +263,8 @@ export class ZigZag {
|
|
|
250
263
|
: point.price < last.end.price;
|
|
251
264
|
|
|
252
265
|
if (isMoreExtreme) {
|
|
253
|
-
// Update the existing pivot to the new extreme
|
|
266
|
+
// Update the existing pivot to the new extreme; the first pivot moves its start with its end (#184)
|
|
267
|
+
if (this.pivots.length === 1) last.start = point;
|
|
254
268
|
last.end = point;
|
|
255
269
|
last.volume += this.sumVol;
|
|
256
270
|
this.sumVol = 0;
|
package/src/runtime/index.ts
CHANGED
package/src/runtime/inputs.ts
CHANGED
|
@@ -245,6 +245,22 @@ function registerOnce(config: InputConfig): unknown {
|
|
|
245
245
|
return context.inputs.getValue(config.id);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Register a multi-line text input (PineScript `input.text_area`, #184)
|
|
250
|
+
* First call registers with defval, subsequent calls return current value
|
|
251
|
+
* @param defval - Default text; lines are separated by "
|
|
252
|
+
"
|
|
253
|
+
* @param title - Display title (optional)
|
|
254
|
+
* @returns Current text
|
|
255
|
+
*/
|
|
256
|
+
export function input_text_area(defval: string, title?: string): string {
|
|
257
|
+
if (!getContext()) {
|
|
258
|
+
return defval;
|
|
259
|
+
}
|
|
260
|
+
const value = registerOnce({ id: generateInputId(title, defval, 'text_area'), type: 'text_area', defval, title });
|
|
261
|
+
return typeof value === 'string' ? value : defval;
|
|
262
|
+
}
|
|
263
|
+
|
|
248
264
|
/**
|
|
249
265
|
* Register a timeframe input (PineScript `input.timeframe`)
|
|
250
266
|
* First call registers with defval, subsequent calls return current value
|
package/src/runtime/types.ts
CHANGED
|
@@ -70,9 +70,10 @@ export interface InputConfig {
|
|
|
70
70
|
id: string;
|
|
71
71
|
/**
|
|
72
72
|
* Type of input. `timeframe` and `session` values are strings ("60", "1D", "0930-1600:23456";
|
|
73
|
-
* an empty timeframe means the chart timeframe), `time` values are UNIX times in milliseconds.
|
|
73
|
+
* an empty timeframe means the chart timeframe), `time` values are UNIX times in milliseconds. A `text_area`
|
|
74
|
+
* value is a string that can hold several lines.
|
|
74
75
|
*/
|
|
75
|
-
type: 'int' | 'float' | 'bool' | 'string' | 'source' | 'color' | 'timeframe' | 'session' | 'time' | 'symbol';
|
|
76
|
+
type: 'int' | 'float' | 'bool' | 'string' | 'text_area' | 'source' | 'color' | 'timeframe' | 'session' | 'time' | 'symbol';
|
|
76
77
|
/** Default value */
|
|
77
78
|
defval: unknown;
|
|
78
79
|
/** Display title */
|
|
@@ -95,7 +96,7 @@ export interface InputConfig {
|
|
|
95
96
|
confirm?: boolean;
|
|
96
97
|
/**
|
|
97
98
|
* Where the input value is shown (PineScript `display`); not set means the PineScript default: 'none' for
|
|
98
|
-
* bool, color and
|
|
99
|
+
* bool, color, time and text_area inputs, 'all' for the others
|
|
99
100
|
*/
|
|
100
101
|
display?: 'all' | 'none' | 'data_window' | 'status_line';
|
|
101
102
|
/**
|
package/src/script/index.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Execution model: the host calls {@link executeScript} with the script body,
|
|
15
15
|
* the bars and the current input values. Declaration calls (indicator, input.*,
|
|
16
|
-
* plot, hline, fill, alertcondition) run as the body executes and are collected
|
|
16
|
+
* plot, hline, fill, alertcondition, alert) run as the body executes and are collected
|
|
17
17
|
* into a {@link ScriptRunResult}: the declarative configs (inputConfig,
|
|
18
18
|
* plotConfig, hlineConfig, fillConfig) plus an IndicatorResult with the plot
|
|
19
19
|
* data. Re-running the body with new bars or inputs is PineScript's
|
|
@@ -145,7 +145,10 @@ export interface ScriptRunResult {
|
|
|
145
145
|
* colours, candles and bars, and the drawings (labels, lines, boxes, linefills, polylines, tables) alive after the
|
|
146
146
|
* last bar.
|
|
147
147
|
*/
|
|
148
|
-
result: IndicatorResult & { alerts?: AlertState[] };
|
|
148
|
+
result: IndicatorResult & { alerts?: AlertState[]; alertCalls?: AlertCall[] };
|
|
149
|
+
/** The script called alert() during the run (PineScript `hasAlertFunction` is known at compile time: a host that
|
|
150
|
+
* needs it before any bar runs reads the source). */
|
|
151
|
+
hasAlertFunction: boolean;
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
export interface AlertConditionConfig {
|
|
@@ -154,12 +157,24 @@ export interface AlertConditionConfig {
|
|
|
154
157
|
message?: string;
|
|
155
158
|
}
|
|
156
159
|
|
|
157
|
-
/** Per-run alert evaluation: whether the condition is true on the last bar. */
|
|
160
|
+
/** Per-run alert evaluation: whether the condition is true on the last bar, and on which bars it is true. */
|
|
158
161
|
export interface AlertState {
|
|
159
162
|
id: string;
|
|
160
163
|
title: string;
|
|
161
164
|
message?: string;
|
|
162
165
|
triggered: boolean;
|
|
166
|
+
/** Times of the bars (as given in the input bars) on which the condition is true (not na, not 0), oldest first. */
|
|
167
|
+
times: number[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** How often an alert() call may trigger the alert (PineScript `alert.freq_*`). */
|
|
171
|
+
export type AlertFrequency = 'all' | 'once_per_bar' | 'once_per_bar_close';
|
|
172
|
+
|
|
173
|
+
/** One alert() call: the time of the bar it ran on (as given in the input bars), its message and frequency. */
|
|
174
|
+
export interface AlertCall {
|
|
175
|
+
time: number;
|
|
176
|
+
message: string;
|
|
177
|
+
freq: AlertFrequency;
|
|
163
178
|
}
|
|
164
179
|
|
|
165
180
|
/** Handle returned by plot()/hline() so fill() can reference them. */
|
|
@@ -196,6 +211,8 @@ interface Collector {
|
|
|
196
211
|
plotBars: Record<string, PlotBarData[]>;
|
|
197
212
|
alertConfig: AlertConditionConfig[];
|
|
198
213
|
alerts: AlertState[];
|
|
214
|
+
alertCalls: AlertCall[];
|
|
215
|
+
hasAlertFunction: boolean;
|
|
199
216
|
strategy?: StrategyRun;
|
|
200
217
|
}
|
|
201
218
|
|
|
@@ -250,6 +267,8 @@ function freshCollector(inputValues: Record<string, unknown>): Collector {
|
|
|
250
267
|
plotBars: {},
|
|
251
268
|
alertConfig: [],
|
|
252
269
|
alerts: [],
|
|
270
|
+
alertCalls: [],
|
|
271
|
+
hasAlertFunction: false,
|
|
253
272
|
};
|
|
254
273
|
}
|
|
255
274
|
|
|
@@ -339,7 +358,9 @@ export function executeScript(
|
|
|
339
358
|
plotBars: Object.keys(c.plotBars).length ? c.plotBars : undefined,
|
|
340
359
|
...drawingOutputs(ctxBars.bars, chartCtx.timeUnit),
|
|
341
360
|
alerts: c.alerts.length ? c.alerts : undefined,
|
|
361
|
+
alertCalls: c.alertCalls.length ? c.alertCalls : undefined,
|
|
342
362
|
},
|
|
363
|
+
hasAlertFunction: c.hasAlertFunction,
|
|
343
364
|
};
|
|
344
365
|
} finally {
|
|
345
366
|
ctx = null;
|
|
@@ -457,6 +478,11 @@ export const input = {
|
|
|
457
478
|
string(defval: string, title?: string, opts: StringInputOptions = {}): string {
|
|
458
479
|
return registerInput<string>({ type: 'string', defval, title, options: opts.options, ...common(opts) }, 'input_string');
|
|
459
480
|
},
|
|
481
|
+
/** Multi-line text ("
|
|
482
|
+
" between the lines), e.g. a list a script parses (#184). */
|
|
483
|
+
text_area(defval: string, title?: string, opts: InputOptions = {}): string {
|
|
484
|
+
return registerInput<string>({ type: 'text_area', defval, title, ...common(opts) }, 'input_text_area');
|
|
485
|
+
},
|
|
460
486
|
/**
|
|
461
487
|
* Declares a colour input. As in PineScript, the default keeps an alpha of 2 decimals: an input default
|
|
462
488
|
* `color.new(c, 90)` has the alpha byte 26 (25 in the script). A value given by the host is not changed.
|
|
@@ -1571,6 +1597,8 @@ export interface ChartContext {
|
|
|
1571
1597
|
basecurrency?: string;
|
|
1572
1598
|
/** Root of the symbol (PineScript `syminfo.root`): "BTC" for CME:BTC1!, "ES" for CME_MINI:ES1!, "AAPL" for NASDAQ:AAPL (#180) */
|
|
1573
1599
|
root?: string;
|
|
1600
|
+
/** Description of the symbol (PineScript `syminfo.description`): "Apple Inc." for NASDAQ:AAPL, "Bitcoin / U.S. dollar" for BITSTAMP:BTCUSD (#184) */
|
|
1601
|
+
description?: string;
|
|
1574
1602
|
/** Chart foreground colour (PineScript `chart.fg_color`), e.g. "#DBDBDB" on a dark chart */
|
|
1575
1603
|
foregroundColor?: string;
|
|
1576
1604
|
/** Chart background colour (PineScript `chart.bg_color`), e.g. "#0F0F0F" on a dark chart */
|
|
@@ -1615,6 +1643,7 @@ export type SymbolInfo = Pick<
|
|
|
1615
1643
|
| 'currency'
|
|
1616
1644
|
| 'basecurrency'
|
|
1617
1645
|
| 'root'
|
|
1646
|
+
| 'description'
|
|
1618
1647
|
>;
|
|
1619
1648
|
|
|
1620
1649
|
/** A request of `request.security` for another symbol whose bars the host has not given. */
|
|
@@ -1721,7 +1750,10 @@ function symbolProperty(key: 'mintick' | 'pointvalue' | 'mincontract'): number {
|
|
|
1721
1750
|
}
|
|
1722
1751
|
|
|
1723
1752
|
/** A text value of the chart or the symbol that the host passes in the chart context. */
|
|
1724
|
-
function chartText(
|
|
1753
|
+
function chartText(
|
|
1754
|
+
key: 'symbolType' | 'currency' | 'basecurrency' | 'root' | 'description' | 'foregroundColor' | 'backgroundColor',
|
|
1755
|
+
name: string
|
|
1756
|
+
): string {
|
|
1725
1757
|
collector();
|
|
1726
1758
|
const value = chartCtx[key];
|
|
1727
1759
|
if (value === undefined) {
|
|
@@ -1742,7 +1774,7 @@ function symbolScale(): [number, number] {
|
|
|
1742
1774
|
/**
|
|
1743
1775
|
* PineScript `syminfo.timezone`, `syminfo.tickerid`, `syminfo.session` (session type), `syminfo.mintick`,
|
|
1744
1776
|
* `syminfo.minmove`, `syminfo.pricescale`, `syminfo.pointvalue`, `syminfo.mincontract`, `syminfo.type`,
|
|
1745
|
-
* `syminfo.currency`, `syminfo.basecurrency` and `syminfo.
|
|
1777
|
+
* `syminfo.currency`, `syminfo.basecurrency`, `syminfo.root` and `syminfo.description`, from the chart context.
|
|
1746
1778
|
*/
|
|
1747
1779
|
export const syminfo = {
|
|
1748
1780
|
get mintick(): number {
|
|
@@ -1786,6 +1818,9 @@ export const syminfo = {
|
|
|
1786
1818
|
get root(): string {
|
|
1787
1819
|
return chartText('root', 'syminfo.root');
|
|
1788
1820
|
},
|
|
1821
|
+
get description(): string {
|
|
1822
|
+
return chartText('description', 'syminfo.description');
|
|
1823
|
+
},
|
|
1789
1824
|
};
|
|
1790
1825
|
|
|
1791
1826
|
/** A calendar function: `(time, timezone?)` on a UNIX time or on a Series of times. */
|
|
@@ -2200,6 +2235,7 @@ function runExternal<T extends SecurityValue>(
|
|
|
2200
2235
|
currency: info.currency,
|
|
2201
2236
|
basecurrency: info.basecurrency,
|
|
2202
2237
|
root: info.root,
|
|
2238
|
+
description: info.description,
|
|
2203
2239
|
};
|
|
2204
2240
|
try {
|
|
2205
2241
|
result = expression();
|
|
@@ -2379,10 +2415,50 @@ export function alertcondition(condition: Series, title: string, message?: strin
|
|
|
2379
2415
|
const c = collector();
|
|
2380
2416
|
const id = `alert${c.alertConfig.length}`;
|
|
2381
2417
|
c.alertConfig.push({ id, title, message });
|
|
2382
|
-
const
|
|
2383
|
-
|
|
2418
|
+
const values = condition.toArray();
|
|
2419
|
+
const b = ctxBars.bars;
|
|
2420
|
+
const times: number[] = [];
|
|
2421
|
+
for (let i = 0; i < values.length && i < b.length; i++) {
|
|
2422
|
+
const v = values[i]!;
|
|
2423
|
+
if (!isNA(v) && v !== 0) times.push(b[i]!.time as number);
|
|
2424
|
+
}
|
|
2425
|
+
const last = values.length ? values[values.length - 1]! : NaN;
|
|
2426
|
+
c.alerts.push({ id, title, message, triggered: !isNA(last) && last !== 0, times });
|
|
2384
2427
|
}
|
|
2385
2428
|
|
|
2429
|
+
const ALERT_FREQUENCIES: readonly AlertFrequency[] = ['all', 'once_per_bar', 'once_per_bar_close'];
|
|
2430
|
+
|
|
2431
|
+
/**
|
|
2432
|
+
* PineScript `alert(message, freq)`, with the `alert.freq_*` constants: the calls are collected per bar with their
|
|
2433
|
+
* message and frequency (`result.alertCalls`) for the host's alert engine, which fires the ones made on the realtime
|
|
2434
|
+
* bar. Called inside eachBar() / strategy.eachBar() it is a call on the current bar; at the top level of the script
|
|
2435
|
+
* (which PineScript runs on every bar) it is a call on every bar, `message` then being a text or one text per bar
|
|
2436
|
+
* (a bar whose text is na makes no call). Default frequency: `alert.freq_once_per_bar`.
|
|
2437
|
+
*/
|
|
2438
|
+
function alertImpl(message: string | ReadonlyArray<string | undefined>, freq: AlertFrequency = 'once_per_bar'): void {
|
|
2439
|
+
const c = collector();
|
|
2440
|
+
if (!ALERT_FREQUENCIES.includes(freq)) {
|
|
2441
|
+
throw new Error(`alert(): freq must be alert.freq_all, alert.freq_once_per_bar or alert.freq_once_per_bar_close, not ${String(freq)}.`);
|
|
2442
|
+
}
|
|
2443
|
+
c.hasAlertFunction = true;
|
|
2444
|
+
const b = ctxBars.bars;
|
|
2445
|
+
const textAt = (i: number): string | undefined => (typeof message === 'string' ? message : message[i]);
|
|
2446
|
+
const call = (i: number): void => {
|
|
2447
|
+
const text = textAt(i);
|
|
2448
|
+
if (text === undefined || text === null) return;
|
|
2449
|
+
c.alertCalls.push({ time: b[i]!.time as number, message: String(text), freq });
|
|
2450
|
+
};
|
|
2451
|
+
if (currentBar >= 0) call(currentBar);
|
|
2452
|
+
else for (let i = 0; i < b.length; i++) call(i);
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
/** PineScript `alert()` with the `alert.freq_*` constants: `alert('Crossed', alert.freq_once_per_bar_close)`. */
|
|
2456
|
+
export const alert = Object.assign(alertImpl, {
|
|
2457
|
+
freq_all: 'all',
|
|
2458
|
+
freq_once_per_bar: 'once_per_bar',
|
|
2459
|
+
freq_once_per_bar_close: 'once_per_bar_close',
|
|
2460
|
+
} as const);
|
|
2461
|
+
|
|
2386
2462
|
// ── Convenience re-exports ───────────────────────────────────────────────────
|
|
2387
2463
|
|
|
2388
2464
|
export { Series, BarData, isNA as na, nz };
|
package/src/security/other.ts
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* holidays, closed hours), gaps off repeats the last value
|
|
19
19
|
* - gaps on: a value only on the chart bar where the shown bar changes (and on the first chart bar), na on the others
|
|
20
20
|
* - the last bar while it is open (`lastBarConfirmed` false) with gaps off: the realtime update shows the bar given by
|
|
21
|
-
* lookahead on (the open bar of a higher timeframe), with lookahead off as well
|
|
21
|
+
* lookahead on (the open bar of a higher timeframe), with lookahead off as well; a lower timeframe keeps the rules
|
|
22
|
+
* above (the last lower bar so far with lookahead off, the first one of the chart bar with lookahead on)
|
|
22
23
|
*
|
|
23
24
|
* Close times, trading days and time zones come from the exchange calendars of the chart and of the other symbol
|
|
24
25
|
* (time zone and session, read by the session functions). Without them:
|
|
@@ -212,7 +213,9 @@ export function securityOther(
|
|
|
212
213
|
|
|
213
214
|
// by trading day when both timeframes are D / W / M; by open time with an intraday side (#181)
|
|
214
215
|
const daily = timeframe.info(chartTf).isdwm && timeframe.info(otherTf).isdwm;
|
|
215
|
-
|
|
216
|
+
// a lower timeframe keeps its rule on the open last bar: the last lower bar so far, not the first one (#184)
|
|
217
|
+
const realtime =
|
|
218
|
+
chart.lastBarConfirmed === false && !options.gaps && timeframe.in_seconds(otherTf) >= timeframe.in_seconds(chartTf);
|
|
216
219
|
let on: number[] = [];
|
|
217
220
|
if (options.lookahead || realtime) {
|
|
218
221
|
if (daily) {
|
package/src/ta/index.ts
CHANGED
|
@@ -1088,6 +1088,7 @@ export function falling(source: Source, length: simple_int): series_bool {
|
|
|
1088
1088
|
* - Equivalent to: `100 * (source - source[length]) / source[length]`
|
|
1089
1089
|
* - Returns percentage change, e.g., 5.0 means 5% increase
|
|
1090
1090
|
* - `na` values in the source series are included in calculations and will produce an `na` result
|
|
1091
|
+
* - A zero `source[length]` gives +/-Infinity (NaN when `source` is 0 too), as in PineScript
|
|
1091
1092
|
* - Useful for momentum analysis and trend strength measurement
|
|
1092
1093
|
*
|
|
1093
1094
|
* @example
|
|
@@ -1106,9 +1107,10 @@ export function roc(source: Source, length: simple_int): series_float {
|
|
|
1106
1107
|
result.push(NaN);
|
|
1107
1108
|
} else {
|
|
1108
1109
|
const oldValue = source[i - length]!;
|
|
1109
|
-
if (
|
|
1110
|
+
if (isNaN(oldValue) || isNaN(source[i]!)) {
|
|
1110
1111
|
result.push(NaN);
|
|
1111
1112
|
} else {
|
|
1113
|
+
// a zero base divides by zero as in PineScript: +/-Infinity, NaN for 0 / 0 (#184)
|
|
1112
1114
|
const changeValue = source[i]! - oldValue;
|
|
1113
1115
|
result.push((100 * changeValue) / oldValue);
|
|
1114
1116
|
}
|
package/src/time/index.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* Every function takes an explicit time zone: UTC/GMT offset notation ("UTC-5",
|
|
6
6
|
* "GMT+0530", "UTC+05:30") or an IANA name ("America/New_York"). The PineScript
|
|
7
7
|
* default time zone (the exchange time zone, `syminfo.timezone`) is not known here.
|
|
8
|
+
* As in PineScript, the calendar fields (`year` ... `second`) of an na time are those
|
|
9
|
+
* of time 0 in the time zone.
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
import type { int, simple_int } from '../types/index.js';
|
|
@@ -72,8 +74,9 @@ export function timestamp(first: string | simple_int, ...rest: Array<simple_int
|
|
|
72
74
|
|
|
73
75
|
// ── Calendar fields ──────────────────────────────────────────────────────────
|
|
74
76
|
|
|
77
|
+
// PineScript reads an na time as 0: year(na) is 1970 in UTC, 1969 in America/New_York (#184)
|
|
75
78
|
function field(time: number, timezone: string, pick: (f: ReturnType<typeof zonedFields>) => number): int {
|
|
76
|
-
return Number.isNaN(time) ?
|
|
79
|
+
return pick(zonedFields(Number.isNaN(time) ? 0 : time, timezone));
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
/**
|
package/src/types/index.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { series_float, int, float, Source, Bar, OHLC } from '../types/index.js';
|
|
7
7
|
import { sma, ema, wma, rma } from '../ta/index.js';
|
|
8
8
|
import { Series } from '../runtime/series.js';
|
|
9
|
+
import type { SourceType } from '../input.js';
|
|
9
10
|
import { isDeleted } from '../drawing/registry.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -165,7 +166,8 @@ export function getOpen(ohlc: OHLC): series_float {
|
|
|
165
166
|
* Extract a specific source from OHLC data or bar array
|
|
166
167
|
*
|
|
167
168
|
* @param data - Bar array or OHLC data
|
|
168
|
-
* @param source - Source type: 'close', 'open', 'high', 'low', 'hl2', 'hlc3', 'ohlc4'
|
|
169
|
+
* @param source - Source type: 'close', 'open', 'high', 'low', 'hl2', 'hlc3', 'ohlc4', 'hlcc4', 'volume' (NaN for a
|
|
170
|
+
* bar without volume)
|
|
169
171
|
* @returns Series of the requested source
|
|
170
172
|
*
|
|
171
173
|
* @example
|
|
@@ -177,7 +179,7 @@ export function getOpen(ohlc: OHLC): series_float {
|
|
|
177
179
|
*/
|
|
178
180
|
export function getSource(
|
|
179
181
|
data: Bar[] | OHLC,
|
|
180
|
-
source:
|
|
182
|
+
source: SourceType = 'close'
|
|
181
183
|
): series_float {
|
|
182
184
|
// Check if data is OHLC structure
|
|
183
185
|
const isOHLC = 'open' in data && Array.isArray(data.open);
|
|
@@ -193,6 +195,7 @@ export function getSource(
|
|
|
193
195
|
case 'hlc3': return ohlc.high.map((h, i) => (h + ohlc.low[i]! + ohlc.close[i]!) / 3);
|
|
194
196
|
case 'ohlc4': return ohlc.open.map((o, i) => (o + ohlc.high[i]! + ohlc.low[i]! + ohlc.close[i]!) / 4);
|
|
195
197
|
case 'hlcc4': return ohlc.high.map((h, i) => (h + ohlc.low[i]! + ohlc.close[i]! + ohlc.close[i]!) / 4);
|
|
198
|
+
case 'volume': return ohlc.volume ?? ohlc.close.map(() => NaN);
|
|
196
199
|
}
|
|
197
200
|
} else {
|
|
198
201
|
const bars = data as Bar[];
|
|
@@ -205,6 +208,7 @@ export function getSource(
|
|
|
205
208
|
case 'hlc3': return bars.map(b => (b.high + b.low + b.close) / 3);
|
|
206
209
|
case 'ohlc4': return bars.map(b => (b.open + b.high + b.low + b.close) / 4);
|
|
207
210
|
case 'hlcc4': return bars.map(b => (b.high + b.low + b.close + b.close) / 4);
|
|
211
|
+
case 'volume': return bars.map(b => b.volume ?? NaN);
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
}
|
|
@@ -227,7 +231,7 @@ export function getSource(
|
|
|
227
231
|
*/
|
|
228
232
|
export function getSourceSeries(
|
|
229
233
|
bars: Bar[],
|
|
230
|
-
source:
|
|
234
|
+
source: SourceType = 'close'
|
|
231
235
|
): Series {
|
|
232
236
|
const open = new Series(bars, (bar) => bar.open);
|
|
233
237
|
const high = new Series(bars, (bar) => bar.high);
|
|
@@ -243,6 +247,7 @@ export function getSourceSeries(
|
|
|
243
247
|
case 'hlc3': return high.add(low).add(close).div(3);
|
|
244
248
|
case 'ohlc4': return open.add(high).add(low).add(close).div(4);
|
|
245
249
|
case 'hlcc4': return high.add(low).add(close).add(close).div(4);
|
|
250
|
+
case 'volume': return Series.fromBars(bars, 'volume');
|
|
246
251
|
default: return close;
|
|
247
252
|
}
|
|
248
253
|
}
|