oakscriptjs 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -1
- package/bin/oakscript.mjs +10 -3
- package/dist/cjs/box/index.d.ts +348 -289
- package/dist/cjs/box/index.d.ts.map +1 -1
- package/dist/cjs/box/index.js.map +2 -2
- package/dist/cjs/check/node.d.ts.map +1 -1
- package/dist/cjs/check/node.js +1 -0
- package/dist/cjs/check/node.js.map +2 -2
- package/dist/cjs/check/preview.d.ts +31 -0
- package/dist/cjs/check/preview.d.ts.map +1 -0
- package/dist/cjs/check/preview.js +303 -0
- package/dist/cjs/check/preview.js.map +7 -0
- package/dist/cjs/color/index.d.ts +11 -11
- package/dist/cjs/color/index.js.map +1 -1
- package/dist/cjs/color/parse.d.ts +2 -0
- package/dist/cjs/color/parse.d.ts.map +1 -1
- package/dist/cjs/color/parse.js +6 -0
- package/dist/cjs/color/parse.js.map +2 -2
- package/dist/cjs/compare/index.d.ts +76 -12
- package/dist/cjs/compare/index.d.ts.map +1 -1
- package/dist/cjs/compare/index.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +28 -5
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +14 -0
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/label/index.d.ts +265 -187
- package/dist/cjs/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js +1 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/line/index.d.ts +247 -207
- package/dist/cjs/line/index.d.ts.map +1 -1
- package/dist/cjs/line/index.js.map +2 -2
- package/dist/cjs/linefill/index.d.ts +61 -89
- package/dist/cjs/linefill/index.d.ts.map +1 -1
- package/dist/cjs/linefill/index.js.map +2 -2
- package/dist/cjs/math/index.d.ts +49 -40
- package/dist/cjs/math/index.d.ts.map +1 -1
- package/dist/cjs/math/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +57 -78
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/runtime/input-active.d.ts +2 -2
- package/dist/cjs/runtime/input-active.js.map +1 -1
- package/dist/cjs/runtime/series.d.ts +241 -161
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +223 -127
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/api/alert.d.ts +37 -0
- package/dist/cjs/script/api/alert.d.ts.map +1 -0
- package/dist/cjs/script/api/alert.js +17 -0
- package/dist/cjs/script/api/alert.js.map +7 -0
- package/dist/cjs/script/api/calc.d.ts +232 -0
- package/dist/cjs/script/api/calc.d.ts.map +1 -0
- package/dist/cjs/script/api/calc.js +17 -0
- package/dist/cjs/script/api/calc.js.map +7 -0
- package/dist/cjs/script/api/color.d.ts +213 -0
- package/dist/cjs/script/api/color.d.ts.map +1 -0
- package/dist/cjs/script/api/color.js +17 -0
- package/dist/cjs/script/api/color.js.map +7 -0
- package/dist/cjs/script/api/context.d.ts +764 -0
- package/dist/cjs/script/api/context.d.ts.map +1 -0
- package/dist/cjs/script/api/context.js +17 -0
- package/dist/cjs/script/api/context.js.map +7 -0
- package/dist/cjs/script/api/log.d.ts +58 -0
- package/dist/cjs/script/api/log.d.ts.map +1 -0
- package/dist/cjs/script/api/log.js +17 -0
- package/dist/cjs/script/api/log.js.map +7 -0
- package/dist/cjs/script/api/strategy.d.ts +391 -0
- package/dist/cjs/script/api/strategy.d.ts.map +1 -0
- package/dist/cjs/script/api/strategy.js +17 -0
- package/dist/cjs/script/api/strategy.js.map +7 -0
- package/dist/cjs/script/api/ta.d.ts +1012 -0
- package/dist/cjs/script/api/ta.d.ts.map +1 -0
- package/dist/cjs/script/api/ta.js +17 -0
- package/dist/cjs/script/api/ta.js.map +7 -0
- package/dist/cjs/script/api/table.d.ts +479 -0
- package/dist/cjs/script/api/table.d.ts.map +1 -0
- package/dist/cjs/script/api/table.js +17 -0
- package/dist/cjs/script/api/table.js.map +7 -0
- package/dist/cjs/script/constants.d.ts +228 -83
- package/dist/cjs/script/constants.d.ts.map +1 -1
- package/dist/cjs/script/constants.js +87 -0
- package/dist/cjs/script/constants.js.map +2 -2
- package/dist/cjs/script/define.d.ts +94 -0
- package/dist/cjs/script/define.d.ts.map +1 -0
- package/dist/cjs/script/define.js +127 -0
- package/dist/cjs/script/define.js.map +7 -0
- package/dist/cjs/script/drawing-args.d.ts.map +1 -1
- package/dist/cjs/script/drawing-args.js +1 -1
- package/dist/cjs/script/drawing-args.js.map +2 -2
- package/dist/cjs/script/formula.d.ts +53 -0
- package/dist/cjs/script/formula.d.ts.map +1 -0
- package/dist/cjs/script/formula.js +402 -0
- package/dist/cjs/script/formula.js.map +7 -0
- package/dist/cjs/script/globals.d.ts +10 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/index.d.ts +1065 -1006
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +530 -60
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/script/json.d.ts +117 -0
- package/dist/cjs/script/json.d.ts.map +1 -0
- package/dist/cjs/script/json.js +321 -0
- package/dist/cjs/script/json.js.map +7 -0
- package/dist/cjs/str/index.d.ts +50 -75
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +2 -2
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/strategy/index.d.ts +102 -1
- package/dist/cjs/strategy/index.d.ts.map +1 -1
- package/dist/cjs/strategy/index.js.map +2 -2
- package/dist/cjs/table/index.d.ts +330 -49
- package/dist/cjs/table/index.d.ts.map +1 -1
- package/dist/cjs/table/index.js +55 -27
- package/dist/cjs/table/index.js.map +2 -2
- package/dist/cjs/text/index.d.ts +12 -14
- package/dist/cjs/text/index.d.ts.map +1 -1
- package/dist/cjs/text/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +15 -8
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +12 -3
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/esm/box/index.d.ts +348 -289
- package/dist/esm/box/index.d.ts.map +1 -1
- package/dist/esm/box/index.js +276 -276
- package/dist/esm/box/index.js.map +1 -1
- package/dist/esm/check/node.d.ts.map +1 -1
- package/dist/esm/check/node.js +1 -0
- package/dist/esm/check/node.js.map +1 -1
- package/dist/esm/check/preview.d.ts +31 -0
- package/dist/esm/check/preview.d.ts.map +1 -0
- package/dist/esm/check/preview.js +296 -0
- package/dist/esm/check/preview.js.map +1 -0
- package/dist/esm/color/index.d.ts +11 -11
- package/dist/esm/color/index.js +11 -11
- package/dist/esm/color/parse.d.ts +2 -0
- package/dist/esm/color/parse.d.ts.map +1 -1
- package/dist/esm/color/parse.js +7 -0
- package/dist/esm/color/parse.js.map +1 -1
- package/dist/esm/compare/index.d.ts +76 -12
- package/dist/esm/compare/index.d.ts.map +1 -1
- package/dist/esm/compare/index.js +76 -12
- package/dist/esm/compare/index.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +28 -5
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +39 -3
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/label/index.d.ts +265 -187
- package/dist/esm/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js +207 -177
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/line/index.d.ts +247 -207
- package/dist/esm/line/index.d.ts.map +1 -1
- package/dist/esm/line/index.js +202 -194
- package/dist/esm/line/index.js.map +1 -1
- package/dist/esm/linefill/index.d.ts +61 -89
- package/dist/esm/linefill/index.d.ts.map +1 -1
- package/dist/esm/linefill/index.js +61 -89
- package/dist/esm/linefill/index.js.map +1 -1
- package/dist/esm/math/index.d.ts +49 -40
- package/dist/esm/math/index.d.ts.map +1 -1
- package/dist/esm/math/index.js +22 -9
- package/dist/esm/math/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +57 -78
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +57 -78
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/runtime/input-active.d.ts +2 -2
- package/dist/esm/runtime/input-active.js +2 -2
- package/dist/esm/runtime/series.d.ts +241 -161
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +241 -161
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/api/alert.d.ts +37 -0
- package/dist/esm/script/api/alert.d.ts.map +1 -0
- package/dist/esm/script/api/alert.js +7 -0
- package/dist/esm/script/api/alert.js.map +1 -0
- package/dist/esm/script/api/calc.d.ts +232 -0
- package/dist/esm/script/api/calc.d.ts.map +1 -0
- package/dist/esm/script/api/calc.js +6 -0
- package/dist/esm/script/api/calc.js.map +1 -0
- package/dist/esm/script/api/color.d.ts +213 -0
- package/dist/esm/script/api/color.d.ts.map +1 -0
- package/dist/esm/script/api/color.js +6 -0
- package/dist/esm/script/api/color.js.map +1 -0
- package/dist/esm/script/api/context.d.ts +764 -0
- package/dist/esm/script/api/context.d.ts.map +1 -0
- package/dist/esm/script/api/context.js +7 -0
- package/dist/esm/script/api/context.js.map +1 -0
- package/dist/esm/script/api/log.d.ts +58 -0
- package/dist/esm/script/api/log.d.ts.map +1 -0
- package/dist/esm/script/api/log.js +6 -0
- package/dist/esm/script/api/log.js.map +1 -0
- package/dist/esm/script/api/strategy.d.ts +391 -0
- package/dist/esm/script/api/strategy.d.ts.map +1 -0
- package/dist/esm/script/api/strategy.js +7 -0
- package/dist/esm/script/api/strategy.js.map +1 -0
- package/dist/esm/script/api/ta.d.ts +1012 -0
- package/dist/esm/script/api/ta.d.ts.map +1 -0
- package/dist/esm/script/api/ta.js +6 -0
- package/dist/esm/script/api/ta.js.map +1 -0
- package/dist/esm/script/api/table.d.ts +479 -0
- package/dist/esm/script/api/table.d.ts.map +1 -0
- package/dist/esm/script/api/table.js +7 -0
- package/dist/esm/script/api/table.js.map +1 -0
- package/dist/esm/script/constants.d.ts +228 -83
- package/dist/esm/script/constants.d.ts.map +1 -1
- package/dist/esm/script/constants.js +110 -24
- package/dist/esm/script/constants.js.map +1 -1
- package/dist/esm/script/define.d.ts +94 -0
- package/dist/esm/script/define.d.ts.map +1 -0
- package/dist/esm/script/define.js +136 -0
- package/dist/esm/script/define.js.map +1 -0
- package/dist/esm/script/drawing-args.d.ts.map +1 -1
- package/dist/esm/script/drawing-args.js +2 -1
- package/dist/esm/script/drawing-args.js.map +1 -1
- package/dist/esm/script/formula.d.ts +53 -0
- package/dist/esm/script/formula.d.ts.map +1 -0
- package/dist/esm/script/formula.js +408 -0
- package/dist/esm/script/formula.js.map +1 -0
- package/dist/esm/script/globals.d.ts +10 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/index.d.ts +1065 -1006
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +1096 -151
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/script/json.d.ts +117 -0
- package/dist/esm/script/json.d.ts.map +1 -0
- package/dist/esm/script/json.js +375 -0
- package/dist/esm/script/json.js.map +1 -0
- package/dist/esm/str/index.d.ts +50 -75
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +51 -76
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/strategy/index.d.ts +102 -1
- package/dist/esm/strategy/index.d.ts.map +1 -1
- package/dist/esm/strategy/index.js +1 -1
- package/dist/esm/strategy/index.js.map +1 -1
- package/dist/esm/table/index.d.ts +330 -49
- package/dist/esm/table/index.d.ts.map +1 -1
- package/dist/esm/table/index.js +372 -61
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/text/index.d.ts +12 -14
- package/dist/esm/text/index.d.ts.map +1 -1
- package/dist/esm/text/index.js +12 -14
- package/dist/esm/text/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +15 -8
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +15 -8
- package/dist/esm/types/index.js.map +1 -1
- package/docs/first-indicator.md +152 -0
- package/docs/guide.md +1185 -0
- package/docs/inventory.md +772 -0
- package/docs/no-code.md +207 -0
- package/docs/recipes.md +202 -0
- package/package.json +2 -1
- package/skills/oakscript/SKILL.md +8 -0
- package/skills/oakscript/reference/errors.md +3 -2
- package/src/box/index.ts +348 -289
- package/src/check/node.ts +1 -0
- package/src/check/preview.ts +307 -0
- package/src/color/index.ts +11 -11
- package/src/color/parse.ts +7 -0
- package/src/compare/index.ts +76 -12
- package/src/drawing/registry.ts +44 -5
- package/src/index.ts +1 -1
- package/src/label/index.ts +267 -189
- package/src/line/index.ts +248 -208
- package/src/linefill/index.ts +61 -89
- package/src/math/index.ts +51 -42
- package/src/polyline/index.ts +57 -78
- package/src/runtime/input-active.ts +2 -2
- package/src/runtime/series.ts +243 -163
- package/src/script/api/alert.ts +43 -0
- package/src/script/api/calc.ts +250 -0
- package/src/script/api/color.ts +245 -0
- package/src/script/api/context.ts +944 -0
- package/src/script/api/log.ts +60 -0
- package/src/script/api/strategy.ts +410 -0
- package/src/script/api/ta.ts +1115 -0
- package/src/script/api/table.ts +538 -0
- package/src/script/constants.ts +229 -25
- package/src/script/define.ts +221 -0
- package/src/script/drawing-args.ts +2 -1
- package/src/script/formula.ts +438 -0
- package/src/script/globals.ts +10 -0
- package/src/script/index.ts +1517 -239
- package/src/script/json.ts +457 -0
- package/src/str/index.ts +51 -76
- package/src/strategy/index.ts +102 -1
- package/src/table/index.ts +388 -62
- package/src/text/index.ts +12 -14
- package/src/types/index.ts +15 -8
|
@@ -36,25 +36,41 @@ import type { Bar } from '../types/index.js';
|
|
|
36
36
|
import type { ArrowData, BarColorData, BgColorData, BoxData, IndicatorResult, LabelData, LabelStyle, LineDrawingData, LinefillData, MarkerData, MarkerLocation, MarkerPosition, MarkerShape, MarkerSize, PineSize, PlotBarData, PlotCandleData, PolylineData, ShapeStyle, TableCellData, TableData, TableMergeData, TablePosition, TimeValue } from '../types/metadata.js';
|
|
37
37
|
import type { ArrowConfig, BarColorConfig, CandleConfig, FillConfig, HLineConfig, InputConfig, InputCondition, PlotConfig, ShapeConfig } from '../runtime/types.js';
|
|
38
38
|
import { BarData, Series } from '../runtime/series.js';
|
|
39
|
-
import
|
|
40
|
-
import
|
|
39
|
+
import type { TaNamespace } from './api/ta.js';
|
|
40
|
+
import type { StrategyNamespace } from './api/strategy.js';
|
|
41
|
+
import type { BarmergeNamespace, BarstateNamespace, ChartNamespace, DividendsNamespace, EarningsNamespace, RequestNamespace, SessionNamespace, SplitsNamespace, SyminfoNamespace, TickerNamespace, TimeframeNamespace } from './api/context.js';
|
|
42
|
+
import type { CalcNamespace } from './api/calc.js';
|
|
43
|
+
import type { ColorNamespace } from './api/color.js';
|
|
44
|
+
import type { LogNamespace } from './api/log.js';
|
|
45
|
+
import type { AlertApi } from './api/alert.js';
|
|
46
|
+
import type { TableNamespace } from './api/table.js';
|
|
47
|
+
import * as pineConstants from './constants.js';
|
|
48
|
+
import * as compareCore from '../compare/index.js';
|
|
41
49
|
import * as lineCore from '../line/index.js';
|
|
42
50
|
import * as labelCore from '../label/index.js';
|
|
43
51
|
import * as boxCore from '../box/index.js';
|
|
44
52
|
import * as linefillCore from '../linefill/index.js';
|
|
45
53
|
import * as polylineCore from '../polyline/index.js';
|
|
46
|
-
import * as
|
|
47
|
-
import * as chartPointCore from '../chartpoint/index.js';
|
|
54
|
+
import * as textCore from '../text/index.js';
|
|
48
55
|
import * as mathCore from '../math/index.js';
|
|
49
56
|
import { type DrawingKind, type DrawingVariable } from '../drawing/registry.js';
|
|
50
57
|
export { holdDrawing, releaseDrawing, type DrawingVariable } from '../drawing/registry.js';
|
|
51
58
|
/**
|
|
52
|
-
* A
|
|
53
|
-
*
|
|
54
|
-
*
|
|
59
|
+
* A variable that holds one drawing (a line, label, box...) from bar to bar and keeps it alive: the object it holds is
|
|
60
|
+
* never deleted by the `max_*_count` limit of the script. Use it to create one object and move it, instead of a new
|
|
61
|
+
* object on each bar. Assigning another object (or `undefined` for na) releases the one before, which the limit can
|
|
62
|
+
* delete again. Declare it in the script body (outside the bar loops), then read and write `.value` in a bar loop.
|
|
63
|
+
* @param initial - The object held from the start. Default: none (`.value` is `undefined`).
|
|
64
|
+
* @returns A box whose `.value` is the held object, or `undefined`.
|
|
65
|
+
* @example
|
|
66
|
+
* ```js
|
|
67
|
+
* const level = varDrawing();
|
|
68
|
+
* eachBar((c) => {
|
|
69
|
+
* if (c.i === c.n - 1) level.value = line.new(c.i - 20, c.close, c.i, c.close, { color: color.orange });
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
55
72
|
*/
|
|
56
|
-
export declare function varDrawing<T extends object>(initial?: T): DrawingVariable<T>;
|
|
57
|
-
import * as timeframeCore from '../timeframe/index.js';
|
|
73
|
+
export declare function varDrawing<T extends object = any>(initial?: T): DrawingVariable<T>;
|
|
58
74
|
import * as strCore from '../str/index.js';
|
|
59
75
|
import { type SessionSpec } from '../session/calendar.js';
|
|
60
76
|
import { position } from '../types/index.js';
|
|
@@ -69,6 +85,8 @@ export interface ScriptRunResult {
|
|
|
69
85
|
precision?: number;
|
|
70
86
|
format?: string;
|
|
71
87
|
scale?: 'right' | 'left' | 'none';
|
|
88
|
+
/** indicator(..., { pane }) when the script gives it (not PineScript); `overlay` is the pane it gave. */
|
|
89
|
+
pane?: 'price' | 'separate' | 'auto';
|
|
72
90
|
};
|
|
73
91
|
inputConfig: InputConfig[];
|
|
74
92
|
plotConfig: PlotConfig[];
|
|
@@ -111,6 +129,11 @@ export interface ScriptRunResult {
|
|
|
111
129
|
/** The script read `chart.left_visible_bar_time` or `chart.right_visible_bar_time`: it has to be calculated again when
|
|
112
130
|
* the visible range of the chart changes. */
|
|
113
131
|
usesVisibleRange: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Things the run did that a script usually does not mean, in plain words: drawings deleted because there were more
|
|
134
|
+
* than the maximum count (`indicator(max_labels_count)`...). Empty when there is nothing to say.
|
|
135
|
+
*/
|
|
136
|
+
warnings: string[];
|
|
114
137
|
}
|
|
115
138
|
export interface AlertConditionConfig {
|
|
116
139
|
id: string;
|
|
@@ -160,6 +183,30 @@ export interface ScriptOptions {
|
|
|
160
183
|
* (see {@link executeIntrabar}). The host keeps one recorder for the main run of a backtest and its intrabar runs.
|
|
161
184
|
*/
|
|
162
185
|
recorder?: StrategyRecorder;
|
|
186
|
+
/**
|
|
187
|
+
* Strict mode: mistakes that PineScript lets pass silently throw a {@link ScriptError} with a plain message: an input
|
|
188
|
+
* value of the wrong type, out of its range or not one of its options, an input name the script does not declare,
|
|
189
|
+
* an unknown option of plot() / hline() / plotshape() / plotchar() / bgcolor() / barcolor(), a text that is not a
|
|
190
|
+
* colour. Default false (PineScript behaviour); {@link defineIndicator} turns it on.
|
|
191
|
+
*/
|
|
192
|
+
strict?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Colours of the plots that give none: true for {@link DEFAULT_PALETTE} (each plot without a colour takes the next
|
|
195
|
+
* one), or a list of colours. Default false: every plot without a colour is blue, as in PineScript.
|
|
196
|
+
*/
|
|
197
|
+
palette?: boolean | readonly string[];
|
|
198
|
+
/**
|
|
199
|
+
* The ids of the plots in `plotConfig` and `result.plots`: 'index' (default, as PineScript numbers them: plot0,
|
|
200
|
+
* plot1...) or 'title' (made from the title as the inputs' ids are: "Fast MA" gives fast_ma), which stay the same when
|
|
201
|
+
* plots are added or moved.
|
|
202
|
+
*/
|
|
203
|
+
plotIds?: 'index' | 'title';
|
|
204
|
+
}
|
|
205
|
+
/** The colours given in turn to plots without a colour when `ScriptOptions.palette` is true. */
|
|
206
|
+
export declare const DEFAULT_PALETTE: readonly string[];
|
|
207
|
+
/** A mistake found in strict mode (see `ScriptOptions.strict`): the message says what to change. */
|
|
208
|
+
export declare class ScriptError extends Error {
|
|
209
|
+
constructor(message: string);
|
|
163
210
|
}
|
|
164
211
|
/**
|
|
165
212
|
* Answers of the strategy engine recorded in the main run of a strategy, bar by bar, and its `varip` values: an
|
|
@@ -218,23 +265,28 @@ export interface IntrabarUpdate {
|
|
|
218
265
|
fullRunReason: string | null;
|
|
219
266
|
}
|
|
220
267
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* the tick price, its high and low the extremes reached so far). The script's variables come back to
|
|
224
|
-
* the start of the bar
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
268
|
+
* Host-side: runs a strategy once more on one bar, inside the bar (calculation on order fills, or on the ticks of
|
|
269
|
+
* history bars). Scripts never call it. `bars` holds the bars up to that bar, the last one as it stands at the tick
|
|
270
|
+
* (its close is the tick price, its high and low the extremes reached so far). The script's variables come back to
|
|
271
|
+
* their state at the start of the bar, except `varip` ones. In strategy.eachBar(), the bars before replay the engine's
|
|
272
|
+
* answers that the main run recorded (their order calls are dropped), and the bar itself calls `options.engine`
|
|
273
|
+
* without processBar / processClose (the host is filling its orders). That bar is a confirmed history bar
|
|
274
|
+
* (`barstate.isconfirmed`); `barstate.islast`, `last_bar_index` and `BarContext.n` keep the chart's last bar. Risk
|
|
275
|
+
* rules are not declared again, and the outputs (plots, drawings) are dropped. Re-entrant: the host calls it inside
|
|
276
|
+
* the bar loop of the main run.
|
|
230
277
|
*
|
|
231
|
-
* Resumed runs
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
278
|
+
* Resumed runs: the intrabar runs of a backtest (same recorder, script, inputs, chart and engine) keep the state of
|
|
279
|
+
* the script as createScriptRun does, so a run calculates its bar only (and the bars since the previous intrabar run);
|
|
280
|
+
* the order calls and `strategy.*` reads are the same as in a full run. The bars before `options.bar` must be the main
|
|
281
|
+
* run's (the same on every call). A script that keeps state outside `persist()` boxes, or uses a feature that is not
|
|
282
|
+
* resumed, gets full runs (`fullRunReason`); the first resumed runs are also calculated in full and compared
|
|
283
|
+
* (`verify`). A resumed run gives its order calls to the engine once it has ended.
|
|
284
|
+
* @param body - The script body, as given to executeScript().
|
|
285
|
+
* @param bars - The bars up to and including the bar calculated inside, oldest first.
|
|
286
|
+
* @param inputs - Input values by input id, as given to the main run.
|
|
287
|
+
* @param chart - The chart context of the main run.
|
|
288
|
+
* @param options - The bar, the chart's last bar index, the main run's engine and recorder, and the resume settings.
|
|
289
|
+
* @returns The first bar calculated, whether the run was resumed, and why the runs are full ones (or null).
|
|
238
290
|
*/
|
|
239
291
|
export declare function executeIntrabar(body: () => void, bars: Bar[], inputs: Record<string, unknown>, chart: ChartContext, options: IntrabarOptions): IntrabarUpdate;
|
|
240
292
|
/** The result of {@link ScriptRun.update}. */
|
|
@@ -262,7 +314,8 @@ export interface ScriptRun {
|
|
|
262
314
|
readonly fullRunReason: string | null;
|
|
263
315
|
}
|
|
264
316
|
/**
|
|
265
|
-
*
|
|
317
|
+
* Host-side: a script that calculates only the newest bars on a live update. Scripts never call it. The first
|
|
318
|
+
* update is a full run; it keeps,
|
|
266
319
|
* for the next one, what the script created (its Series, ta.* calls, eachBar() blocks, persist() boxes and plots) with
|
|
267
320
|
* their state at the end of the last confirmed bar. An update whose bars are the same up to the forming bar of the
|
|
268
321
|
* previous update (a new price of the forming bar, or new bars after it) runs the script again from that bar only;
|
|
@@ -274,36 +327,54 @@ export interface ScriptRun {
|
|
|
274
327
|
* compared (`verify`): a difference makes the next updates full runs. Not resumed yet, so calculated in full: drawings,
|
|
275
328
|
* request.security, strategies, varip, timenow, last_bar_index, BarContext.n, barstate.islastconfirmedhistory
|
|
276
329
|
* (`fullRunReason` names the first one met).
|
|
330
|
+
* @param body - The script body, a function that runs the script's statements.
|
|
331
|
+
* @param inputs - Input values by input id. Default: `{}` (every input at its default).
|
|
332
|
+
* @param chart - The chart context (timeframe, time zone, session, symbol...); an update can give a new one.
|
|
333
|
+
* Default: `{}`.
|
|
334
|
+
* @param options - The executeScript() options, plus `verify` (resumed updates also run in full and compared).
|
|
335
|
+
* Default: `{}`.
|
|
336
|
+
* @returns A run: call `update(bars, chart?)` on each change of the bars; `fullRunReason` says why it does not resume.
|
|
277
337
|
*/
|
|
278
338
|
export declare function createScriptRun(body: () => void, inputs?: Record<string, unknown>, chart?: ChartContext, options?: ScriptRunOptions): ScriptRun;
|
|
279
339
|
/** A `varip` variable: `.value` reads and writes it. */
|
|
280
340
|
export interface VaripVariable<T> {
|
|
341
|
+
/** The current value of the variable. */
|
|
281
342
|
value: T;
|
|
282
343
|
}
|
|
283
344
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
345
|
+
* A strategy variable that keeps the changes made while a bar is calculated again inside the bar (on order fills or
|
|
346
|
+
* ticks). A plain variable comes back to its value at the start of the bar on each of those runs; a `varip` one does
|
|
347
|
+
* not, so it can count fills or ticks. Declare it once in the script body (outside the callbacks), in the same order
|
|
348
|
+
* on each run; read and write `.value` in strategy.eachBar(). Without intrabar runs it is a plain variable.
|
|
349
|
+
* @param initial - The starting value.
|
|
350
|
+
* @returns A box whose `.value` reads and writes the variable.
|
|
351
|
+
* @example
|
|
352
|
+
* ```js
|
|
353
|
+
* const updatesInTrade = varip(0);
|
|
354
|
+
* strategy.eachBar((c) => {
|
|
355
|
+
* if (strategy.position_size !== 0) updatesInTrade.value += 1;
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
288
358
|
*/
|
|
289
359
|
export declare function varip<T>(initial: T): VaripVariable<T>;
|
|
290
360
|
/** A `persist` variable: `.value` reads and writes it. */
|
|
291
361
|
export interface PersistVariable<T> {
|
|
362
|
+
/** The current value of the variable. */
|
|
292
363
|
value: T;
|
|
293
364
|
}
|
|
294
365
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* ```
|
|
306
|
-
* const dir = persist(0);
|
|
366
|
+
* A variable that keeps its value from one bar to the next, kept by the runtime. Declare it in the script body
|
|
367
|
+
* (outside the callbacks), in the same order on each run, and read and write `.value` in one eachBar() callback. On a
|
|
368
|
+
* live chart the runtime saves its value at the end of the last confirmed bar and puts it back before the forming bar
|
|
369
|
+
* is calculated again, so only the newest bar is calculated: prefer it to a `let` variable outside the callback.
|
|
370
|
+
* The script is calculated in full on each update (same results, slower) when the variable is used outside an
|
|
371
|
+
* eachBar() callback, by two eachBar() blocks, or holds something else than plain data (numbers, strings, booleans,
|
|
372
|
+
* arrays, plain objects, Map, Set). Calling it inside a bar loop throws.
|
|
373
|
+
* @param initial - The value before the first bar.
|
|
374
|
+
* @returns A box whose `.value` reads and writes the variable.
|
|
375
|
+
* @example
|
|
376
|
+
* ```js
|
|
377
|
+
* const dir = persist(0);
|
|
307
378
|
* const trend = eachBar((c) => {
|
|
308
379
|
* if (c.close > c.get(close, 1)) dir.value = 1;
|
|
309
380
|
* else if (c.close < c.get(close, 1)) dir.value = -1;
|
|
@@ -312,71 +383,117 @@ export interface PersistVariable<T> {
|
|
|
312
383
|
* ```
|
|
313
384
|
*/
|
|
314
385
|
export declare function persist<T>(initial: T): PersistVariable<T>;
|
|
386
|
+
/** Options of {@link indicator}. */
|
|
315
387
|
export interface IndicatorOptions {
|
|
388
|
+
/** Short name shown in the chart legend. Default: the title. */
|
|
316
389
|
shorttitle?: string;
|
|
317
|
-
/** true: drawn on the price pane; false
|
|
390
|
+
/** true: drawn on the price pane; false: in its own pane below the chart. Default: false. */
|
|
318
391
|
overlay?: boolean;
|
|
392
|
+
/** Number of decimals of the values shown in the legend and on the price scale. Default: the host's choice (the symbol's precision). */
|
|
319
393
|
precision?: number;
|
|
394
|
+
/** Number format of the values: `format.price`, `format.volume`, `format.percent`, `format.mintick` or `format.inherit`. Default: `format.inherit`. */
|
|
320
395
|
format?: string;
|
|
321
|
-
/** The price scale: `scale.right`, `scale.left` or `scale.none
|
|
396
|
+
/** The price scale the script uses: `scale.right`, `scale.left` or `scale.none`. Default: the host's choice. */
|
|
322
397
|
scale?: 'right' | 'left' | 'none';
|
|
323
|
-
/**
|
|
398
|
+
/** Most lines kept alive; above it the oldest are deleted (a few more may stay for a moment). Default: 50. */
|
|
324
399
|
max_lines_count?: number;
|
|
325
|
-
/**
|
|
400
|
+
/** Most labels kept alive; above it the oldest are deleted. Default: 50. */
|
|
326
401
|
max_labels_count?: number;
|
|
327
|
-
/**
|
|
402
|
+
/** Most boxes kept alive; above it the oldest are deleted. Default: 50. */
|
|
328
403
|
max_boxes_count?: number;
|
|
329
|
-
/**
|
|
404
|
+
/** Most polylines kept alive; above it the oldest are deleted. Default: 50. */
|
|
330
405
|
max_polylines_count?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Where the script is drawn, instead of `overlay` (give one of the two): 'price' (on the price pane), 'separate'
|
|
408
|
+
* (its own pane) or 'auto' (chosen from the plotted values: the price pane when they are prices, like an average;
|
|
409
|
+
* its own pane otherwise, like an RSI). Default: not set (`overlay` decides).
|
|
410
|
+
*/
|
|
411
|
+
pane?: 'price' | 'separate' | 'auto';
|
|
331
412
|
}
|
|
332
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* Declares the script as an indicator: its title, its pane and how its values are shown. Call it once, at the top
|
|
415
|
+
* of the script (a script declares either `indicator()` or `strategy()`). A script without a declaration runs with
|
|
416
|
+
* the title "Untitled" in its own pane.
|
|
417
|
+
* @param title - Name of the script, shown in the legend and the settings.
|
|
418
|
+
* @param options - Pane, short title, number format and drawing limits. Default: `{}` (own pane).
|
|
419
|
+
* @example
|
|
420
|
+
* ```js
|
|
421
|
+
* indicator("My SMA", { overlay: true, precision: 2 });
|
|
422
|
+
* plot(ta.sma(close, 20), "SMA");
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
333
425
|
export declare function indicator(title: string, options?: IndicatorOptions): void;
|
|
334
|
-
/** Options of every `input.*` kind
|
|
426
|
+
/** Options of every `input.*` kind: where the input is listed in the settings and how it behaves. */
|
|
335
427
|
export interface InputOptions {
|
|
336
|
-
/** Group title: every input with the same `group` is listed under it, at the place of the group's first input. */
|
|
428
|
+
/** Group title: every input with the same `group` is listed under it, at the place of the group's first input. Default: no group. */
|
|
337
429
|
group?: string;
|
|
338
|
-
/** Inputs with the same `inline` id share one row of their group (ungrouped inputs share rows among themselves). */
|
|
430
|
+
/** Inputs with the same `inline` id share one row of their group (ungrouped inputs share rows among themselves). Default: a row of its own. */
|
|
339
431
|
inline?: string;
|
|
340
|
-
/** Help text shown next to the input. */
|
|
432
|
+
/** Help text shown next to the input. Default: none. */
|
|
341
433
|
tooltip?: string;
|
|
342
|
-
/**
|
|
434
|
+
/** true: the host asks for the value when the script is added to a chart. Default: false. */
|
|
343
435
|
confirm?: boolean;
|
|
344
|
-
/**
|
|
436
|
+
/**
|
|
437
|
+
* Where the value is shown besides the settings: `display.all`, `display.none`, `display.status_line` or
|
|
438
|
+
* `display.data_window`. Default: 'none' for bool, color, time and text_area inputs, 'all' for the others.
|
|
439
|
+
*/
|
|
345
440
|
display?: InputConfig['display'];
|
|
346
441
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
442
|
+
* false greys the input out in the settings (it keeps its value). A boolean (`active: showMa`), or a condition on
|
|
443
|
+
* input ids that a host can apply without running the script (`active: 'ma_1'`,
|
|
444
|
+
* `active: { input: 'type', ne: 'None' }`). Default: true.
|
|
350
445
|
*/
|
|
351
446
|
active?: boolean | InputCondition;
|
|
447
|
+
/**
|
|
448
|
+
* The id of the input (letters, digits and _): the name of its value in the inputs given to the run. Default: made
|
|
449
|
+
* from the title ("Fast length" gives fast_length), which changes when the title changes.
|
|
450
|
+
*/
|
|
451
|
+
id?: string;
|
|
352
452
|
}
|
|
453
|
+
/** Options of `input.int()` and `input.float()`. */
|
|
353
454
|
export interface NumericInputOptions extends InputOptions {
|
|
455
|
+
/** Smallest value the user can enter. Default: no minimum. */
|
|
354
456
|
minval?: number;
|
|
457
|
+
/** Largest value the user can enter. Default: no maximum. */
|
|
355
458
|
maxval?: number;
|
|
459
|
+
/** Step of the arrows of the number field. Default: the host's choice (1 for an int). */
|
|
356
460
|
step?: number;
|
|
357
|
-
/** The values to choose from (the host shows a drop-down list). */
|
|
461
|
+
/** The values to choose from (the host shows a drop-down list). Default: a free number field. */
|
|
358
462
|
options?: number[];
|
|
359
463
|
}
|
|
360
|
-
/** A field of an enum made with `defineEnum()`: its name and title. `String(field)` is the title
|
|
361
|
-
* `str.tostring()` of an enum field. */
|
|
464
|
+
/** A field of an enum made with `defineEnum()`: its name and title. `String(field)` is the title. */
|
|
362
465
|
export interface EnumField {
|
|
466
|
+
/** The field's name, as written in `defineEnum()` (`"sma"`). */
|
|
363
467
|
readonly name: string;
|
|
468
|
+
/** The field's title, shown in the settings (`"Simple"`); the name when the title was empty. */
|
|
364
469
|
readonly title: string;
|
|
470
|
+
/** The title, so `String(field)` and `str.tostring(field)` give it. */
|
|
365
471
|
toString(): string;
|
|
366
472
|
}
|
|
473
|
+
/** Options of `input.enum()`. */
|
|
367
474
|
export interface EnumInputOptions extends InputOptions {
|
|
368
|
-
/** The fields to choose from
|
|
475
|
+
/** The fields to choose from, all of the default's enum. Default: every field of the enum. */
|
|
369
476
|
options?: EnumField[];
|
|
370
477
|
}
|
|
371
478
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
479
|
+
* Makes an enum: a fixed set of named fields, each with a title, for a choice list (`input.enum()`) or a state with
|
|
480
|
+
* a few values. Fields compare with `===`; `field.name` is the name, `field.title` and `String(field)` the title.
|
|
481
|
+
* @param fields - An object of field names and titles, e.g. `{ sma: "Simple", ema: "Exponential" }`; an empty title
|
|
482
|
+
* is the name.
|
|
483
|
+
* @returns A frozen object with one {@link EnumField} per name.
|
|
484
|
+
* @example
|
|
485
|
+
* ```js
|
|
486
|
+
* const MaType = defineEnum({ sma: "Simple", ema: "Exponential" });
|
|
487
|
+
* const maType = input.enum(MaType.sma, "Average");
|
|
488
|
+
* plot(maType === MaType.ema ? ta.ema(close, 20) : ta.sma(close, 20), "MA");
|
|
489
|
+
* ```
|
|
375
490
|
*/
|
|
376
491
|
export declare function defineEnum<K extends string>(fields: Record<K, string>): {
|
|
377
492
|
readonly [P in K]: EnumField;
|
|
378
493
|
};
|
|
494
|
+
/** Options of `input.string()`, `input.timeframe()`, `input.session()` and `input.symbol()`. */
|
|
379
495
|
export interface StringInputOptions extends InputOptions {
|
|
496
|
+
/** The values to choose from (the host shows a drop-down list). Default: a free text field (or the kind's own picker). */
|
|
380
497
|
options?: string[];
|
|
381
498
|
}
|
|
382
499
|
/** Named arguments of an input: its options, with `title` (and `defval` when every argument is named). */
|
|
@@ -384,347 +501,522 @@ type InputArgs<O, D> = O & {
|
|
|
384
501
|
title?: string;
|
|
385
502
|
defval?: D;
|
|
386
503
|
};
|
|
387
|
-
/**
|
|
388
|
-
*
|
|
389
|
-
*
|
|
504
|
+
/**
|
|
505
|
+
* Script inputs: each `input.*` call declares a setting the user can change AND returns its current value (the
|
|
506
|
+
* user's value when there is one, else the default). The arguments after the default can be named:
|
|
507
|
+
* `input.int(14, "Length", { minval: 1 })`, `input.int(14, { title: "Length", minval: 1 })` or
|
|
508
|
+
* `input.int({ defval: 14, title: "Length" })`. The input id is the title in snake case ("Fast length" is
|
|
509
|
+
* `fast_length`); keep titles stable, a renamed input loses the user's value.
|
|
510
|
+
*/
|
|
390
511
|
export declare const input: {
|
|
512
|
+
/**
|
|
513
|
+
* Declares a whole-number setting (a length, a count) and returns its value, rounded to an integer.
|
|
514
|
+
* @param defval - Default value, or every argument by name (`{ defval, title, minval... }`).
|
|
515
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_int`).
|
|
516
|
+
* @param opts - `minval`, `maxval`, `step`, `options` (a choice list) and the common input options.
|
|
517
|
+
* @returns The current value: the user's value, else `defval`.
|
|
518
|
+
* @example
|
|
519
|
+
* ```js
|
|
520
|
+
* const length = input.int(14, "Length", { minval: 1, maxval: 500 });
|
|
521
|
+
* plot(ta.rsi(close, length), "RSI");
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
391
524
|
int(defval: number | InputArgs<NumericInputOptions, number>, title?: string | InputArgs<NumericInputOptions, number>, opts?: NumericInputOptions): number;
|
|
525
|
+
/**
|
|
526
|
+
* Declares a decimal-number setting (a multiplier, a percent, a level) and returns its value.
|
|
527
|
+
* @param defval - Default value, or every argument by name (`{ defval, title, minval... }`).
|
|
528
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_float`).
|
|
529
|
+
* @param opts - `minval`, `maxval`, `step`, `options` (a choice list) and the common input options.
|
|
530
|
+
* @returns The current value: the user's value, else `defval`.
|
|
531
|
+
* @example
|
|
532
|
+
* ```js
|
|
533
|
+
* const mult = input.float(2.0, "Multiplier", { minval: 0.1, step: 0.1 });
|
|
534
|
+
* const [basis, upper, lower] = ta.bb(close, 20, mult);
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
392
537
|
float(defval: number | InputArgs<NumericInputOptions, number>, title?: string | InputArgs<NumericInputOptions, number>, opts?: NumericInputOptions): number;
|
|
538
|
+
/**
|
|
539
|
+
* Declares an on / off setting (a checkbox) and returns its value. Shown only in the settings by default.
|
|
540
|
+
* @param defval - Default value, or every argument by name (`{ defval, title... }`).
|
|
541
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_bool`).
|
|
542
|
+
* @param opts - The common input options (`group`, `inline`, `tooltip`, `confirm`, `display`, `active`, `id`).
|
|
543
|
+
* @returns The current value: the user's value, else `defval`.
|
|
544
|
+
* @example
|
|
545
|
+
* ```js
|
|
546
|
+
* const showMa = input.bool(true, "Show MA");
|
|
547
|
+
* plot(ta.sma(close, 20), "MA", { display: showMa ? display.all : display.none });
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
393
550
|
bool(defval: boolean | InputArgs<InputOptions, boolean>, title?: string | InputArgs<InputOptions, boolean>, opts?: InputOptions): boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Declares a text setting and returns its value; with `options`, a drop-down list of choices.
|
|
553
|
+
* @param defval - Default value (one of `options` when they are given), or every argument by name.
|
|
554
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_string`).
|
|
555
|
+
* @param opts - `options` (a choice list) and the common input options.
|
|
556
|
+
* @returns The current value: the user's value, else `defval`.
|
|
557
|
+
* @example
|
|
558
|
+
* ```js
|
|
559
|
+
* const maType = input.string("EMA", "MA type", { options: ["SMA", "EMA"] });
|
|
560
|
+
* const ma = maType === "SMA" ? ta.sma(close, 20) : ta.ema(close, 20);
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
394
563
|
string(defval: string | InputArgs<StringInputOptions, string>, title?: string | InputArgs<StringInputOptions, string>, opts?: StringInputOptions): string;
|
|
395
|
-
/**
|
|
564
|
+
/**
|
|
565
|
+
* Declares a multi-line text setting (lines separated by a newline) and returns its value, e.g. a list of levels
|
|
566
|
+
* the script parses. Shown only in the settings by default.
|
|
567
|
+
* @param defval - Default text, or every argument by name.
|
|
568
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_text_area`).
|
|
569
|
+
* @param opts - The common input options.
|
|
570
|
+
* @returns The current text: the user's text, else `defval`.
|
|
571
|
+
* @example
|
|
572
|
+
* ```js
|
|
573
|
+
* const text = input.text_area("100\n105\n110", "Levels");
|
|
574
|
+
* for (const lvl of text.split("\n")) hline(Number(lvl), "Level " + lvl);
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
396
577
|
text_area(defval: string | InputArgs<InputOptions, string>, title?: string | InputArgs<InputOptions, string>, opts?: InputOptions): string;
|
|
397
578
|
/**
|
|
398
|
-
* Declares a colour
|
|
399
|
-
* `color.new(c, 90)`
|
|
579
|
+
* Declares a colour setting (a colour picker) and returns its value. The default's transparency is kept to 2
|
|
580
|
+
* decimals (`color.new(c, 90)` gives the alpha byte 26); a value given by the host is used as it is. Shown only in
|
|
581
|
+
* the settings by default.
|
|
582
|
+
* @param defval - Default colour (`color.blue`, `"#2962FF"`, `color.new(...)`), or every argument by name.
|
|
583
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_color`).
|
|
584
|
+
* @param opts - The common input options.
|
|
585
|
+
* @returns The current colour string: the user's colour, else `defval`.
|
|
586
|
+
* @example
|
|
587
|
+
* ```js
|
|
588
|
+
* const lineColor = input.color(color.teal, "Line colour");
|
|
589
|
+
* plot(ta.ema(close, 20), "EMA", { color: lineColor });
|
|
590
|
+
* ```
|
|
400
591
|
*/
|
|
401
592
|
color(defval: string | InputArgs<InputOptions, string>, title?: string | InputArgs<InputOptions, string>, opts?: InputOptions): string;
|
|
402
|
-
/**
|
|
593
|
+
/**
|
|
594
|
+
* Declares a source setting (the price a calculation reads) and returns it as a Series. The choices are `open`,
|
|
595
|
+
* `high`, `low`, `close`, `volume`, `hl2`, `hlc3`, `ohlc4`, `hlcc4`, and the outputs of other scripts on the chart
|
|
596
|
+
* when the host allows it (an unknown source gives `close`).
|
|
597
|
+
* @param defval - Default source, by name (`"close"`) or as the built-in Series (`close`), or every argument by
|
|
598
|
+
* name. Default: `"close"`.
|
|
599
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_source`).
|
|
600
|
+
* @param opts - The common input options.
|
|
601
|
+
* @returns The chosen source as a Series.
|
|
602
|
+
* @example
|
|
603
|
+
* ```js
|
|
604
|
+
* const src = input.source(close, "Source");
|
|
605
|
+
* plot(ta.sma(src, 20), "SMA");
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
403
608
|
source(defval?: string | Series, title?: string | InputArgs<InputOptions, string | Series>, opts?: InputOptions): Series;
|
|
404
|
-
/**
|
|
609
|
+
/**
|
|
610
|
+
* Declares a timeframe setting (a timeframe picker) and returns its value, for `request.security()` or
|
|
611
|
+
* `timeframe.change()`.
|
|
612
|
+
* @param defval - Default timeframe: `"60"` (60 minutes), `"D"`, `"W"`, `"M"`...; `""` is the chart's timeframe.
|
|
613
|
+
* Or every argument by name.
|
|
614
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_timeframe`).
|
|
615
|
+
* @param opts - `options` (a choice list of timeframes) and the common input options.
|
|
616
|
+
* @returns The current timeframe string (`""`: the chart's timeframe).
|
|
617
|
+
* @example
|
|
618
|
+
* ```js
|
|
619
|
+
* const tf = input.timeframe("D", "Higher timeframe");
|
|
620
|
+
* const htfClose = request.security("", tf, () => close);
|
|
621
|
+
* ```
|
|
622
|
+
*/
|
|
405
623
|
timeframe(defval: string | InputArgs<StringInputOptions, string>, title?: string | InputArgs<StringInputOptions, string>, opts?: StringInputOptions): string;
|
|
406
|
-
/**
|
|
624
|
+
/**
|
|
625
|
+
* Declares a trading-hours setting and returns its value, a session string for `time()` or `inSession()`.
|
|
626
|
+
* @param defval - Default session: `"HHMM-HHMM"`, optionally followed by `:` and the days (1 = Sunday ...
|
|
627
|
+
* 7 = Saturday), e.g. `"0930-1600"` or `"0930-1600:23456"`. Or every argument by name.
|
|
628
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_session`).
|
|
629
|
+
* @param opts - `options` (a choice list of sessions) and the common input options.
|
|
630
|
+
* @returns The current session string.
|
|
631
|
+
* @example
|
|
632
|
+
* ```js
|
|
633
|
+
* const sess = input.session("0930-1600", "Session");
|
|
634
|
+
* bgcolor(color.when(na(time("", sess)).not(), color.new(color.blue, 90)));
|
|
635
|
+
* ```
|
|
636
|
+
*/
|
|
407
637
|
session(defval: string | InputArgs<StringInputOptions, string>, title?: string | InputArgs<StringInputOptions, string>, opts?: StringInputOptions): string;
|
|
408
|
-
/**
|
|
638
|
+
/**
|
|
639
|
+
* Declares a symbol setting (a symbol search) and returns its value, a ticker id for `request.security()` of
|
|
640
|
+
* another symbol.
|
|
641
|
+
* @param defval - Default ticker id, `"EXCHANGE:TICKER"` (`"NASDAQ:MSFT"`), or every argument by name.
|
|
642
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_symbol`).
|
|
643
|
+
* @param opts - `options` (a choice list of symbols) and the common input options.
|
|
644
|
+
* @returns The current ticker id.
|
|
645
|
+
* @example
|
|
646
|
+
* ```js
|
|
647
|
+
* const other = input.symbol("NASDAQ:MSFT", "Compare with");
|
|
648
|
+
* plot(request.security(other, "", () => close), "Other close");
|
|
649
|
+
* ```
|
|
650
|
+
*/
|
|
409
651
|
symbol(defval: string | InputArgs<StringInputOptions, string>, title?: string | InputArgs<StringInputOptions, string>, opts?: StringInputOptions): string;
|
|
410
652
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
653
|
+
* Declares a price-level setting (a number field) and returns its value. With `confirm: true` the host can ask the
|
|
654
|
+
* user to pick it on the chart; an `inline` id shared with an `input.time()` makes one chart point of both.
|
|
655
|
+
* @param defval - Default price, or every argument by name.
|
|
656
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_float`).
|
|
657
|
+
* @param opts - The common input options.
|
|
658
|
+
* @returns The current price: the user's value, else `defval`.
|
|
659
|
+
* @example
|
|
660
|
+
* ```js
|
|
661
|
+
* const level = input.price(100, "Level", { confirm: true });
|
|
662
|
+
* hline(level, "Level");
|
|
663
|
+
* ```
|
|
413
664
|
*/
|
|
414
665
|
price(defval: number | InputArgs<InputOptions, number>, title?: string | InputArgs<InputOptions, number>, opts?: InputOptions): number;
|
|
415
666
|
/**
|
|
416
|
-
*
|
|
417
|
-
*
|
|
667
|
+
* Declares a choice among the fields of an enum made with `defineEnum()` and returns the chosen field. The
|
|
668
|
+
* settings list the fields by title; the host stores the field's name.
|
|
669
|
+
* @param defval - Default field (`MaType.sma`), or every argument by name. It must be one of `options`.
|
|
670
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_enum`).
|
|
671
|
+
* @param opts - `options` (only these fields of the enum) and the common input options.
|
|
672
|
+
* @returns The chosen field; compare it with `===`.
|
|
673
|
+
* @example
|
|
674
|
+
* ```js
|
|
675
|
+
* const MaType = defineEnum({ sma: "Simple", ema: "Exponential" });
|
|
676
|
+
* const maType = input.enum(MaType.sma, "Average");
|
|
677
|
+
* const ma = maType === MaType.ema ? ta.ema(close, 20) : ta.sma(close, 20);
|
|
678
|
+
* ```
|
|
418
679
|
*/
|
|
419
680
|
enum<F extends EnumField>(defval: F | InputArgs<EnumInputOptions, F>, title?: string | InputArgs<EnumInputOptions, F>, opts?: EnumInputOptions): F;
|
|
420
|
-
/**
|
|
681
|
+
/**
|
|
682
|
+
* Declares a date-and-time setting and returns it as a UNIX time in milliseconds. With `confirm: true` the host
|
|
683
|
+
* can ask the user to pick it on the chart. Shown only in the settings by default.
|
|
684
|
+
* @param defval - Default time in ms, usually from `timestamp()`, or every argument by name.
|
|
685
|
+
* @param title - Label in the settings, or the options with `title` in them. Default: none (id `input_time`).
|
|
686
|
+
* @param opts - The common input options.
|
|
687
|
+
* @returns The current time in ms: the user's value, else `defval`.
|
|
688
|
+
* @example
|
|
689
|
+
* ```js
|
|
690
|
+
* const start = input.time(timestamp("2024-01-01"), "Start");
|
|
691
|
+
* bgcolor(color.when(time.gte(start), color.new(color.green, 90)));
|
|
692
|
+
* ```
|
|
693
|
+
*/
|
|
421
694
|
time(defval: number | InputArgs<InputOptions, number>, title?: string | InputArgs<InputOptions, number>, opts?: InputOptions): number;
|
|
422
695
|
};
|
|
696
|
+
/**
|
|
697
|
+
* Opening price of each bar, as a Series. In a bar loop, `c.open` is the value of the current bar.
|
|
698
|
+
* @example
|
|
699
|
+
* ```js
|
|
700
|
+
* const body = close.sub(open);
|
|
701
|
+
* plot(body, "Body", { style: plot.style_columns });
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
423
704
|
export declare const open: Series;
|
|
705
|
+
/**
|
|
706
|
+
* Highest price of each bar, as a Series. In a bar loop, `c.high` is the value of the current bar.
|
|
707
|
+
* @example
|
|
708
|
+
* ```js
|
|
709
|
+
* plot(ta.highest(high, 20), "20-bar high");
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
424
712
|
export declare const high: Series;
|
|
713
|
+
/**
|
|
714
|
+
* Lowest price of each bar, as a Series. In a bar loop, `c.low` is the value of the current bar.
|
|
715
|
+
* @example
|
|
716
|
+
* ```js
|
|
717
|
+
* plot(ta.lowest(low, 20), "20-bar low");
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
425
720
|
export declare const low: Series;
|
|
721
|
+
/**
|
|
722
|
+
* Closing price of each bar, as a Series (on the forming bar, the latest price). The usual source of indicators.
|
|
723
|
+
* In a bar loop, `c.close` is the value of the current bar.
|
|
724
|
+
* @example
|
|
725
|
+
* ```js
|
|
726
|
+
* plot(ta.sma(close, 20), "SMA");
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
426
729
|
export declare const close: Series;
|
|
730
|
+
/**
|
|
731
|
+
* Traded volume of each bar, as a Series (NaN when the data has no volume). In a bar loop, `c.volume`.
|
|
732
|
+
* @example
|
|
733
|
+
* ```js
|
|
734
|
+
* plot(volume, "Volume", { style: plot.style_columns });
|
|
735
|
+
* ```
|
|
736
|
+
*/
|
|
427
737
|
export declare const volume: Series;
|
|
738
|
+
/**
|
|
739
|
+
* Median price of each bar, (high + low) / 2, as a Series.
|
|
740
|
+
* @example
|
|
741
|
+
* ```js
|
|
742
|
+
* plot(ta.sma(hl2, 10), "Median SMA");
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
428
745
|
export declare const hl2: Series;
|
|
746
|
+
/**
|
|
747
|
+
* Typical price of each bar, (high + low + close) / 3, as a Series.
|
|
748
|
+
* @example
|
|
749
|
+
* ```js
|
|
750
|
+
* plot(ta.sma(hlc3, 20), "Typical SMA");
|
|
751
|
+
* ```
|
|
752
|
+
*/
|
|
429
753
|
export declare const hlc3: Series;
|
|
754
|
+
/**
|
|
755
|
+
* Average price of each bar, (open + high + low + close) / 4, as a Series.
|
|
756
|
+
* @example
|
|
757
|
+
* ```js
|
|
758
|
+
* plot(ohlc4, "OHLC average");
|
|
759
|
+
* ```
|
|
760
|
+
*/
|
|
430
761
|
export declare const ohlc4: Series;
|
|
762
|
+
/**
|
|
763
|
+
* Weighted close of each bar, (high + low + close + close) / 4, as a Series.
|
|
764
|
+
* @example
|
|
765
|
+
* ```js
|
|
766
|
+
* plot(ta.ema(hlcc4, 20), "Weighted close EMA");
|
|
767
|
+
* ```
|
|
768
|
+
*/
|
|
431
769
|
export declare const hlcc4: Series;
|
|
432
|
-
/**
|
|
770
|
+
/**
|
|
771
|
+
* Index of each bar, as a Series: 0 on the oldest bar, then 1, 2... In a bar loop, `c.i` is the same number.
|
|
772
|
+
* @example
|
|
773
|
+
* ```js
|
|
774
|
+
* plotshape(bar_index.mod(10).eq(0), "Every 10 bars", { style: shape.circle });
|
|
775
|
+
* ```
|
|
776
|
+
*/
|
|
433
777
|
export declare const bar_index: Series;
|
|
434
|
-
/**
|
|
778
|
+
/**
|
|
779
|
+
* Index of the last bar of the chart, the same on every bar, as a Series. In a bar loop, `c.n - 1`.
|
|
780
|
+
* @example
|
|
781
|
+
* ```js
|
|
782
|
+
* bgcolor(color.when(bar_index.gte(last_bar_index.sub(9)), color.new(color.blue, 90)), { title: "Last 10 bars" });
|
|
783
|
+
* ```
|
|
784
|
+
*/
|
|
435
785
|
export declare const last_bar_index: Series;
|
|
436
|
-
/**
|
|
437
|
-
*
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
* and the first bar: as in PineScript, the first loaded bars (a day in progress) have a value. On D / W / M
|
|
458
|
-
* charts every bar is a new day (no time zone or session needed); on intraday charts it needs the chart context
|
|
459
|
-
* (timeframe, time zone, session). */
|
|
460
|
-
vwap: {
|
|
461
|
-
(source: Series, anchor?: Series): Series;
|
|
462
|
-
(source: Series, anchor: Series | undefined, stdev_mult: number): [Series, Series, Series];
|
|
463
|
-
};
|
|
464
|
-
/** `ta.vwma(source, length)` with the chart volume, as PineScript; a third argument gives another volume. */
|
|
465
|
-
vwma: (source: Series, length: number, vol?: Series) => Series;
|
|
466
|
-
/** `ta.mfi(source, length)` with the chart volume (PineScript takes 2 arguments). */
|
|
467
|
-
mfi: (source: Series, length: number) => Series;
|
|
468
|
-
/** `ta.pivothigh(source, leftbars, rightbars)` or `ta.pivothigh(leftbars, rightbars)` (source = high).
|
|
469
|
-
* The value appears `rightbars` bars after the pivot bar, as in PineScript. */
|
|
470
|
-
pivothigh: (sourceOrLeft: Series | number, leftOrRight: number | Series, rightbars?: number | Series) => Series;
|
|
471
|
-
/** `ta.pivotlow(source, leftbars, rightbars)` or `ta.pivotlow(leftbars, rightbars)` (source = low). */
|
|
472
|
-
pivotlow: (sourceOrLeft: Series | number, leftOrRight: number | Series, rightbars?: number | Series) => Series;
|
|
473
|
-
obv: Series;
|
|
474
|
-
pvt: Series;
|
|
475
|
-
accdist: Series;
|
|
476
|
-
nvi: Series;
|
|
477
|
-
pvi: Series;
|
|
478
|
-
iii: Series;
|
|
479
|
-
wad: Series;
|
|
480
|
-
wvad: Series;
|
|
481
|
-
sma: (source: Series, length: number | Series) => Series;
|
|
482
|
-
ema: (source: Series, length: number) => Series;
|
|
483
|
-
rma: (source: Series, length: number) => Series;
|
|
484
|
-
wma: (source: Series, length: number | Series) => Series;
|
|
485
|
-
rsi: (source: Series, length: number | Series) => Series;
|
|
486
|
-
change: (source: Series, length?: number) => Series;
|
|
487
|
-
mom: (source: Series, length: number) => Series;
|
|
488
|
-
roc: (source: Series, length: number) => Series;
|
|
489
|
-
cum: (source: Series) => Series;
|
|
490
|
-
stdev: (source: Series, length: number | Series, biased?: boolean) => Series;
|
|
491
|
-
variance: (source: Series, length: number | Series, biased?: boolean) => Series;
|
|
492
|
-
crossover: (a: Series, b: Series | number) => Series;
|
|
493
|
-
crossunder: (a: Series, b: Series | number) => Series;
|
|
494
|
-
cross: (a: Series, b: Series | number) => Series;
|
|
495
|
-
barssince: (condition: Series) => Series;
|
|
496
|
-
valuewhen: (condition: Series, source: Series, occurrence: number) => Series;
|
|
497
|
-
macd: (source: Series, fastLength: number, slowLength: number, signalLength: number) => [Series, Series, Series];
|
|
498
|
-
bb: (source: Series, length: number, mult: number) => [Series, Series, Series];
|
|
499
|
-
hma: (source: Series, length: number) => Series;
|
|
500
|
-
dev: (source: Series, length: number) => Series;
|
|
501
|
-
cci: (source: Series, length: number) => Series;
|
|
502
|
-
percentrank: (source: Series, length: number) => Series;
|
|
503
|
-
median: (source: Series, length: number) => Series;
|
|
504
|
-
linreg: (source: Series, length: number, offset?: number) => Series;
|
|
505
|
-
correlation: (a: Series, b: Series, length: number) => Series;
|
|
506
|
-
stoch: (source: Series, highSource: Series, lowSource: Series, length: number) => Series;
|
|
507
|
-
rising(source: Series, length: number): Series;
|
|
508
|
-
falling(source: Series, length: number): Series;
|
|
509
|
-
vwapBands(source: Series, volume: Series, anchor: Series | undefined, stdev_mult: number): [Series, Series, Series];
|
|
510
|
-
alma(source: Series, length?: number, offset?: number, sigma?: number, floor?: boolean): Series;
|
|
511
|
-
zigzag(bars: Bar[], deviation?: number, depth?: number, backstep?: number): [Series, Series, Series];
|
|
512
|
-
swma(source: Series): Series;
|
|
513
|
-
tsi(source: Series, shortLength: number, longLength: number): Series;
|
|
514
|
-
cmo(source: Series, length: number): Series;
|
|
515
|
-
bbw(source: Series, length: number, mult: number): Series;
|
|
516
|
-
range(source: Series, length: number): Series;
|
|
517
|
-
max(source: Series): Series;
|
|
518
|
-
min(source: Series): Series;
|
|
519
|
-
cog(source: Series, length?: number): Series;
|
|
520
|
-
mode(source: Series, length: number): Series;
|
|
521
|
-
percentile_linear_interpolation(source: Series, length: number, percentage: number): Series;
|
|
522
|
-
percentile_nearest_rank(source: Series, length: number, percentage: number): Series;
|
|
523
|
-
rci(source: Series, length: number): Series;
|
|
524
|
-
ta: {
|
|
525
|
-
sma: typeof taSeries.sma;
|
|
526
|
-
ema: typeof taSeries.ema;
|
|
527
|
-
wma: typeof taSeries.wma;
|
|
528
|
-
vwma: typeof taSeries.vwma;
|
|
529
|
-
rma: typeof taSeries.rma;
|
|
530
|
-
rsi: typeof taSeries.rsi;
|
|
531
|
-
macd: typeof taSeries.macd;
|
|
532
|
-
bb: typeof taSeries.bb;
|
|
533
|
-
stdev: typeof taSeries.stdev;
|
|
534
|
-
atr: typeof taSeries.atr;
|
|
535
|
-
tr: typeof taSeries.tr;
|
|
536
|
-
stoch: typeof taSeries.stoch;
|
|
537
|
-
crossover: typeof taSeries.crossover;
|
|
538
|
-
crossunder: typeof taSeries.crossunder;
|
|
539
|
-
cross: typeof taSeries.cross;
|
|
540
|
-
change: typeof taSeries.change;
|
|
541
|
-
mom: typeof taSeries.mom;
|
|
542
|
-
roc: typeof taSeries.roc;
|
|
543
|
-
highest: typeof taSeries.highest;
|
|
544
|
-
lowest: typeof taSeries.lowest;
|
|
545
|
-
rising: typeof taSeries.rising;
|
|
546
|
-
falling: typeof taSeries.falling;
|
|
547
|
-
cum: typeof taSeries.cum;
|
|
548
|
-
supertrend: typeof taSeries.supertrend;
|
|
549
|
-
vwap: typeof taSeries.vwap;
|
|
550
|
-
ichimoku: typeof taSeries.ichimoku;
|
|
551
|
-
linreg: typeof taSeries.linreg;
|
|
552
|
-
alma: typeof taSeries.alma;
|
|
553
|
-
zigzag: typeof taSeries.zigzag;
|
|
554
|
-
cci: typeof taSeries.cci;
|
|
555
|
-
sar: typeof taSeries.sar;
|
|
556
|
-
dev: typeof taSeries.dev;
|
|
557
|
-
variance: typeof taSeries.variance;
|
|
558
|
-
median: typeof taSeries.median;
|
|
559
|
-
swma: typeof taSeries.swma;
|
|
560
|
-
correlation: typeof taSeries.correlation;
|
|
561
|
-
percentrank: typeof taSeries.percentrank;
|
|
562
|
-
mfi: typeof taSeries.mfi;
|
|
563
|
-
hma: typeof taSeries.hma;
|
|
564
|
-
pivothigh: typeof taSeries.pivothigh;
|
|
565
|
-
pivotlow: typeof taSeries.pivotlow;
|
|
566
|
-
barssince: typeof taSeries.barssince;
|
|
567
|
-
valuewhen: typeof taSeries.valuewhen;
|
|
568
|
-
dmi: typeof taSeries.dmi;
|
|
569
|
-
tsi: typeof taSeries.tsi;
|
|
570
|
-
cmo: typeof taSeries.cmo;
|
|
571
|
-
kc: typeof taSeries.kc;
|
|
572
|
-
bbw: typeof taSeries.bbw;
|
|
573
|
-
wpr: typeof taSeries.wpr;
|
|
574
|
-
kcw: typeof taSeries.kcw;
|
|
575
|
-
range: typeof taSeries.range;
|
|
576
|
-
highestbars: typeof taSeries.highestbars;
|
|
577
|
-
lowestbars: typeof taSeries.lowestbars;
|
|
578
|
-
max: typeof taSeries.max;
|
|
579
|
-
min: typeof taSeries.min;
|
|
580
|
-
vwapBands: typeof taSeries.vwapBands;
|
|
581
|
-
obv: typeof taSeries.obv;
|
|
582
|
-
pvt: typeof taSeries.pvt;
|
|
583
|
-
accdist: typeof taSeries.accdist;
|
|
584
|
-
nvi: typeof taSeries.nvi;
|
|
585
|
-
pvi: typeof taSeries.pvi;
|
|
586
|
-
iii: typeof taSeries.iii;
|
|
587
|
-
wad: typeof taSeries.wad;
|
|
588
|
-
wvad: typeof taSeries.wvad;
|
|
589
|
-
cog: typeof taSeries.cog;
|
|
590
|
-
mode: typeof taSeries.mode;
|
|
591
|
-
percentile_linear_interpolation: typeof taSeries.percentile_linear_interpolation;
|
|
592
|
-
percentile_nearest_rank: typeof taSeries.percentile_nearest_rank;
|
|
593
|
-
rci: typeof taSeries.rci;
|
|
594
|
-
};
|
|
595
|
-
};
|
|
596
|
-
/** PineScript `fixnan(source)`: each `na` value becomes the previous non-`na` value.
|
|
597
|
-
* Accepts a Series or a per-bar color array (`undefined` = `na`, as returned by `color.when`). */
|
|
786
|
+
/**
|
|
787
|
+
* Technical analysis: moving averages, oscillators, bands, crosses, pivots and volume indicators. Each function
|
|
788
|
+
* computes a whole Series in one call: call it before any `eachBar()` loop and read a bar's value with `c.get(x)`.
|
|
789
|
+
* @example
|
|
790
|
+
* ```js
|
|
791
|
+
* const fast = ta.ema(close, 12), slow = ta.ema(close, 26);
|
|
792
|
+
* plot(fast, "Fast"); plot(slow, "Slow");
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
export declare const ta: TaNamespace;
|
|
796
|
+
/**
|
|
797
|
+
* Fills the gaps of a Series: each na value (NaN) becomes the last value that was not na. Values before the first
|
|
798
|
+
* non-na value stay na; +/-Infinity is kept.
|
|
799
|
+
* @param source - The Series to fill.
|
|
800
|
+
* @returns A Series without gaps after its first value.
|
|
801
|
+
* @example
|
|
802
|
+
* ```js
|
|
803
|
+
* const pivot = fixnan(ta.pivothigh(5, 5));
|
|
804
|
+
* plot(pivot, "Last pivot high", { style: plot.style_stepline });
|
|
805
|
+
* ```
|
|
806
|
+
*/
|
|
598
807
|
export declare function fixnan(source: Series): Series;
|
|
808
|
+
/**
|
|
809
|
+
* Fills the gaps of a per-bar colour array: each na entry (`undefined`) becomes the last colour that was not na.
|
|
810
|
+
* @param source - One colour per bar, as made by `color.when()`.
|
|
811
|
+
* @returns A colour array without gaps after its first colour.
|
|
812
|
+
* @example
|
|
813
|
+
* ```js
|
|
814
|
+
* const trendColor = fixnan(color.when(ta.crossover(close, ta.sma(close, 20)), color.green));
|
|
815
|
+
* barcolor(trendColor);
|
|
816
|
+
* ```
|
|
817
|
+
*/
|
|
599
818
|
export declare function fixnan(source: Array<string | undefined>): Array<string | undefined>;
|
|
600
|
-
/**
|
|
601
|
-
*
|
|
602
|
-
*
|
|
819
|
+
/**
|
|
820
|
+
* Tells, bar by bar, whether a Series is na (NaN or +/-Infinity): a Series of 1 where it is, 0 elsewhere.
|
|
821
|
+
* @param x - The Series to test.
|
|
822
|
+
* @returns A Series of 1 / 0.
|
|
823
|
+
* @example
|
|
824
|
+
* ```js
|
|
825
|
+
* const ma = ta.sma(close, 50);
|
|
826
|
+
* bgcolor(color.when(na(ma), color.new(color.gray, 90)), { title: "Warming up" });
|
|
827
|
+
* ```
|
|
828
|
+
*/
|
|
603
829
|
export declare function na(x: Series): Series;
|
|
830
|
+
/**
|
|
831
|
+
* Tells whether one value is na: NaN, +/-Infinity, `undefined` or `null` (a colour or a drawing), a deleted drawing,
|
|
832
|
+
* or an empty text. Use it on the numbers of a bar loop.
|
|
833
|
+
* @param x - The value to test.
|
|
834
|
+
* @returns true when the value is na.
|
|
835
|
+
* @example
|
|
836
|
+
* ```js
|
|
837
|
+
* const ma = ta.sma(close, 50);
|
|
838
|
+
* eachBar((c) => { if (!na(c.get(ma)) && c.close > c.get(ma)) label.new(c.i, c.high, "Above"); });
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
604
841
|
export declare function na(x: unknown): boolean;
|
|
605
|
-
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
842
|
+
/**
|
|
843
|
+
* Replaces the na values of a Series (NaN or +/-Infinity) with a replacement, bar by bar, e.g. to start a sum at 0.
|
|
844
|
+
* @param source - The Series to clean.
|
|
845
|
+
* @param replacement - The value for the na bars: a number, or a Series (its value on the same bar). Default: 0.
|
|
846
|
+
* @returns A Series without na values (unless the replacement is na).
|
|
847
|
+
* @example
|
|
848
|
+
* ```js
|
|
849
|
+
* const change = nz(close.sub(close.offset(1)));
|
|
850
|
+
* plot(change, "Change", { style: plot.style_columns });
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
608
853
|
export declare function nz(source: Series, replacement?: number | Series): Series;
|
|
854
|
+
/**
|
|
855
|
+
* Returns a value, or a replacement when it is na (NaN, +/-Infinity, `undefined`, `null`). Use it on the numbers of
|
|
856
|
+
* a bar loop.
|
|
857
|
+
* @param source - The value to check.
|
|
858
|
+
* @param replacement - The value returned when `source` is na. Default: 0.
|
|
859
|
+
* @returns `source`, or `replacement` when `source` is na.
|
|
860
|
+
* @example
|
|
861
|
+
* ```js
|
|
862
|
+
* const total = eachBar((c) => nz(c.prev()) + c.volume);
|
|
863
|
+
* plot(total, "Cumulative volume");
|
|
864
|
+
* ```
|
|
865
|
+
*/
|
|
609
866
|
export declare function nz<T>(source: T, replacement?: T): T;
|
|
610
|
-
/**
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
|
|
620
|
-
declare
|
|
621
|
-
|
|
622
|
-
/** color.* plus `when` — per-bar conditional colors for plot()/fill()/bgcolor()/barcolor(). */
|
|
623
|
-
export declare const color: {
|
|
624
|
-
new: typeof colorCore.new_color;
|
|
625
|
-
from_gradient: typeof fromGradient;
|
|
626
|
-
when: typeof colorWhen;
|
|
627
|
-
rgb(red: import("../index.js").simple_int, green: import("../index.js").simple_int, blue: import("../index.js").simple_int, transp?: import("../index.js").simple_float): string;
|
|
628
|
-
from_hex(hex: string, transp?: import("../index.js").simple_float): string;
|
|
629
|
-
new_color(baseColor: import("../types/index.js").color | null | undefined, transp: import("../index.js").simple_float): string;
|
|
630
|
-
r(clr: import("../types/index.js").color): import("../index.js").int;
|
|
631
|
-
g(clr: import("../types/index.js").color): import("../index.js").int;
|
|
632
|
-
b(clr: import("../types/index.js").color): import("../index.js").int;
|
|
633
|
-
t(clr: import("../types/index.js").color | null | undefined): import("../index.js").float;
|
|
634
|
-
aqua: "#00BCD4";
|
|
635
|
-
black: "#363A45";
|
|
636
|
-
blue: "#2962FF";
|
|
637
|
-
fuchsia: "#E040FB";
|
|
638
|
-
gray: "#787B86";
|
|
639
|
-
green: "#4CAF50";
|
|
640
|
-
lime: "#00E676";
|
|
641
|
-
maroon: "#880E4F";
|
|
642
|
-
navy: "#311B92";
|
|
643
|
-
olive: "#808000";
|
|
644
|
-
orange: "#FF9800";
|
|
645
|
-
purple: "#9C27B0";
|
|
646
|
-
red: "#F23645";
|
|
647
|
-
silver: "#B2B5BE";
|
|
648
|
-
teal: "#089981";
|
|
649
|
-
white: "#FFFFFF";
|
|
650
|
-
yellow: "#FDD835";
|
|
651
|
-
};
|
|
867
|
+
/**
|
|
868
|
+
* Colours: named colours (`color.red`, `color.teal`...), `color.new` for transparency, `color.rgb`, gradients, and
|
|
869
|
+
* `color.when` to pick a colour per bar for `plot()`, `fill()`, `bgcolor()` and `barcolor()`.
|
|
870
|
+
* @example
|
|
871
|
+
* ```js
|
|
872
|
+
* const up = close.gt(open);
|
|
873
|
+
* plot(close, "Close", { color: color.when(up, color.green, color.red) });
|
|
874
|
+
* bgcolor(color.new(color.blue, 90));
|
|
875
|
+
* ```
|
|
876
|
+
*/
|
|
877
|
+
export declare const color: ColorNamespace;
|
|
878
|
+
/** Options of {@link plot}. */
|
|
652
879
|
export interface ScriptPlotOptions {
|
|
653
|
-
/** Shift in bars
|
|
880
|
+
/** Shift in bars: the value of bar i is drawn on bar i + offset (negative: to the left). Default: 0. */
|
|
654
881
|
offset?: number;
|
|
655
|
-
/**
|
|
882
|
+
/** One colour, or one colour per bar (`color.when()`, `undefined` = not drawn). Default: blue `#2962FF`. */
|
|
656
883
|
color?: string | string[];
|
|
884
|
+
/** Line width in pixels. Default: 1. */
|
|
657
885
|
linewidth?: number;
|
|
886
|
+
/** How the values are drawn: `plot.style_line`, `plot.style_histogram`, `plot.style_columns`... Default: `plot.style_line`. */
|
|
658
887
|
style?: PlotConfig['style'];
|
|
659
|
-
/**
|
|
888
|
+
/** Dash pattern of the line: `plot.linestyle_solid`, `plot.linestyle_dashed` or `plot.linestyle_dotted` (one for all bars). Default: solid. */
|
|
660
889
|
linestyle?: PlotConfig['linestyle'];
|
|
890
|
+
/** Where the plot shows: `display.all`, `display.none` (hidden, still listed), `display.pane`, `display.status_line`, `display.data_window`. Default: `display.all`. */
|
|
661
891
|
display?: PlotConfig['display'];
|
|
892
|
+
/** Base level the histogram bars start from (`plot.style_histogram`). Default: 0. */
|
|
662
893
|
histbase?: number;
|
|
663
|
-
/**
|
|
894
|
+
/** true: draw on the price pane even when the script has its own pane. Default: false. */
|
|
664
895
|
force_overlay?: boolean;
|
|
665
|
-
/**
|
|
896
|
+
/** false: not listed in the style settings of the script. Default: true. */
|
|
666
897
|
editable?: boolean;
|
|
667
898
|
}
|
|
668
899
|
/**
|
|
669
|
-
*
|
|
670
|
-
*
|
|
900
|
+
* The titles an output gets when the script gives none (`plot` is "Plot", `hline` is "Level"...): the style settings
|
|
901
|
+
* and the alert lists show them.
|
|
671
902
|
*/
|
|
672
903
|
export declare const DEFAULT_OUTPUT_TITLES: {
|
|
904
|
+
/** Title of a `plot()` without one. */
|
|
673
905
|
readonly plot: "Plot";
|
|
906
|
+
/** Title of an `hline()` without one. */
|
|
674
907
|
readonly hline: "Level";
|
|
908
|
+
/** Title of a `fill()` between two plots without one. */
|
|
675
909
|
readonly plotFill: "Plots Background";
|
|
910
|
+
/** Title of a `fill()` between two hlines without one. */
|
|
676
911
|
readonly hlineFill: "Hlines Background";
|
|
912
|
+
/** Title of a `plotshape()` without one. */
|
|
677
913
|
readonly shape: "Shapes";
|
|
914
|
+
/** Title of a `plotchar()` without one. */
|
|
678
915
|
readonly char: "Chars";
|
|
916
|
+
/** Title of a `plotarrow()` without one. */
|
|
679
917
|
readonly arrow: "Arrows";
|
|
918
|
+
/** Title of a `bgcolor()` without one. */
|
|
680
919
|
readonly bgcolor: "Background Color";
|
|
920
|
+
/** Title of a `barcolor()` without one. */
|
|
681
921
|
readonly barcolor: "Bar Color";
|
|
922
|
+
/** Title of a `plotcandle()` without one. */
|
|
682
923
|
readonly candle: "PlotCandle";
|
|
924
|
+
/** Title of a `plotbar()` without one. */
|
|
683
925
|
readonly bar: "PlotBar";
|
|
684
926
|
};
|
|
685
|
-
/**
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
readonly
|
|
698
|
-
|
|
699
|
-
readonly
|
|
700
|
-
|
|
701
|
-
readonly
|
|
702
|
-
|
|
703
|
-
readonly
|
|
704
|
-
|
|
705
|
-
readonly
|
|
706
|
-
|
|
927
|
+
/** The `plot()` function with its `plot.style_*` and `plot.linestyle_*` constants. */
|
|
928
|
+
export interface PlotFunction {
|
|
929
|
+
/**
|
|
930
|
+
* Draws a Series on the chart (a line by default, or a histogram, columns, area, circles...) and lists it in the
|
|
931
|
+
* legend and the settings. Bars whose value is na (NaN or +/-Infinity) are not drawn.
|
|
932
|
+
* @param source - The values to draw: a Series, or a number for the same value on every bar.
|
|
933
|
+
* @param title - Name of the plot in the legend, the settings and the alerts. Default: "Plot".
|
|
934
|
+
* @param options - Colour, width, style, line style, offset, display... Default: `{}` (a blue line).
|
|
935
|
+
* @returns A handle to pass to `fill()`.
|
|
936
|
+
*/
|
|
937
|
+
(source: Series | number, title?: string, options?: ScriptPlotOptions): PlotHandle;
|
|
938
|
+
/** Style: a line through every value; na values are bridged. */
|
|
939
|
+
readonly style_line: 'line';
|
|
940
|
+
/** Style: a line with a gap where the value is na. */
|
|
941
|
+
readonly style_linebr: 'linebr';
|
|
942
|
+
/** Style: steps (horizontal then vertical moves); na values are bridged. */
|
|
943
|
+
readonly style_stepline: 'stepline';
|
|
944
|
+
/** Style: steps with a gap where the value is na. */
|
|
945
|
+
readonly style_steplinebr: 'steplinebr';
|
|
946
|
+
/** Style: steps with a diamond on each change. */
|
|
947
|
+
readonly style_stepline_diamond: 'stepline_diamond';
|
|
948
|
+
/** Style: a thin bar from the base line (`histbase`, default 0) to each value. */
|
|
949
|
+
readonly style_histogram: 'histogram';
|
|
950
|
+
/** Style: a wide column from the base line to each value. */
|
|
951
|
+
readonly style_columns: 'columns';
|
|
952
|
+
/** Style: a line with the area down to the base line filled. */
|
|
953
|
+
readonly style_area: 'area';
|
|
954
|
+
/** Style: a filled area with a gap where the value is na. */
|
|
955
|
+
readonly style_areabr: 'areabr';
|
|
956
|
+
/** Style: a dot on each value. */
|
|
957
|
+
readonly style_circles: 'circles';
|
|
958
|
+
/** Style: a cross on each value. */
|
|
959
|
+
readonly style_cross: 'cross';
|
|
960
|
+
/** Line style: solid. */
|
|
961
|
+
readonly linestyle_solid: 'solid';
|
|
962
|
+
/** Line style: dotted. */
|
|
963
|
+
readonly linestyle_dotted: 'dotted';
|
|
964
|
+
/** Line style: dashed. */
|
|
965
|
+
readonly linestyle_dashed: 'dashed';
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Draws a Series on the chart and lists it in the legend and the settings; `plot.style_*` and `plot.linestyle_*`
|
|
969
|
+
* pick how it is drawn.
|
|
970
|
+
* @example
|
|
971
|
+
* ```js
|
|
972
|
+
* const fast = plot(ta.ema(close, 12), "Fast", { color: color.teal, linewidth: 2 });
|
|
973
|
+
* plot(ta.rsi(close, 14), "RSI", { style: plot.style_histogram });
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
976
|
+
export declare const plot: PlotFunction;
|
|
707
977
|
export interface ScriptHLineOptions {
|
|
978
|
+
/** Colour of the line. Default: the host's (grey). */
|
|
708
979
|
color?: string;
|
|
709
|
-
/** Line style
|
|
980
|
+
/** Line style: `hline.style_solid`, `hline.style_dotted` or `hline.style_dashed`. Default: dashed. */
|
|
710
981
|
linestyle?: HLineConfig['linestyle'];
|
|
982
|
+
/** Width of the line in pixels. Default: 1. */
|
|
711
983
|
linewidth?: number;
|
|
712
|
-
/**
|
|
984
|
+
/** false: not listed in the style settings of the script. Default: true. */
|
|
713
985
|
editable?: boolean;
|
|
714
986
|
}
|
|
715
|
-
/**
|
|
716
|
-
|
|
717
|
-
/**
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
987
|
+
/** The `hline()` function with its `hline.style_*` constants. */
|
|
988
|
+
export interface HlineFunction {
|
|
989
|
+
/**
|
|
990
|
+
* Draws a horizontal line at a fixed price (a level such as 70 / 30 on an oscillator).
|
|
991
|
+
* @param price - Price of the line.
|
|
992
|
+
* @param title - Name of the line in the settings. Default: "Level".
|
|
993
|
+
* @param options - Colour, line style and width. Default: `{}` (a dashed line).
|
|
994
|
+
* @returns A handle to pass to `fill()`.
|
|
995
|
+
*/
|
|
996
|
+
(price: number, title?: string, options?: ScriptHLineOptions): PlotHandle;
|
|
997
|
+
/** Line style: solid. */
|
|
998
|
+
readonly style_solid: 'solid';
|
|
999
|
+
/** Line style: dotted. */
|
|
1000
|
+
readonly style_dotted: 'dotted';
|
|
1001
|
+
/** Line style: dashed (the default). */
|
|
1002
|
+
readonly style_dashed: 'dashed';
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Draws a horizontal line at a fixed price; `hline.style_*` picks its line style.
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```js
|
|
1008
|
+
* const top = hline(70, "Overbought", { color: color.red });
|
|
1009
|
+
* const bottom = hline(30, "Oversold", { linestyle: hline.style_dotted });
|
|
1010
|
+
* fill(top, bottom, color.new(color.purple, 90));
|
|
1011
|
+
* ```
|
|
1012
|
+
*/
|
|
1013
|
+
export declare const hline: HlineFunction;
|
|
723
1014
|
export interface ScriptFillOptions {
|
|
724
|
-
/**
|
|
1015
|
+
/** Fill colour: one colour, or one per bar from `color.when()`. */
|
|
725
1016
|
color?: string | string[];
|
|
1017
|
+
/** Name of the fill in the settings. Default: "Plots Background" / "Hlines Background". */
|
|
726
1018
|
title?: string;
|
|
727
|
-
/**
|
|
1019
|
+
/** false: not listed in the style settings of the script. Default: true. */
|
|
728
1020
|
editable?: boolean;
|
|
729
1021
|
}
|
|
730
1022
|
/** A fill colour argument: a colour, na (null / undefined), or a per-bar array from color.when(). */
|
|
@@ -732,16 +1024,51 @@ export type ScriptFillColor = string | null | undefined | Array<string | null |
|
|
|
732
1024
|
/** A gradient value argument: a number or a Series. */
|
|
733
1025
|
export type ScriptFillValue = number | Series;
|
|
734
1026
|
/**
|
|
735
|
-
*
|
|
736
|
-
* -
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
*
|
|
1027
|
+
* Colours the space between two plots or two hlines, with an options object.
|
|
1028
|
+
* @param a - First plot or hline (the handle `plot()` / `hline()` returned).
|
|
1029
|
+
* @param b - Second plot or hline, of the same kind as `a`.
|
|
1030
|
+
* @param options - Colour (one, or one per bar from `color.when()`), title, editable. Default: `{}`.
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```js
|
|
1033
|
+
* const upper = plot(ta.sma(high, 20), "Upper");
|
|
1034
|
+
* const lower = plot(ta.sma(low, 20), "Lower");
|
|
1035
|
+
* fill(upper, lower, { color: color.new(color.blue, 85), title: "Channel" });
|
|
1036
|
+
* ```
|
|
742
1037
|
*/
|
|
743
1038
|
export declare function fill(a: PlotHandle, b: PlotHandle, options?: ScriptFillOptions): void;
|
|
1039
|
+
/**
|
|
1040
|
+
* Colours the space between two plots or two hlines with one colour (or one per bar).
|
|
1041
|
+
* @param a - First plot or hline (the handle `plot()` / `hline()` returned).
|
|
1042
|
+
* @param b - Second plot or hline, of the same kind as `a`.
|
|
1043
|
+
* @param color - Fill colour, or one per bar from `color.when()`; na (null) leaves a bar unfilled.
|
|
1044
|
+
* @param title - Name of the fill in the settings. Default: "Plots Background" / "Hlines Background".
|
|
1045
|
+
* @param rest - `editable` (false keeps it out of the settings); `show_last`, `fillgaps` and `display` are accepted
|
|
1046
|
+
* and not used.
|
|
1047
|
+
* @example
|
|
1048
|
+
* ```js
|
|
1049
|
+
* const top = hline(70), bottom = hline(30);
|
|
1050
|
+
* fill(top, bottom, color.new(color.purple, 90), "Zone");
|
|
1051
|
+
* ```
|
|
1052
|
+
*/
|
|
744
1053
|
export declare function fill(a: PlotHandle, b: PlotHandle, color: ScriptFillColor, title?: string, ...rest: unknown[]): void;
|
|
1054
|
+
/**
|
|
1055
|
+
* Colours the space between two plots with a gradient: `top_color` at `top_value`, `bottom_color` at
|
|
1056
|
+
* `bottom_value`; the values and colours may change from bar to bar.
|
|
1057
|
+
* @param a - First plot (the handle `plot()` returned).
|
|
1058
|
+
* @param b - Second plot.
|
|
1059
|
+
* @param top_value - Price of the top colour: a number or a Series.
|
|
1060
|
+
* @param bottom_value - Price of the bottom colour: a number or a Series.
|
|
1061
|
+
* @param top_color - Colour at the top, or one per bar.
|
|
1062
|
+
* @param bottom_color - Colour at the bottom, or one per bar.
|
|
1063
|
+
* @param title - Name of the fill in the settings. Default: "Plots Background".
|
|
1064
|
+
* @param rest - `editable` (false keeps it out of the settings); other arguments are accepted and not used.
|
|
1065
|
+
* @example
|
|
1066
|
+
* ```js
|
|
1067
|
+
* const basis = ta.sma(close, 20);
|
|
1068
|
+
* const p = plot(close), q = plot(basis);
|
|
1069
|
+
* fill(p, q, high, basis, color.green, color.new(color.green, 100));
|
|
1070
|
+
* ```
|
|
1071
|
+
*/
|
|
745
1072
|
export declare function fill(a: PlotHandle, b: PlotHandle, top_value: ScriptFillValue, bottom_value: ScriptFillValue, top_color: ScriptFillColor, bottom_color: ScriptFillColor, title?: string, ...rest: unknown[]): void;
|
|
746
1073
|
export interface PlotShapeOptions {
|
|
747
1074
|
style?: ShapeStyle;
|
|
@@ -762,21 +1089,46 @@ export interface PlotShapeOptions {
|
|
|
762
1089
|
export interface PlotCharOptions extends Omit<PlotShapeOptions, 'style'> {
|
|
763
1090
|
char?: string;
|
|
764
1091
|
}
|
|
765
|
-
/**
|
|
1092
|
+
/**
|
|
1093
|
+
* Draws a shape (triangle, arrow, circle, label...) on each bar where the condition is true: buy and sell signals.
|
|
1094
|
+
* @param condition - Series that is true (non-zero) on the bars that get a shape. With `location.absolute`, its
|
|
1095
|
+
* value is the price of the shape.
|
|
1096
|
+
* @param title - Name of the shapes in the settings and the alerts. Default: "Shapes".
|
|
1097
|
+
* @param options - Shape (`shape.*`), place (`location.*`), colour, text, size (`size.*`), offset... Default: `{}`
|
|
1098
|
+
* (a cross above the bar).
|
|
1099
|
+
* @example
|
|
1100
|
+
* ```js
|
|
1101
|
+
* const up = ta.crossover(ta.ema(close, 9), ta.ema(close, 21));
|
|
1102
|
+
* plotshape(up, "Buy", { style: shape.triangleup, location: location.belowbar, color: color.green });
|
|
1103
|
+
* ```
|
|
1104
|
+
*/
|
|
766
1105
|
export declare function plotshape(condition: Series, title?: string, options?: PlotShapeOptions): void;
|
|
767
|
-
/**
|
|
1106
|
+
/**
|
|
1107
|
+
* Draws a character (a letter, an emoji...) on each bar where the condition is true.
|
|
1108
|
+
* @param condition - Series that is true (non-zero) on the bars that get the character. With `location.absolute`,
|
|
1109
|
+
* its value is the price of the character.
|
|
1110
|
+
* @param title - Name of the characters in the settings and the alerts. Default: "Chars".
|
|
1111
|
+
* @param options - Character (`char`), place (`location.*`), colour, text, size (`size.*`), offset... Default: `{}`
|
|
1112
|
+
* (a star above the bar).
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```js
|
|
1115
|
+
* const gapUp = open.gt(high.offset(1));
|
|
1116
|
+
* plotchar(gapUp, "Gap up", { char: "▲", location: location.abovebar, color: color.teal });
|
|
1117
|
+
* ```
|
|
1118
|
+
*/
|
|
768
1119
|
export declare function plotchar(condition: Series, title?: string, options?: PlotCharOptions): void;
|
|
769
1120
|
export interface PlotArrowOptions {
|
|
770
|
-
/**
|
|
1121
|
+
/** Colour of the up arrows: one colour or one per bar. Default: #00FF00. */
|
|
771
1122
|
colorup?: string | Array<string | undefined>;
|
|
772
|
-
/**
|
|
1123
|
+
/** Colour of the down arrows: one colour or one per bar. Default: #FF0000. */
|
|
773
1124
|
colordown?: string | Array<string | undefined>;
|
|
774
|
-
/**
|
|
1125
|
+
/** Moves the arrows by this many bars (the arrow of bar i is drawn on bar i + offset). Default: 0. */
|
|
775
1126
|
offset?: number;
|
|
776
|
-
/**
|
|
1127
|
+
/** Height of the smallest arrow, in pixels. Default: 5. */
|
|
777
1128
|
minheight?: number;
|
|
778
|
-
/**
|
|
1129
|
+
/** Height of the largest arrow, in pixels. Default: 100. */
|
|
779
1130
|
maxheight?: number;
|
|
1131
|
+
/** Where the arrows are shown: `display.all`, `display.none`... Default: everywhere. */
|
|
780
1132
|
display?: ArrowConfig['display'];
|
|
781
1133
|
/** Draw on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false. */
|
|
782
1134
|
force_overlay?: boolean;
|
|
@@ -784,14 +1136,28 @@ export interface PlotArrowOptions {
|
|
|
784
1136
|
editable?: boolean;
|
|
785
1137
|
}
|
|
786
1138
|
/**
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
1139
|
+
* Draws an up arrow below the bar where the value is positive and a down arrow above it where it is negative;
|
|
1140
|
+
* nothing for 0 or na. The larger the value, the longer the arrow (between `minheight` and `maxheight`).
|
|
1141
|
+
* @param series - Series whose sign gives the arrow's direction and whose size gives its length.
|
|
1142
|
+
* @param title - Name of the arrows in the settings and the alerts. Default: "Arrows".
|
|
1143
|
+
* @param options - Colours, heights, offset, display. Default: `{}` (green up, red down).
|
|
1144
|
+
* @example
|
|
1145
|
+
* ```js
|
|
1146
|
+
* const change = close.sub(close.offset(1));
|
|
1147
|
+
* plotarrow(change, "Change", { colorup: color.teal, colordown: color.orange });
|
|
1148
|
+
* ```
|
|
790
1149
|
*/
|
|
791
1150
|
export declare function plotarrow(series: Series, title?: string, options?: PlotArrowOptions): void;
|
|
792
1151
|
/**
|
|
793
|
-
*
|
|
794
|
-
*
|
|
1152
|
+
* Colours the background of the script's pane behind each bar.
|
|
1153
|
+
* @param colors - One colour for every bar, or one per bar from `color.when()` (no colour on an na entry).
|
|
1154
|
+
* @param options - `offset` (bars to move the colours by), `title` (default "Background Color"), `force_overlay`
|
|
1155
|
+
* (true: colour the price chart's pane), `editable`. Default: `{}`.
|
|
1156
|
+
* @example
|
|
1157
|
+
* ```js
|
|
1158
|
+
* const rsi = ta.rsi(close, 14);
|
|
1159
|
+
* bgcolor(color.when(rsi.gt(70), color.new(color.red, 85)));
|
|
1160
|
+
* ```
|
|
795
1161
|
*/
|
|
796
1162
|
export declare function bgcolor(colors: string | Array<string | undefined>, options?: {
|
|
797
1163
|
offset?: number;
|
|
@@ -799,7 +1165,16 @@ export declare function bgcolor(colors: string | Array<string | undefined>, opti
|
|
|
799
1165
|
force_overlay?: boolean;
|
|
800
1166
|
editable?: boolean;
|
|
801
1167
|
}): void;
|
|
802
|
-
/**
|
|
1168
|
+
/**
|
|
1169
|
+
* Colours the chart's candles or bars, replacing their usual colours.
|
|
1170
|
+
* @param colors - One colour for every bar, or one per bar from `color.when()` (usual colour on an na entry).
|
|
1171
|
+
* @param options - `title` (default "Bar Color") and `editable`. Default: `{}`.
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```js
|
|
1174
|
+
* const trendUp = close.gt(ta.sma(close, 50));
|
|
1175
|
+
* barcolor(color.when(trendUp, color.green, color.red));
|
|
1176
|
+
* ```
|
|
1177
|
+
*/
|
|
803
1178
|
export declare function barcolor(colors: string | Array<string | undefined>, options?: {
|
|
804
1179
|
title?: string;
|
|
805
1180
|
editable?: boolean;
|
|
@@ -807,12 +1182,13 @@ export declare function barcolor(colors: string | Array<string | undefined>, opt
|
|
|
807
1182
|
/** A colour argument of plotcandle() / plotbar(): a colour, or per-bar colours (null / undefined entries are na). */
|
|
808
1183
|
export type ScriptCandleColor = string | Array<string | null | undefined>;
|
|
809
1184
|
export interface PlotCandleOptions {
|
|
810
|
-
/** Body colour:
|
|
1185
|
+
/** Body colour: one colour or one per bar (`color.when()`); an na entry gives a see-through body. Default: #2962FF. */
|
|
811
1186
|
color?: ScriptCandleColor;
|
|
812
|
-
/** Wick colour:
|
|
1187
|
+
/** Wick colour: one colour or one per bar. Default: #737375. */
|
|
813
1188
|
wickcolor?: ScriptCandleColor;
|
|
814
|
-
/** Border colour:
|
|
1189
|
+
/** Border colour: one colour or one per bar. Default: #000000. */
|
|
815
1190
|
bordercolor?: ScriptCandleColor;
|
|
1191
|
+
/** Where the candles are shown: `display.all`, `display.none`... Default: everywhere. */
|
|
816
1192
|
display?: CandleConfig['display'];
|
|
817
1193
|
/** Draw on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false. */
|
|
818
1194
|
force_overlay?: boolean;
|
|
@@ -820,8 +1196,9 @@ export interface PlotCandleOptions {
|
|
|
820
1196
|
editable?: boolean;
|
|
821
1197
|
}
|
|
822
1198
|
export interface PlotBarOptions {
|
|
823
|
-
/** Bar colour:
|
|
1199
|
+
/** Bar colour: one colour or one per bar (`color.when()`); an na entry gives a see-through bar. Default: #2962FF. */
|
|
824
1200
|
color?: ScriptCandleColor;
|
|
1201
|
+
/** Where the bars are shown: `display.all`, `display.none`... Default: everywhere. */
|
|
825
1202
|
display?: CandleConfig['display'];
|
|
826
1203
|
/** Draw on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false. */
|
|
827
1204
|
force_overlay?: boolean;
|
|
@@ -833,18 +1210,41 @@ export interface PlotBarOptions {
|
|
|
833
1210
|
* them (reference: body / bar #2962FF, wick #737375, border #000000; the wick and border do not follow the body).
|
|
834
1211
|
*/
|
|
835
1212
|
export declare const DEFAULT_CANDLE_COLORS: {
|
|
1213
|
+
/** Body colour (and the colour of `plotbar()` bars). */
|
|
836
1214
|
readonly color: "#2962FF";
|
|
1215
|
+
/** Wick colour. */
|
|
837
1216
|
readonly wickColor: "#737375";
|
|
1217
|
+
/** Border colour. */
|
|
838
1218
|
readonly borderColor: "#000000";
|
|
839
1219
|
};
|
|
840
1220
|
/**
|
|
841
|
-
*
|
|
842
|
-
*
|
|
1221
|
+
* Draws candles from four Series (for example the candles of another symbol, or smoothed prices). A bar where one of
|
|
1222
|
+
* the four values is na has no candle.
|
|
1223
|
+
* @param open - Open of each candle.
|
|
1224
|
+
* @param high - High of each candle.
|
|
1225
|
+
* @param low - Low of each candle.
|
|
1226
|
+
* @param close - Close of each candle.
|
|
1227
|
+
* @param title - Name of the candles in the settings. Default: "PlotCandle".
|
|
1228
|
+
* @param options - Body, wick and border colours, display, force_overlay, editable. Default: `{}`.
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```js
|
|
1231
|
+
* const o = ta.ema(open, 5), h = ta.ema(high, 5), l = ta.ema(low, 5), c = ta.ema(close, 5);
|
|
1232
|
+
* plotcandle(o, h, l, c, "Smoothed", { color: color.when(c.gt(o), color.teal, color.red) });
|
|
1233
|
+
* ```
|
|
843
1234
|
*/
|
|
844
1235
|
export declare function plotcandle(open: Series, high: Series, low: Series, close: Series, title?: string, options?: PlotCandleOptions): void;
|
|
845
1236
|
/**
|
|
846
|
-
*
|
|
847
|
-
*
|
|
1237
|
+
* Draws open-high-low-close bars from four Series. A bar where one of the four values is na is not drawn.
|
|
1238
|
+
* @param open - Open of each bar.
|
|
1239
|
+
* @param high - High of each bar.
|
|
1240
|
+
* @param low - Low of each bar.
|
|
1241
|
+
* @param close - Close of each bar.
|
|
1242
|
+
* @param title - Name of the bars in the settings. Default: "PlotBar".
|
|
1243
|
+
* @param options - Colour, display, force_overlay, editable. Default: `{}`.
|
|
1244
|
+
* @example
|
|
1245
|
+
* ```js
|
|
1246
|
+
* plotbar(open, high, low, close, "Bars", { color: color.when(close.gt(open), color.green, color.red) });
|
|
1247
|
+
* ```
|
|
848
1248
|
*/
|
|
849
1249
|
export declare function plotbar(open: Series, high: Series, low: Series, close: Series, title?: string, options?: PlotBarOptions): void;
|
|
850
1250
|
/**
|
|
@@ -868,6 +1268,20 @@ export interface BarContext {
|
|
|
868
1268
|
/** This block's own previous output (PineScript self-reference, offset >= 1). */
|
|
869
1269
|
prev(offset?: number): number;
|
|
870
1270
|
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Runs a function on every bar, oldest first, for logic that needs the bar's values one at a time (state, ifs,
|
|
1273
|
+
* loops). The function reads the bar through `c` (`c.close`, `c.get(series)`, `c.get(series, 1)` for one bar back)
|
|
1274
|
+
* and returns the bar's value of the Series that `eachBar` gives back (na when it returns nothing).
|
|
1275
|
+
* @param fn - Called once per bar with the bar's context; returns a number (or true / false) for that bar.
|
|
1276
|
+
* @returns Series of the values the function returned.
|
|
1277
|
+
* @example
|
|
1278
|
+
* ```js
|
|
1279
|
+
* const fast = ta.sma(close, 10);
|
|
1280
|
+
* let count = 0;
|
|
1281
|
+
* const streak = eachBar((c) => (count = c.get(close) > c.get(fast) ? count + 1 : 0));
|
|
1282
|
+
* plot(streak, "Bars above");
|
|
1283
|
+
* ```
|
|
1284
|
+
*/
|
|
871
1285
|
export declare function eachBar(fn: (c: BarContext) => number | boolean | void): Series;
|
|
872
1286
|
/**
|
|
873
1287
|
* Runs the strategy logic once per bar, in order, like {@link eachBar}. On each bar the engine first
|
|
@@ -924,7 +1338,7 @@ export type StrategyApi = ((title: string, options?: StrategyOptions) => void) &
|
|
|
924
1338
|
* });
|
|
925
1339
|
* ```
|
|
926
1340
|
*/
|
|
927
|
-
export declare const strategy:
|
|
1341
|
+
export declare const strategy: StrategyNamespace;
|
|
928
1342
|
/** Types of chart PineScript tells apart (`chart.is_*`); every other type is 'standard'. */
|
|
929
1343
|
export type ChartType = 'standard' | 'heikinashi' | 'renko' | 'kagi' | 'linebreak' | 'pnf' | 'range';
|
|
930
1344
|
/**
|
|
@@ -992,6 +1406,8 @@ export interface ChartContext {
|
|
|
992
1406
|
ticker?: string;
|
|
993
1407
|
/** The chart's own symbol (PineScript `syminfo.main_tickerid`, the same inside `request.security`); default `tickerid` */
|
|
994
1408
|
mainTickerid?: string;
|
|
1409
|
+
/** The chart's own timeframe (`timeframe.main_period`, the same inside `request.security`); default `timeframe` */
|
|
1410
|
+
mainTimeframe?: string;
|
|
995
1411
|
/** Two-letter code of the country the symbol trades in (PineScript `syminfo.country`): "US", "IN" */
|
|
996
1412
|
country?: string | null;
|
|
997
1413
|
/** Contract a continuous future stands for (PineScript `syminfo.current_contract`): "ESZ2026" for CME_MINI:ES1! */
|
|
@@ -1151,143 +1567,200 @@ export declare class MissingSymbolDataError extends Error {
|
|
|
1151
1567
|
* PineScript `timeframe.*`: the chart timeframe variables (from the chart context), and
|
|
1152
1568
|
* `in_seconds(timeframe?)`, `from_seconds(seconds)`.
|
|
1153
1569
|
*/
|
|
1154
|
-
export declare const timeframe:
|
|
1155
|
-
period: string;
|
|
1156
|
-
main_period: string;
|
|
1157
|
-
multiplier: number;
|
|
1158
|
-
isintraday: boolean;
|
|
1159
|
-
isdaily: boolean;
|
|
1160
|
-
isweekly: boolean;
|
|
1161
|
-
ismonthly: boolean;
|
|
1162
|
-
isminutes: boolean;
|
|
1163
|
-
isseconds: boolean;
|
|
1164
|
-
isticks: boolean;
|
|
1165
|
-
isdwm: boolean;
|
|
1166
|
-
/** PineScript `timeframe.change(tf)`: 1 on bars that open a new `tf` period (0 on the first bar). */
|
|
1167
|
-
change(tf: string): Series;
|
|
1168
|
-
/** Seconds in `timeframe`; without it (or with "") the chart timeframe, as in PineScript. */
|
|
1169
|
-
in_seconds(tf?: string): number;
|
|
1170
|
-
from_seconds(seconds: import("../index.js").int): import("../index.js").simple_string;
|
|
1171
|
-
info(timeframe: import("../index.js").simple_string): timeframeCore.TimeframeInfo;
|
|
1172
|
-
};
|
|
1570
|
+
export declare const timeframe: TimeframeNamespace;
|
|
1173
1571
|
/**
|
|
1174
1572
|
* PineScript `syminfo.*`, from the chart context (inside `request.security`, the requested symbol's). A field the
|
|
1175
1573
|
* symbol has none of is na ("" for a text); a field the host did not give throws.
|
|
1176
1574
|
*/
|
|
1177
|
-
export declare const syminfo:
|
|
1178
|
-
readonly mintick: number;
|
|
1179
|
-
readonly minmove: number;
|
|
1180
|
-
readonly pricescale: number;
|
|
1181
|
-
readonly pointvalue: number;
|
|
1182
|
-
readonly mincontract: number;
|
|
1183
|
-
readonly timezone: string;
|
|
1184
|
-
readonly tickerid: string;
|
|
1185
|
-
readonly main_tickerid: string;
|
|
1186
|
-
readonly ticker: string;
|
|
1187
|
-
readonly prefix: string;
|
|
1188
|
-
readonly session: string;
|
|
1189
|
-
readonly type: string;
|
|
1190
|
-
readonly currency: string;
|
|
1191
|
-
readonly basecurrency: string;
|
|
1192
|
-
readonly root: string;
|
|
1193
|
-
readonly description: string;
|
|
1194
|
-
readonly country: string;
|
|
1195
|
-
readonly current_contract: string;
|
|
1196
|
-
readonly expiration_date: number;
|
|
1197
|
-
readonly sector: string;
|
|
1198
|
-
readonly industry: string;
|
|
1199
|
-
readonly isin: string;
|
|
1200
|
-
readonly volumetype: string;
|
|
1201
|
-
readonly employees: number;
|
|
1202
|
-
readonly shareholders: number;
|
|
1203
|
-
readonly shares_outstanding_total: number;
|
|
1204
|
-
readonly shares_outstanding_float: number;
|
|
1205
|
-
readonly recommendations_buy: number;
|
|
1206
|
-
readonly recommendations_buy_strong: number;
|
|
1207
|
-
readonly recommendations_hold: number;
|
|
1208
|
-
readonly recommendations_sell: number;
|
|
1209
|
-
readonly recommendations_sell_strong: number;
|
|
1210
|
-
readonly recommendations_total: number;
|
|
1211
|
-
readonly recommendations_date: number;
|
|
1212
|
-
readonly target_price_average: number;
|
|
1213
|
-
readonly target_price_high: number;
|
|
1214
|
-
readonly target_price_low: number;
|
|
1215
|
-
readonly target_price_median: number;
|
|
1216
|
-
readonly target_price_estimates: number;
|
|
1217
|
-
readonly target_price_date: number;
|
|
1218
|
-
};
|
|
1575
|
+
export declare const syminfo: SyminfoNamespace;
|
|
1219
1576
|
/** A calendar function: `(time, timezone?)` on a UNIX time or on a Series of times. */
|
|
1220
1577
|
interface CalendarFunction {
|
|
1578
|
+
/**
|
|
1579
|
+
* @param time - A time in UNIX milliseconds.
|
|
1580
|
+
* @param timezone - Time zone to read the time in: "America/New_York", "UTC+2"... Default: the exchange's.
|
|
1581
|
+
* @returns The calendar field of that time.
|
|
1582
|
+
*/
|
|
1221
1583
|
(time: number, timezone?: string): number;
|
|
1584
|
+
/**
|
|
1585
|
+
* @param time - A Series of times in UNIX milliseconds, e.g. `time`.
|
|
1586
|
+
* @param timezone - Time zone to read the times in: "America/New_York", "UTC+2"... Default: the exchange's.
|
|
1587
|
+
* @returns Series of the calendar field of each time.
|
|
1588
|
+
*/
|
|
1222
1589
|
(time: Series, timezone?: string): Series;
|
|
1223
1590
|
}
|
|
1224
|
-
/**
|
|
1591
|
+
/**
|
|
1592
|
+
* The year of a time (2025...). Works on one time or on a Series of times (`year(time)` gives the value of each bar).
|
|
1593
|
+
* @example
|
|
1594
|
+
* ```js
|
|
1595
|
+
* const newYear = year(time).neq(year(time).offset(1));
|
|
1596
|
+
* bgcolor(color.when(newYear, color.new(color.blue, 80)));
|
|
1597
|
+
* ```
|
|
1598
|
+
*/
|
|
1225
1599
|
export declare const year: CalendarFunction;
|
|
1226
|
-
/**
|
|
1600
|
+
/**
|
|
1601
|
+
* The month of a time, 1 (January) to 12. Works on one time or on a Series of times (`month(time)` gives the value of each bar).
|
|
1602
|
+
* @example
|
|
1603
|
+
* ```js
|
|
1604
|
+
* const january = month(time).eq(1);
|
|
1605
|
+
* bgcolor(color.when(january, color.new(color.teal, 85)));
|
|
1606
|
+
* ```
|
|
1607
|
+
*/
|
|
1227
1608
|
export declare const month: CalendarFunction;
|
|
1228
|
-
/**
|
|
1609
|
+
/**
|
|
1610
|
+
* The week of the year of a time, 1 to 53. Works on one time or on a Series of times (`weekofyear(time)` gives the value of each bar).
|
|
1611
|
+
* @example
|
|
1612
|
+
* ```js
|
|
1613
|
+
* plot(weekofyear(time), "Week");
|
|
1614
|
+
* ```
|
|
1615
|
+
*/
|
|
1229
1616
|
export declare const weekofyear: CalendarFunction;
|
|
1230
|
-
/**
|
|
1617
|
+
/**
|
|
1618
|
+
* The day of the month of a time, 1 to 31. Works on one time or on a Series of times (`dayofmonth(time)` gives the value of each bar).
|
|
1619
|
+
* @example
|
|
1620
|
+
* ```js
|
|
1621
|
+
* plot(dayofmonth(time, "UTC"), "Day of month");
|
|
1622
|
+
* ```
|
|
1623
|
+
*/
|
|
1231
1624
|
export declare const dayofmonth: CalendarFunction;
|
|
1232
|
-
/**
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1625
|
+
/**
|
|
1626
|
+
* The day of the week of a time, 1 (Sunday) to 7 (Saturday), on one time or a Series of times; compare it with the
|
|
1627
|
+
* `dayofweek.monday`... constants.
|
|
1628
|
+
* @example
|
|
1629
|
+
* ```js
|
|
1630
|
+
* const monday = dayofweek(time).eq(dayofweek.monday);
|
|
1631
|
+
* bgcolor(color.when(monday, color.new(color.gray, 90)));
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
export declare const dayofweek: CalendarFunction & typeof pineConstants.daysOfWeek;
|
|
1635
|
+
/**
|
|
1636
|
+
* The hour of a time, 0 to 23. Works on one time or on a Series of times (`hour(time)` gives the value of each bar).
|
|
1637
|
+
* @example
|
|
1638
|
+
* ```js
|
|
1639
|
+
* const morning = hour(time).lt(12);
|
|
1640
|
+
* bgcolor(color.when(morning, color.new(color.orange, 90)));
|
|
1641
|
+
* ```
|
|
1642
|
+
*/
|
|
1244
1643
|
export declare const hour: CalendarFunction;
|
|
1245
|
-
/**
|
|
1644
|
+
/**
|
|
1645
|
+
* The minute of a time, 0 to 59. Works on one time or on a Series of times (`minute(time)` gives the value of each bar).
|
|
1646
|
+
* @example
|
|
1647
|
+
* ```js
|
|
1648
|
+
* plot(minute(time), "Minute");
|
|
1649
|
+
* ```
|
|
1650
|
+
*/
|
|
1246
1651
|
export declare const minute: CalendarFunction;
|
|
1247
|
-
/**
|
|
1652
|
+
/**
|
|
1653
|
+
* The second of a time, 0 to 59. Works on one time or on a Series of times (`second(time)` gives the value of each bar).
|
|
1654
|
+
* @example
|
|
1655
|
+
* ```js
|
|
1656
|
+
* plot(second(time), "Second");
|
|
1657
|
+
* ```
|
|
1658
|
+
*/
|
|
1248
1659
|
export declare const second: CalendarFunction;
|
|
1249
1660
|
/**
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1661
|
+
* The UNIX time (milliseconds) of a date written as text.
|
|
1662
|
+
* @param dateString - A date such as "2024-03-15", "2024-03-15T09:30" or "15 Mar 2024 09:30 GMT+1"; without a time
|
|
1663
|
+
* zone it is UTC.
|
|
1664
|
+
* @returns The time in UNIX milliseconds.
|
|
1665
|
+
* @example
|
|
1666
|
+
* ```js
|
|
1667
|
+
* const start = timestamp("2024-01-01");
|
|
1668
|
+
* bgcolor(color.when(time.gte(start), color.new(color.green, 92)));
|
|
1669
|
+
* ```
|
|
1252
1670
|
*/
|
|
1253
1671
|
export declare function timestamp(dateString: string): number;
|
|
1672
|
+
/**
|
|
1673
|
+
* The UNIX time (milliseconds) of a date and time in a time zone.
|
|
1674
|
+
* @param timezone - Time zone: "America/New_York", "UTC+2"...
|
|
1675
|
+
* @param year - Year, e.g. 2024.
|
|
1676
|
+
* @param month - Month, 1 to 12.
|
|
1677
|
+
* @param day - Day of the month, 1 to 31.
|
|
1678
|
+
* @param hour - Hour, 0 to 23. Default: 0.
|
|
1679
|
+
* @param minute - Minute. Default: 0.
|
|
1680
|
+
* @param second - Second. Default: 0.
|
|
1681
|
+
* @returns The time in UNIX milliseconds.
|
|
1682
|
+
* @example
|
|
1683
|
+
* ```js
|
|
1684
|
+
* const open = timestamp("America/New_York", 2024, 3, 15, 9, 30);
|
|
1685
|
+
* ```
|
|
1686
|
+
*/
|
|
1254
1687
|
export declare function timestamp(timezone: string, year: number, month: number, day: number, hour?: number, minute?: number, second?: number): number;
|
|
1688
|
+
/**
|
|
1689
|
+
* The UNIX time (milliseconds) of a date and time in the exchange's time zone.
|
|
1690
|
+
* @param year - Year, e.g. 2024.
|
|
1691
|
+
* @param month - Month, 1 to 12.
|
|
1692
|
+
* @param day - Day of the month, 1 to 31.
|
|
1693
|
+
* @param hour - Hour, 0 to 23. Default: 0.
|
|
1694
|
+
* @param minute - Minute. Default: 0.
|
|
1695
|
+
* @param second - Second. Default: 0.
|
|
1696
|
+
* @returns The time in UNIX milliseconds.
|
|
1697
|
+
* @example
|
|
1698
|
+
* ```js
|
|
1699
|
+
* const from = timestamp(2024, 1, 1);
|
|
1700
|
+
* plotshape(time.eq(from), "Start");
|
|
1701
|
+
* ```
|
|
1702
|
+
*/
|
|
1255
1703
|
export declare function timestamp(year: number, month: number, day: number, hour?: number, minute?: number, second?: number): number;
|
|
1256
|
-
/**
|
|
1704
|
+
/**
|
|
1705
|
+
* Whether a time is inside a session (trading hours).
|
|
1706
|
+
* @param time - A time in UNIX milliseconds, e.g. `c.time` in `eachBar()`.
|
|
1707
|
+
* @param session - Session hours and days: "0930-1600", "0930-1600:23456" (Monday to Friday), "1800-0500" (overnight).
|
|
1708
|
+
* @param timezone - Time zone of the session hours. Default: the exchange's.
|
|
1709
|
+
* @returns true when the time is in the session.
|
|
1710
|
+
* @example
|
|
1711
|
+
* ```js
|
|
1712
|
+
* const regular = eachBar((c) => inSession(c.time, "0930-1600"));
|
|
1713
|
+
* bgcolor(color.when(regular, color.new(color.blue, 92)));
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1257
1716
|
export declare function inSession(time: number, session: string, timezone?: string): boolean;
|
|
1258
|
-
/**
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
trim(str: import("../index.js").simple_string): string;
|
|
1278
|
-
trimLeft(str: import("../index.js").simple_string): string;
|
|
1279
|
-
trimRight(str: import("../index.js").simple_string): string;
|
|
1280
|
-
match(source: import("../index.js").simple_string, regex: import("../index.js").simple_string): import("../index.js").simple_string | null;
|
|
1281
|
-
repeat(source: import("../index.js").simple_string, count: import("../index.js").simple_int, separator?: import("../index.js").simple_string): string | null;
|
|
1282
|
-
};
|
|
1717
|
+
/**
|
|
1718
|
+
* Text functions: `str.tostring` (a number as text), `str.format` (a pattern with values), `str.format_time` (a date),
|
|
1719
|
+
* search, replace, split, case... `str.format_time` and the dates of `str.format` use the exchange's time zone by
|
|
1720
|
+
* default.
|
|
1721
|
+
* @example
|
|
1722
|
+
* ```js
|
|
1723
|
+
* eachBar((c) => {
|
|
1724
|
+
* if (barstate.islast) log.info(str.format("Close {0} at {1}", c.get(close), str.format_time(c.get(time), "HH:mm")));
|
|
1725
|
+
* });
|
|
1726
|
+
* ```
|
|
1727
|
+
*/
|
|
1728
|
+
export declare const str: typeof strCore;
|
|
1729
|
+
/**
|
|
1730
|
+
* The open time of the period of `tf` that holds each bar, in UNIX milliseconds; na on bars outside `session`.
|
|
1731
|
+
* @param tf - Timeframe of the periods: "D", "W", "60"... Default: the chart's.
|
|
1732
|
+
* @param session - Session hours, e.g. "0930-1600"; bars outside it give na. Default: the symbol's.
|
|
1733
|
+
* @param timezone - Time zone of the session hours. Default: the exchange's.
|
|
1734
|
+
* @returns Series of period open times.
|
|
1735
|
+
*/
|
|
1283
1736
|
declare function timeFunction(tf?: string, session?: string, timezone?: string): Series;
|
|
1737
|
+
/**
|
|
1738
|
+
* The close time of the period of `tf` that holds each bar, in UNIX milliseconds; na on bars outside `session`.
|
|
1739
|
+
* @param tf - Timeframe of the periods: "D", "W", "60"... Default: the chart's.
|
|
1740
|
+
* @param session - Session hours, e.g. "0930-1600"; bars outside it give na. Default: the symbol's.
|
|
1741
|
+
* @param timezone - Time zone of the session hours. Default: the exchange's.
|
|
1742
|
+
* @returns Series of period close times.
|
|
1743
|
+
*/
|
|
1284
1744
|
declare function timeCloseFunction(tf?: string, session?: string, timezone?: string): Series;
|
|
1285
1745
|
/** PineScript `timenow`: the current time in ms, the same on every bar of a run (`ChartContext.now`). */
|
|
1286
1746
|
export declare const timenow: Series;
|
|
1747
|
+
/**
|
|
1748
|
+
* The open time of each bar, in UNIX milliseconds (a Series). Called as `time(tf?, session?, timezone?)`: the open
|
|
1749
|
+
* time of the `tf` period that holds the bar, na outside `session`.
|
|
1750
|
+
* @example
|
|
1751
|
+
* ```js
|
|
1752
|
+
* const newDay = time("D").neq(time("D").offset(1));
|
|
1753
|
+
* bgcolor(color.when(newDay, color.new(color.gray, 85)));
|
|
1754
|
+
* ```
|
|
1755
|
+
*/
|
|
1287
1756
|
export declare const time: Series & typeof timeFunction;
|
|
1288
1757
|
/**
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
1758
|
+
* The close time of each bar, in UNIX milliseconds (a Series). Called as `time_close(tf?, session?, timezone?)`: the
|
|
1759
|
+
* close time of the `tf` period that holds the bar, na outside `session`.
|
|
1760
|
+
* @example
|
|
1761
|
+
* ```js
|
|
1762
|
+
* plot(time_close.sub(time).div(60000), "Bar minutes");
|
|
1763
|
+
* ```
|
|
1291
1764
|
*/
|
|
1292
1765
|
export declare const time_close: Series & typeof timeCloseFunction;
|
|
1293
1766
|
/** PineScript `time_tradingday`: 00:00 UTC of the trading day of each bar, in ms. */
|
|
@@ -1299,42 +1772,16 @@ export declare const time_tradingday: Series;
|
|
|
1299
1772
|
* it is a history bar, as in PineScript.
|
|
1300
1773
|
* `islastconfirmedhistory` is the last bar when it is confirmed and not realtime, else the bar before it.
|
|
1301
1774
|
*/
|
|
1302
|
-
export declare const barstate:
|
|
1303
|
-
readonly isfirst: Series;
|
|
1304
|
-
readonly islast: Series;
|
|
1305
|
-
readonly isconfirmed: Series;
|
|
1306
|
-
readonly isrealtime: Series;
|
|
1307
|
-
readonly ishistory: Series;
|
|
1308
|
-
readonly isnew: Series;
|
|
1309
|
-
readonly islastconfirmedhistory: Series;
|
|
1310
|
-
};
|
|
1775
|
+
export declare const barstate: BarstateNamespace;
|
|
1311
1776
|
/**
|
|
1312
1777
|
* PineScript `session.*` (1 / 0 per bar) and the constants `session.regular` / `session.extended`.
|
|
1313
1778
|
* First and last bars are per session period; market / pre / post market use the regular hours.
|
|
1314
1779
|
*/
|
|
1315
|
-
export declare const session:
|
|
1316
|
-
regular: string;
|
|
1317
|
-
extended: string;
|
|
1318
|
-
readonly isfirstbar: Series;
|
|
1319
|
-
readonly islastbar: Series;
|
|
1320
|
-
readonly ismarket: Series;
|
|
1321
|
-
readonly ispremarket: Series;
|
|
1322
|
-
readonly ispostmarket: Series;
|
|
1323
|
-
readonly isfirstbar_regular: Series;
|
|
1324
|
-
readonly islastbar_regular: Series;
|
|
1325
|
-
};
|
|
1780
|
+
export declare const session: SessionNamespace;
|
|
1326
1781
|
/** PineScript `barmerge.*` constants of `request.security`. */
|
|
1327
|
-
export declare const barmerge:
|
|
1328
|
-
readonly gaps_on: "gaps_on";
|
|
1329
|
-
readonly gaps_off: "gaps_off";
|
|
1330
|
-
readonly lookahead_on: "lookahead_on";
|
|
1331
|
-
readonly lookahead_off: "lookahead_off";
|
|
1332
|
-
};
|
|
1782
|
+
export declare const barmerge: BarmergeNamespace;
|
|
1333
1783
|
/** PineScript `ticker.heikinashi(symbol)` / `ticker.standard(symbol)` for the chart symbol. */
|
|
1334
|
-
export declare const ticker:
|
|
1335
|
-
heikinashi(symbol: string): string;
|
|
1336
|
-
standard(symbol: string): string;
|
|
1337
|
-
};
|
|
1784
|
+
export declare const ticker: TickerNamespace;
|
|
1338
1785
|
/** What an expression of `request.security` may return. */
|
|
1339
1786
|
export type SecurityValue = Series | number | boolean | Array<Series | number | boolean>;
|
|
1340
1787
|
/** Named arguments of `request.security` (PineScript names). */
|
|
@@ -1358,18 +1805,6 @@ export interface SecurityLowerTfArgs<T extends SecurityValue = SecurityValue> {
|
|
|
1358
1805
|
ignore_invalid_timeframe?: boolean;
|
|
1359
1806
|
calc_bars_count?: number;
|
|
1360
1807
|
}
|
|
1361
|
-
/** `request.security` with PineScript's named arguments: `request.security(sym, "D", () => close, { lookahead: barmerge.lookahead_on })`. */
|
|
1362
|
-
declare function securityCall<T extends SecurityValue>(...args: [symbol: string, timeframe: string, expression: () => T, gaps?: string, lookahead?: string, ignore_invalid_symbol?: boolean] | [symbol: string, timeframe: string, expression: () => T, args: SecurityArgs<T>] | [args: SecurityArgs<T> & {
|
|
1363
|
-
symbol: string;
|
|
1364
|
-
timeframe: string;
|
|
1365
|
-
expression: () => T;
|
|
1366
|
-
}]): T extends unknown[] ? Series[] : Series;
|
|
1367
|
-
/** `request.security_lower_tf` with PineScript's named arguments. */
|
|
1368
|
-
declare function securityLowerTfCall<T extends SecurityValue>(...args: [symbol: string, timeframe: string, expression: () => T, ignore_invalid_symbol?: boolean] | [symbol: string, timeframe: string, expression: () => T, args: SecurityLowerTfArgs<T>] | [args: SecurityLowerTfArgs<T> & {
|
|
1369
|
-
symbol: string;
|
|
1370
|
-
timeframe: string;
|
|
1371
|
-
expression: () => T;
|
|
1372
|
-
}]): T extends unknown[] ? number[][][] : number[][];
|
|
1373
1808
|
/** Named arguments of `request.seed` (PineScript names). */
|
|
1374
1809
|
export interface SeedArgs<T extends SecurityValue = SecurityValue> {
|
|
1375
1810
|
source?: string;
|
|
@@ -1378,42 +1813,12 @@ export interface SeedArgs<T extends SecurityValue = SecurityValue> {
|
|
|
1378
1813
|
ignore_invalid_symbol?: boolean;
|
|
1379
1814
|
calc_bars_count?: number;
|
|
1380
1815
|
}
|
|
1381
|
-
/** `request.seed` with PineScript's named arguments. */
|
|
1382
|
-
declare function seedCall<T extends SecurityValue>(...args: [source: string, symbol: string, expression: () => T, ignore_invalid_symbol?: boolean] | [source: string, symbol: string, expression: () => T, args: SeedArgs<T>] | [args: SeedArgs<T> & {
|
|
1383
|
-
source: string;
|
|
1384
|
-
symbol: string;
|
|
1385
|
-
expression: () => T;
|
|
1386
|
-
}]): T extends unknown[] ? Series[] : Series;
|
|
1387
1816
|
/** PineScript `dividends.*`: the fields of `request.dividends` and the next announced dividend of the chart symbol. */
|
|
1388
|
-
export declare const dividends:
|
|
1389
|
-
readonly net: "net";
|
|
1390
|
-
readonly gross: "gross";
|
|
1391
|
-
/** Amount of the next dividend (net), na when none is announced */
|
|
1392
|
-
readonly future_amount: number;
|
|
1393
|
-
/** Ex-date of the next dividend (ms) */
|
|
1394
|
-
readonly future_ex_date: number;
|
|
1395
|
-
/** Payment date of the next dividend (ms) */
|
|
1396
|
-
readonly future_pay_date: number;
|
|
1397
|
-
};
|
|
1817
|
+
export declare const dividends: DividendsNamespace;
|
|
1398
1818
|
/** PineScript `splits.*`: the fields of `request.splits`. */
|
|
1399
|
-
export declare const splits:
|
|
1400
|
-
readonly numerator: "numerator";
|
|
1401
|
-
readonly denominator: "denominator";
|
|
1402
|
-
};
|
|
1819
|
+
export declare const splits: SplitsNamespace;
|
|
1403
1820
|
/** PineScript `earnings.*`: the fields of `request.earnings` and the next earnings release of the chart symbol. */
|
|
1404
|
-
export declare const earnings:
|
|
1405
|
-
readonly actual: "actual";
|
|
1406
|
-
readonly estimate: "estimate";
|
|
1407
|
-
readonly standardized: "standardized";
|
|
1408
|
-
/** Estimated earnings per share of the next release */
|
|
1409
|
-
readonly future_eps: number;
|
|
1410
|
-
/** Estimated revenue of the next release */
|
|
1411
|
-
readonly future_revenue: number;
|
|
1412
|
-
/** Time of the next release (ms) */
|
|
1413
|
-
readonly future_time: number;
|
|
1414
|
-
/** End of the fiscal period of the next release (ms) */
|
|
1415
|
-
readonly future_period_end_time: number;
|
|
1416
|
-
};
|
|
1821
|
+
export declare const earnings: EarningsNamespace;
|
|
1417
1822
|
/** Named arguments of `request.dividends` / `request.earnings` (`request.splits` has no `currency`). */
|
|
1418
1823
|
export interface EventRequestArgs {
|
|
1419
1824
|
ticker?: string;
|
|
@@ -1423,34 +1828,17 @@ export interface EventRequestArgs {
|
|
|
1423
1828
|
ignore_invalid_symbol?: boolean;
|
|
1424
1829
|
currency?: string;
|
|
1425
1830
|
}
|
|
1426
|
-
type EventRequestCall = [ticker: string, field?: string, gaps?: string, lookahead?: string, ignore_invalid_symbol?: boolean, currency?: string] | [ticker: string, field: string, args: EventRequestArgs] | [ticker: string, args: EventRequestArgs] | [args: EventRequestArgs & {
|
|
1427
|
-
ticker: string;
|
|
1428
|
-
}];
|
|
1429
|
-
/**
|
|
1430
|
-
* PineScript `request.dividends(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency)`: the dividend per
|
|
1431
|
-
* share (`dividends.net`, default, or `dividends.gross`) as declared, from the bar after its ex-date's day (see
|
|
1432
|
-
* `security/events`). na before the first dividend. The events come from `ChartContext.events`.
|
|
1433
|
-
*/
|
|
1434
|
-
declare function dividendsCall(...args: EventRequestCall): Series;
|
|
1435
1831
|
/**
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
*
|
|
1442
|
-
*
|
|
1443
|
-
*
|
|
1832
|
+
* Data from other symbols, timeframes and sources: `request.security` (another symbol or timeframe),
|
|
1833
|
+
* `request.security_lower_tf` (the lower-timeframe bars inside each bar), `request.seed` (a separately published data series),
|
|
1834
|
+
* dividends, splits and earnings. Call it before any `eachBar()` loop.
|
|
1835
|
+
* @example
|
|
1836
|
+
* ```js
|
|
1837
|
+
* const dailyClose = request.security("", "D", () => close);
|
|
1838
|
+
* plot(dailyClose, "Daily close");
|
|
1839
|
+
* ```
|
|
1444
1840
|
*/
|
|
1445
|
-
declare
|
|
1446
|
-
export declare const request: {
|
|
1447
|
-
security: typeof securityCall;
|
|
1448
|
-
security_lower_tf: typeof securityLowerTfCall;
|
|
1449
|
-
seed: typeof seedCall;
|
|
1450
|
-
dividends: typeof dividendsCall;
|
|
1451
|
-
splits: typeof splitsCall;
|
|
1452
|
-
earnings: typeof earningsCall;
|
|
1453
|
-
};
|
|
1841
|
+
export declare const request: RequestNamespace;
|
|
1454
1842
|
/** PineScript `line.*`; `line.all` lists the live lines in creation order. */
|
|
1455
1843
|
type Numeric = number | Series;
|
|
1456
1844
|
/** A function whose number parameters also take a Series (read on the current bar inside a bar loop). */
|
|
@@ -1565,400 +1953,102 @@ export interface LinefillNewArgs {
|
|
|
1565
1953
|
line2?: Line;
|
|
1566
1954
|
color?: Colour;
|
|
1567
1955
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
style_arrow_right: "arrow_right";
|
|
1574
|
-
style_arrow_both: "arrow_both";
|
|
1575
|
-
new_line(first_point: ChartPoint, second_point: ChartPoint, xloc?: "bar_index" | "bar_time" | "pane", extend?: "none" | "left" | "right" | "both", lineColor?: import("../types/index.js").color, style?: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both", width?: number, force_overlay?: boolean): Line;
|
|
1576
|
-
new_line(x1: number, y1: number, x2: number, y2: number, xloc?: "bar_index" | "bar_time" | "pane", extend?: "none" | "left" | "right" | "both", lineColor?: import("../types/index.js").color, style?: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both", width?: number, force_overlay?: boolean): Line;
|
|
1577
|
-
get_price(id: Line, x: number): number;
|
|
1578
|
-
get_x1(id: Line): number;
|
|
1579
|
-
get_x2(id: Line): number;
|
|
1580
|
-
get_y1(id: Line): number;
|
|
1581
|
-
get_y2(id: Line): number;
|
|
1582
|
-
copy(id: Line): Line;
|
|
1583
|
-
set_x1(id: Line, x: number): Line;
|
|
1584
|
-
set_x2(id: Line, x: number): Line;
|
|
1585
|
-
set_y1(id: Line, y: number): Line;
|
|
1586
|
-
set_y2(id: Line, y: number): Line;
|
|
1587
|
-
set_xy1(id: Line, x: number, y: number): Line;
|
|
1588
|
-
set_xy2(id: Line, x: number, y: number): Line;
|
|
1589
|
-
set_xloc(id: Line, x1: number, x2: number, xloc: "bar_index" | "bar_time" | "pane"): Line;
|
|
1590
|
-
set_extend(id: Line, extend: "none" | "left" | "right" | "both"): Line;
|
|
1591
|
-
set_color(id: Line, lineColor: import("../types/index.js").color): Line;
|
|
1592
|
-
set_style(id: Line, style: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both"): Line;
|
|
1593
|
-
set_width(id: Line, width: number): Line;
|
|
1594
|
-
delete_line(id: Line): void;
|
|
1595
|
-
all(): Line[];
|
|
1596
|
-
set_first_point(id: Line, point: ChartPoint): Line;
|
|
1597
|
-
set_second_point(id: Line, point: ChartPoint): Line;
|
|
1598
|
-
new: typeof lineCore.new_line;
|
|
1599
|
-
delete: typeof lineCore.delete_line;
|
|
1600
|
-
}>, "all"> & {
|
|
1601
|
-
readonly all: Line[];
|
|
1956
|
+
/** Wraps a drawing namespace and keeps its `all` getter (the live drawings in creation order). */
|
|
1957
|
+
/** A drawing namespace of scripts: the members of `T`, and `all`. */
|
|
1958
|
+
type DrawingNamespace<T, D> = Omit<ScriptDrawing<T>, 'all'> & {
|
|
1959
|
+
/** The live drawings of this kind, oldest first (a new array on each read). */
|
|
1960
|
+
readonly all: D[];
|
|
1602
1961
|
};
|
|
1603
|
-
|
|
1962
|
+
declare const lineNs: DrawingNamespace<typeof lineCore & typeof pineConstants.lineStyles, Line>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Lines between two chart points: `line.new()` draws one, `line.set_*` / `line.get_*` move and read it, `line.style_*`
|
|
1965
|
+
* are its styles, `line.all` lists the live lines.
|
|
1966
|
+
*/
|
|
1604
1967
|
export declare const line: typeof lineNs & {
|
|
1605
1968
|
new: ((args: LineNewArgs) => Line) & ((x1: Numeric, y1: Numeric, x2: Numeric, y2: Numeric, args: LineNewArgs) => Line) & ((first_point: ChartPoint, second_point: ChartPoint, args: LineNewArgs) => Line);
|
|
1606
1969
|
};
|
|
1607
|
-
declare const labelNs:
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
style_triangledown: "triangledown";
|
|
1613
|
-
style_flag: "flag";
|
|
1614
|
-
style_circle: "circle";
|
|
1615
|
-
style_arrowup: "arrowup";
|
|
1616
|
-
style_arrowdown: "arrowdown";
|
|
1617
|
-
style_label_up: "label_up";
|
|
1618
|
-
style_label_down: "label_down";
|
|
1619
|
-
style_label_left: "label_left";
|
|
1620
|
-
style_label_right: "label_right";
|
|
1621
|
-
style_label_lower_left: "label_lower_left";
|
|
1622
|
-
style_label_lower_right: "label_lower_right";
|
|
1623
|
-
style_label_upper_left: "label_upper_left";
|
|
1624
|
-
style_label_upper_right: "label_upper_right";
|
|
1625
|
-
style_label_center: "label_center";
|
|
1626
|
-
style_square: "square";
|
|
1627
|
-
style_diamond: "diamond";
|
|
1628
|
-
style_text_outline: "text_outline";
|
|
1629
|
-
new_label(point: ChartPoint, text?: string, xloc?: "bar_index" | "bar_time" | "pane", yloc?: "price" | "abovebar" | "belowbar", labelColor?: import("../types/index.js").color, style?: "none" | "xcross" | "cross" | "triangleup" | "triangledown" | "flag" | "circle" | "arrowup" | "arrowdown" | "label_up" | "label_down" | "label_left" | "label_right" | "label_lower_left" | "label_lower_right" | "label_upper_left" | "label_upper_right" | "label_center" | "square" | "diamond" | "text_outline", textcolor?: import("../types/index.js").color, size?: string | number, textalign?: "left" | "center" | "right", tooltip?: string, text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Label;
|
|
1630
|
-
new_label(x: number, y: number, text?: string, xloc?: "bar_index" | "bar_time" | "pane", yloc?: "price" | "abovebar" | "belowbar", labelColor?: import("../types/index.js").color, style?: "none" | "xcross" | "cross" | "triangleup" | "triangledown" | "flag" | "circle" | "arrowup" | "arrowdown" | "label_up" | "label_down" | "label_left" | "label_right" | "label_lower_left" | "label_lower_right" | "label_upper_left" | "label_upper_right" | "label_center" | "square" | "diamond" | "text_outline", textcolor?: import("../types/index.js").color, size?: string | number, textalign?: "left" | "center" | "right", tooltip?: string, text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Label;
|
|
1631
|
-
get_x(id: Label): number;
|
|
1632
|
-
get_y(id: Label): number;
|
|
1633
|
-
get_text(id: Label): string | undefined;
|
|
1634
|
-
copy(id: Label): Label;
|
|
1635
|
-
set_x(id: Label, x: number): Label;
|
|
1636
|
-
set_y(id: Label, y: number): Label;
|
|
1637
|
-
set_xy(id: Label, x: number, y: number): Label;
|
|
1638
|
-
set_xloc(id: Label, x: number, xloc: "bar_index" | "bar_time" | "pane"): Label;
|
|
1639
|
-
set_yloc(id: Label, yloc: "price" | "abovebar" | "belowbar"): Label;
|
|
1640
|
-
set_text(id: Label, text: string): Label;
|
|
1641
|
-
set_tooltip(id: Label, tooltip: string): Label;
|
|
1642
|
-
set_color(id: Label, labelColor: import("../types/index.js").color): Label;
|
|
1643
|
-
set_textcolor(id: Label, textColor: import("../types/index.js").color): Label;
|
|
1644
|
-
set_style(id: Label, style: "none" | "xcross" | "cross" | "triangleup" | "triangledown" | "flag" | "circle" | "arrowup" | "arrowdown" | "label_up" | "label_down" | "label_left" | "label_right" | "label_lower_left" | "label_lower_right" | "label_upper_left" | "label_upper_right" | "label_center" | "square" | "diamond" | "text_outline"): Label;
|
|
1645
|
-
set_size(id: Label, size: string | number): Label;
|
|
1646
|
-
set_textalign(id: Label, align: "left" | "center" | "right"): Label;
|
|
1647
|
-
set_text_font_family(id: Label, font: "default" | "monospace"): Label;
|
|
1648
|
-
delete_label(id: Label): void;
|
|
1649
|
-
all(): Label[];
|
|
1650
|
-
set_point(id: Label, point: ChartPoint): Label;
|
|
1651
|
-
set_text_formatting(id: Label, formatting: number): Label;
|
|
1652
|
-
new: typeof labelCore.new_label;
|
|
1653
|
-
delete: typeof labelCore.delete_label;
|
|
1654
|
-
}>, "all"> & {
|
|
1655
|
-
readonly all: Label[];
|
|
1656
|
-
};
|
|
1657
|
-
/** PineScript `label.*` (with `label.style_*`); `label.all` lists the live labels in creation order. */
|
|
1970
|
+
declare const labelNs: DrawingNamespace<typeof labelCore & typeof pineConstants.labelStyles, Label>;
|
|
1971
|
+
/**
|
|
1972
|
+
* Text boxes and shapes at a chart point: `label.new()` draws one, `label.set_*` / `label.get_*` change and read it,
|
|
1973
|
+
* `label.style_*` are its styles, `label.all` lists the live labels.
|
|
1974
|
+
*/
|
|
1658
1975
|
export declare const label: typeof labelNs & {
|
|
1659
1976
|
new: ((args: LabelNewArgs) => Label) & ((x: Numeric, y: Numeric, args: LabelNewArgs) => Label) & ((x: Numeric, y: Numeric, text: string, args: LabelNewArgs) => Label) & ((point: ChartPoint, args: LabelNewArgs) => Label) & ((point: ChartPoint, text: string, args: LabelNewArgs) => Label);
|
|
1660
1977
|
};
|
|
1661
|
-
declare const boxNs:
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
get_top(id: Box): number;
|
|
1667
|
-
get_bottom(id: Box): number;
|
|
1668
|
-
copy(id: Box): Box;
|
|
1669
|
-
set_left(id: Box, left: number): Box;
|
|
1670
|
-
set_right(id: Box, right: number): Box;
|
|
1671
|
-
set_top(id: Box, top: number): Box;
|
|
1672
|
-
set_bottom(id: Box, bottom: number): Box;
|
|
1673
|
-
set_lefttop(id: Box, left: number, top: number): Box;
|
|
1674
|
-
set_rightbottom(id: Box, right: number, bottom: number): Box;
|
|
1675
|
-
set_xloc(id: Box, left: number, right: number, xloc: "bar_index" | "bar_time" | "pane"): Box;
|
|
1676
|
-
set_extend(id: Box, extend: "none" | "left" | "right" | "both"): Box;
|
|
1677
|
-
set_border_color(id: Box, borderColor: import("../types/index.js").color): Box;
|
|
1678
|
-
set_border_width(id: Box, width: number): Box;
|
|
1679
|
-
set_border_style(id: Box, style: "solid" | "dotted" | "dashed"): Box;
|
|
1680
|
-
set_bgcolor(id: Box, bgColor: import("../types/index.js").color): Box;
|
|
1681
|
-
set_text(id: Box, text: string): Box;
|
|
1682
|
-
set_text_color(id: Box, textColor: import("../types/index.js").color): Box;
|
|
1683
|
-
set_text_size(id: Box, size: string | number): Box;
|
|
1684
|
-
set_text_halign(id: Box, align: "left" | "center" | "right"): Box;
|
|
1685
|
-
set_text_valign(id: Box, align: "top" | "center" | "bottom"): Box;
|
|
1686
|
-
set_text_wrap(id: Box, wrap: "none" | "auto"): Box;
|
|
1687
|
-
set_text_font_family(id: Box, font: "default" | "monospace"): Box;
|
|
1688
|
-
delete_box(id: Box): void;
|
|
1689
|
-
all(): Box[];
|
|
1690
|
-
set_top_left_point(id: Box, point: ChartPoint): Box;
|
|
1691
|
-
set_bottom_right_point(id: Box, point: ChartPoint): Box;
|
|
1692
|
-
set_text_formatting(id: Box, formatting: number): Box;
|
|
1693
|
-
new: typeof boxCore.new_box;
|
|
1694
|
-
delete: typeof boxCore.delete_box;
|
|
1695
|
-
}>, "all"> & {
|
|
1696
|
-
readonly all: Box[];
|
|
1697
|
-
};
|
|
1698
|
-
/** PineScript `box.*`; `box.all` lists the live boxes in creation order. */
|
|
1978
|
+
declare const boxNs: DrawingNamespace<typeof boxCore, Box>;
|
|
1979
|
+
/**
|
|
1980
|
+
* Rectangles between two x coordinates and two prices, with optional text: `box.new()` draws one, `box.set_*` /
|
|
1981
|
+
* `box.get_*` change and read it, `box.all` lists the live boxes.
|
|
1982
|
+
*/
|
|
1699
1983
|
export declare const box: typeof boxNs & {
|
|
1700
1984
|
new: ((args: BoxNewArgs) => Box) & ((left: Numeric, top: Numeric, right: Numeric, bottom: Numeric, args: BoxNewArgs) => Box) & ((top_left: ChartPoint, bottom_right: ChartPoint, args: BoxNewArgs) => Box);
|
|
1701
1985
|
};
|
|
1702
|
-
declare const linefillNs:
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
delete_linefill(id: Linefill): void;
|
|
1708
|
-
all(): Linefill[];
|
|
1709
|
-
new: typeof linefillCore.new_linefill;
|
|
1710
|
-
delete: typeof linefillCore.delete_linefill;
|
|
1711
|
-
}>, "all"> & {
|
|
1712
|
-
readonly all: Linefill[];
|
|
1713
|
-
};
|
|
1714
|
-
/** PineScript `linefill.*`; `linefill.all` lists the live linefills in creation order. */
|
|
1986
|
+
declare const linefillNs: DrawingNamespace<typeof linefillCore, Linefill>;
|
|
1987
|
+
/**
|
|
1988
|
+
* Colour fills between two lines that follow the lines when they move: `linefill.new()`, `linefill.set_color()`,
|
|
1989
|
+
* `linefill.all`.
|
|
1990
|
+
*/
|
|
1715
1991
|
export declare const linefill: typeof linefillNs & {
|
|
1716
1992
|
new: ((args: LinefillNewArgs) => Linefill) & ((line1: Line, line2: Line, args: LinefillNewArgs) => Linefill);
|
|
1717
1993
|
};
|
|
1718
|
-
declare const polylineNs:
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
clear_all(): void;
|
|
1724
|
-
reset_id_counter(): void;
|
|
1725
|
-
new: typeof polylineCore.new_polyline;
|
|
1726
|
-
delete: typeof polylineCore.delete_polyline;
|
|
1727
|
-
}>, "all"> & {
|
|
1728
|
-
readonly all: polylineCore.Polyline[];
|
|
1729
|
-
};
|
|
1730
|
-
/** PineScript `polyline.*`; `polyline.all` lists the live polylines in creation order. */
|
|
1994
|
+
declare const polylineNs: DrawingNamespace<typeof polylineCore, Polyline>;
|
|
1995
|
+
/**
|
|
1996
|
+
* Shapes through many chart points, straight or curved, open or closed and filled: `polyline.new()`,
|
|
1997
|
+
* `polyline.delete()`, `polyline.all`.
|
|
1998
|
+
*/
|
|
1731
1999
|
export declare const polyline: typeof polylineNs & {
|
|
1732
2000
|
new: ((args: PolylineNewArgs) => Polyline) & ((points: ChartPoint[], args: PolylineNewArgs) => Polyline);
|
|
1733
2001
|
};
|
|
1734
|
-
declare const tableNs: Omit<ScriptDrawing<{
|
|
1735
|
-
new_table(position: "top_left" | "top_center" | "top_right" | "middle_left" | "middle_center" | "middle_right" | "bottom_left" | "bottom_center" | "bottom_right", columns: number, rows: number, bgcolor?: import("../types/index.js").color, frame_color?: import("../types/index.js").color, frame_width?: number, border_color?: import("../types/index.js").color, border_width?: number, force_overlay?: boolean): Table;
|
|
1736
|
-
cell(table_id: Table, column: number, row: number, text?: string, width?: number, height?: number, text_color?: import("../types/index.js").color, text_halign?: "left" | "right" | "center", text_valign?: "center" | "top" | "bottom", text_size?: string | number, bgcolor?: import("../types/index.js").color, tooltip?: string, text_font_family?: "default" | "monospace", text_formatting?: number): void;
|
|
1737
|
-
merge_cells(table_id: Table, start_column: number, start_row: number, end_column: number, end_row: number): void;
|
|
1738
|
-
clear(table_id: Table, start_column: number, start_row: number, end_column?: number, end_row?: number): void;
|
|
1739
|
-
set_position(table_id: Table, position: "top_left" | "top_center" | "top_right" | "middle_left" | "middle_center" | "middle_right" | "bottom_left" | "bottom_center" | "bottom_right"): void;
|
|
1740
|
-
delete_table(table_id: Table): void;
|
|
1741
|
-
all(): Table[];
|
|
1742
|
-
cell_set_text: (table_id: Table, column: number, row: number, value: string | undefined) => void;
|
|
1743
|
-
cell_set_width: (table_id: Table, column: number, row: number, value: number | undefined) => void;
|
|
1744
|
-
cell_set_height: (table_id: Table, column: number, row: number, value: number | undefined) => void;
|
|
1745
|
-
cell_set_text_color: (table_id: Table, column: number, row: number, value: import("../types/index.js").color | undefined) => void;
|
|
1746
|
-
cell_set_text_halign: (table_id: Table, column: number, row: number, value: "left" | "right" | "center" | undefined) => void;
|
|
1747
|
-
cell_set_text_valign: (table_id: Table, column: number, row: number, value: "center" | "top" | "bottom" | undefined) => void;
|
|
1748
|
-
cell_set_text_size: (table_id: Table, column: number, row: number, value: string | number | undefined) => void;
|
|
1749
|
-
cell_set_bgcolor: (table_id: Table, column: number, row: number, value: import("../types/index.js").color | undefined) => void;
|
|
1750
|
-
cell_set_tooltip: (table_id: Table, column: number, row: number, value: string | undefined) => void;
|
|
1751
|
-
cell_set_text_font_family: (table_id: Table, column: number, row: number, value: "default" | "monospace" | undefined) => void;
|
|
1752
|
-
cell_set_text_formatting: (table_id: Table, column: number, row: number, value: number | undefined) => void;
|
|
1753
|
-
set_bgcolor: (table_id: Table, value: import("../types/index.js").color | undefined) => void;
|
|
1754
|
-
set_frame_color: (table_id: Table, value: import("../types/index.js").color | undefined) => void;
|
|
1755
|
-
set_frame_width: (table_id: Table, value: number | undefined) => void;
|
|
1756
|
-
set_border_color: (table_id: Table, value: import("../types/index.js").color | undefined) => void;
|
|
1757
|
-
set_border_width: (table_id: Table, value: number | undefined) => void;
|
|
1758
|
-
new: typeof tableCore.new_table;
|
|
1759
|
-
delete: typeof tableCore.delete_table;
|
|
1760
|
-
}>, "all"> & {
|
|
1761
|
-
readonly all: Table[];
|
|
1762
|
-
};
|
|
1763
2002
|
/**
|
|
1764
|
-
*
|
|
2003
|
+
* Tables fixed at a place of the pane, for values and dashboards: `table.new()` creates one, `table.cell()` fills it,
|
|
2004
|
+
* `table.all` lists the live tables. The live tables go to `result.tables`.
|
|
1765
2005
|
*/
|
|
1766
|
-
export declare const table:
|
|
1767
|
-
new: ((args: TableNewArgs) => Table) & ((position: string, columns: number, rows: number, args: TableNewArgs) => Table);
|
|
1768
|
-
cell: ((args: TableCellArgs) => void) & ((table_id: Table, column: number, row: number, args: TableCellArgs) => void) & ((table_id: Table, column: number, row: number, text: string, args: TableCellArgs) => void);
|
|
1769
|
-
};
|
|
2006
|
+
export declare const table: TableNamespace;
|
|
1770
2007
|
/** PineScript `position.*` constants (table positions). */
|
|
1771
2008
|
export { position };
|
|
1772
|
-
/**
|
|
1773
|
-
export declare const text:
|
|
1774
|
-
|
|
1775
|
-
format_bold: 1;
|
|
1776
|
-
format_italic: 2;
|
|
1777
|
-
align_left: "left";
|
|
1778
|
-
align_center: "center";
|
|
1779
|
-
align_right: "right";
|
|
1780
|
-
align_top: "top";
|
|
1781
|
-
align_bottom: "bottom";
|
|
1782
|
-
wrap_auto: "auto";
|
|
1783
|
-
wrap_none: "none";
|
|
1784
|
-
};
|
|
1785
|
-
/** PineScript constant namespaces (`shape.triangleup`, `size.small`, `xloc.bar_time`, `extend.right`...): the strings
|
|
1786
|
-
* the functions take. */
|
|
1787
|
-
export declare const shape: {
|
|
1788
|
-
readonly xcross: "xcross";
|
|
1789
|
-
readonly cross: "cross";
|
|
1790
|
-
readonly triangleup: "triangleup";
|
|
1791
|
-
readonly triangledown: "triangledown";
|
|
1792
|
-
readonly flag: "flag";
|
|
1793
|
-
readonly circle: "circle";
|
|
1794
|
-
readonly arrowup: "arrowup";
|
|
1795
|
-
readonly arrowdown: "arrowdown";
|
|
1796
|
-
readonly labelup: "labelup";
|
|
1797
|
-
readonly labeldown: "labeldown";
|
|
1798
|
-
readonly square: "square";
|
|
1799
|
-
readonly diamond: "diamond";
|
|
1800
|
-
}, location: {
|
|
1801
|
-
readonly abovebar: "abovebar";
|
|
1802
|
-
readonly belowbar: "belowbar";
|
|
1803
|
-
readonly top: "top";
|
|
1804
|
-
readonly bottom: "bottom";
|
|
1805
|
-
readonly absolute: "absolute";
|
|
1806
|
-
}, size: {
|
|
1807
|
-
readonly auto: "auto";
|
|
1808
|
-
readonly tiny: "tiny";
|
|
1809
|
-
readonly small: "small";
|
|
1810
|
-
readonly normal: "normal";
|
|
1811
|
-
readonly large: "large";
|
|
1812
|
-
readonly huge: "huge";
|
|
1813
|
-
}, xloc: {
|
|
1814
|
-
readonly bar_index: "bar_index";
|
|
1815
|
-
readonly bar_time: "bar_time";
|
|
1816
|
-
readonly pane: "pane";
|
|
1817
|
-
}, yloc: {
|
|
1818
|
-
readonly price: "price";
|
|
1819
|
-
readonly abovebar: "abovebar";
|
|
1820
|
-
readonly belowbar: "belowbar";
|
|
1821
|
-
}, extend: {
|
|
1822
|
-
readonly none: "none";
|
|
1823
|
-
readonly left: "left";
|
|
1824
|
-
readonly right: "right";
|
|
1825
|
-
readonly both: "both";
|
|
1826
|
-
}, display: {
|
|
1827
|
-
readonly none: "none";
|
|
1828
|
-
readonly all: "all";
|
|
1829
|
-
readonly data_window: "data_window";
|
|
1830
|
-
readonly status_line: "status_line";
|
|
1831
|
-
readonly pane: "pane";
|
|
1832
|
-
}, format: {
|
|
1833
|
-
readonly inherit: "inherit";
|
|
1834
|
-
readonly price: "price";
|
|
1835
|
-
readonly volume: "volume";
|
|
1836
|
-
readonly percent: "percent";
|
|
1837
|
-
readonly mintick: "mintick";
|
|
1838
|
-
}, font: {
|
|
1839
|
-
readonly family_default: "default";
|
|
1840
|
-
readonly family_monospace: "monospace";
|
|
1841
|
-
}, scale: {
|
|
1842
|
-
readonly right: "right";
|
|
1843
|
-
readonly left: "left";
|
|
1844
|
-
readonly none: "none";
|
|
1845
|
-
}, order: {
|
|
1846
|
-
readonly ascending: "ascending";
|
|
1847
|
-
readonly descending: "descending";
|
|
1848
|
-
}, currency: {
|
|
1849
|
-
readonly NONE: "NONE";
|
|
1850
|
-
readonly AED: "AED";
|
|
1851
|
-
readonly ARS: "ARS";
|
|
1852
|
-
readonly AUD: "AUD";
|
|
1853
|
-
readonly BDT: "BDT";
|
|
1854
|
-
readonly BHD: "BHD";
|
|
1855
|
-
readonly BRL: "BRL";
|
|
1856
|
-
readonly BTC: "BTC";
|
|
1857
|
-
readonly CAD: "CAD";
|
|
1858
|
-
readonly CHF: "CHF";
|
|
1859
|
-
readonly CLP: "CLP";
|
|
1860
|
-
readonly CNY: "CNY";
|
|
1861
|
-
readonly COP: "COP";
|
|
1862
|
-
readonly CZK: "CZK";
|
|
1863
|
-
readonly DKK: "DKK";
|
|
1864
|
-
readonly EGP: "EGP";
|
|
1865
|
-
readonly ETH: "ETH";
|
|
1866
|
-
readonly EUR: "EUR";
|
|
1867
|
-
readonly GBP: "GBP";
|
|
1868
|
-
readonly GEL: "GEL";
|
|
1869
|
-
readonly HKD: "HKD";
|
|
1870
|
-
readonly HUF: "HUF";
|
|
1871
|
-
readonly IDR: "IDR";
|
|
1872
|
-
readonly ILS: "ILS";
|
|
1873
|
-
readonly INR: "INR";
|
|
1874
|
-
readonly ISK: "ISK";
|
|
1875
|
-
readonly JPY: "JPY";
|
|
1876
|
-
readonly KES: "KES";
|
|
1877
|
-
readonly KRW: "KRW";
|
|
1878
|
-
readonly KWD: "KWD";
|
|
1879
|
-
readonly LKR: "LKR";
|
|
1880
|
-
readonly MAD: "MAD";
|
|
1881
|
-
readonly MXN: "MXN";
|
|
1882
|
-
readonly MYR: "MYR";
|
|
1883
|
-
readonly NGN: "NGN";
|
|
1884
|
-
readonly NOK: "NOK";
|
|
1885
|
-
readonly NZD: "NZD";
|
|
1886
|
-
readonly PEN: "PEN";
|
|
1887
|
-
readonly PHP: "PHP";
|
|
1888
|
-
readonly PKR: "PKR";
|
|
1889
|
-
readonly PLN: "PLN";
|
|
1890
|
-
readonly QAR: "QAR";
|
|
1891
|
-
readonly RON: "RON";
|
|
1892
|
-
readonly RSD: "RSD";
|
|
1893
|
-
readonly RUB: "RUB";
|
|
1894
|
-
readonly SAR: "SAR";
|
|
1895
|
-
readonly SEK: "SEK";
|
|
1896
|
-
readonly SGD: "SGD";
|
|
1897
|
-
readonly THB: "THB";
|
|
1898
|
-
readonly TND: "TND";
|
|
1899
|
-
readonly TRY: "TRY";
|
|
1900
|
-
readonly TWD: "TWD";
|
|
1901
|
-
readonly USD: "USD";
|
|
1902
|
-
readonly USDT: "USDT";
|
|
1903
|
-
readonly VES: "VES";
|
|
1904
|
-
readonly VND: "VND";
|
|
1905
|
-
readonly ZAR: "ZAR";
|
|
1906
|
-
}, adjustment: {
|
|
1907
|
-
readonly none: "none";
|
|
1908
|
-
readonly splits: "splits";
|
|
1909
|
-
readonly dividends: "dividends";
|
|
1910
|
-
};
|
|
2009
|
+
/** Text constants: `text.format_*` (bold, italic), `text.align_*` (alignment) and `text.wrap_*` (wrapping). */
|
|
2010
|
+
export declare const text: typeof textCore;
|
|
2011
|
+
export { shape, location, size, xloc, yloc, extend, display, format, font, scale, order, currency, adjustment } from './constants.js';
|
|
1911
2012
|
/**
|
|
1912
2013
|
* PineScript `chart.point.*`. `chart.point.now(price?)` is the point of the current bar
|
|
1913
2014
|
* (index, time, and `price`, default the close), so it runs inside eachBar().
|
|
1914
2015
|
*/
|
|
1915
|
-
export declare const chart:
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
readonly is_standard: boolean;
|
|
1928
|
-
readonly is_heikinashi: boolean;
|
|
1929
|
-
readonly is_renko: boolean;
|
|
1930
|
-
readonly is_kagi: boolean;
|
|
1931
|
-
readonly is_linebreak: boolean;
|
|
1932
|
-
readonly is_pnf: boolean;
|
|
1933
|
-
readonly is_range: boolean;
|
|
1934
|
-
point: {
|
|
1935
|
-
now(price?: number): ChartPoint;
|
|
1936
|
-
new_point(time: number | null, index: number | null, price: number): ChartPoint;
|
|
1937
|
-
from_time(time: number, price: number): ChartPoint;
|
|
1938
|
-
from_index(index: number, price: number): ChartPoint;
|
|
1939
|
-
copy(point: ChartPoint): ChartPoint;
|
|
1940
|
-
new: typeof chartPointCore.new_point;
|
|
1941
|
-
};
|
|
1942
|
-
};
|
|
1943
|
-
/** Wraps a plain value array (e.g. a side output accumulated inside eachBar)
|
|
1944
|
-
* into a Series aligned with the current bars. */
|
|
2016
|
+
export declare const chart: ChartNamespace;
|
|
2017
|
+
/**
|
|
2018
|
+
* Makes a Series from an array of numbers, one per bar (oldest first), e.g. values collected inside `eachBar()`.
|
|
2019
|
+
* @param values - One value per bar; NaN is na.
|
|
2020
|
+
* @returns Series of the values.
|
|
2021
|
+
* @example
|
|
2022
|
+
* ```js
|
|
2023
|
+
* const ranges = [];
|
|
2024
|
+
* eachBar((c) => { ranges.push(c.high - c.low); });
|
|
2025
|
+
* plot(seriesOf(ranges), "Range");
|
|
2026
|
+
* ```
|
|
2027
|
+
*/
|
|
1945
2028
|
export declare function seriesOf(values: number[]): Series;
|
|
1946
|
-
/**
|
|
2029
|
+
/**
|
|
2030
|
+
* Declares a condition users can create an alert on (in the app's alert dialog). It does not send an alert itself.
|
|
2031
|
+
* @param condition - Series that is true (non-zero) on the bars where the alert fires.
|
|
2032
|
+
* @param title - Name of the condition in the alert dialog.
|
|
2033
|
+
* @param message - Default text of the alert. Default: the title.
|
|
2034
|
+
* @example
|
|
2035
|
+
* ```js
|
|
2036
|
+
* const cross = ta.crossover(close, ta.sma(close, 50));
|
|
2037
|
+
* alertcondition(cross, "Price above SMA 50", "Close crossed above its 50-bar average");
|
|
2038
|
+
* ```
|
|
2039
|
+
*/
|
|
1947
2040
|
export declare function alertcondition(condition: Series, title: string, message?: string): void;
|
|
1948
2041
|
/**
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1953
|
-
* (
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
readonly freq_once_per_bar: "once_per_bar";
|
|
1960
|
-
readonly freq_once_per_bar_close: "once_per_bar_close";
|
|
1961
|
-
};
|
|
2042
|
+
* Sends an alert message while the script runs (to the alerts set on the script), with the `alert.freq_*`
|
|
2043
|
+
* constants for how often it may fire.
|
|
2044
|
+
* @example
|
|
2045
|
+
* ```js
|
|
2046
|
+
* eachBar((c) => {
|
|
2047
|
+
* if (c.get(close) > c.get(high, 1)) alert("New high", alert.freq_once_per_bar_close);
|
|
2048
|
+
* });
|
|
2049
|
+
* ```
|
|
2050
|
+
*/
|
|
2051
|
+
export declare const alert: AlertApi;
|
|
1962
2052
|
/** The level of a log message. */
|
|
1963
2053
|
export type LogLevel = 'info' | 'warning' | 'error';
|
|
1964
2054
|
/** One log.*() message: the bar it was made on (index, and time as given in the input bars), its level and text, and
|
|
@@ -1973,80 +2063,49 @@ export interface LogEntry {
|
|
|
1973
2063
|
/** The most messages a run keeps: the newest ones. */
|
|
1974
2064
|
export declare const MAX_LOG_ENTRIES = 10000;
|
|
1975
2065
|
/**
|
|
1976
|
-
*
|
|
1977
|
-
* `stack`) and gives the line in the script's own source
|
|
2066
|
+
* Host-side: how the host finds the line of the script that called log.*(). Scripts never call it.
|
|
2067
|
+
* @param resolver - Gets the stack of the call (an Error's `stack`) and gives the line in the script's own source;
|
|
2068
|
+
* null (the default): messages have no line.
|
|
1978
2069
|
*/
|
|
1979
2070
|
export declare function setLogLineResolver(resolver: ((stack: string) => number | undefined) | null): void;
|
|
1980
2071
|
/**
|
|
1981
|
-
*
|
|
1982
|
-
* bar
|
|
1983
|
-
*
|
|
1984
|
-
*
|
|
1985
|
-
*
|
|
2072
|
+
* Messages for the logs panel: `log.info`, `log.warning` and `log.error`. Inside `eachBar()` a call makes a message on
|
|
2073
|
+
* the current bar; at the top level, one message per bar. With arguments the message is a `str.format()` pattern.
|
|
2074
|
+
* @example
|
|
2075
|
+
* ```js
|
|
2076
|
+
* eachBar((c) => {
|
|
2077
|
+
* if (c.get(volume) > 2 * c.get(ta.sma(volume, 20))) log.info("Volume spike: {0}", c.get(volume));
|
|
2078
|
+
* });
|
|
2079
|
+
* ```
|
|
1986
2080
|
*/
|
|
1987
|
-
export declare const log:
|
|
1988
|
-
info(message: string | ReadonlyArray<string | undefined>, ...args: unknown[]): void;
|
|
1989
|
-
warning(message: string | ReadonlyArray<string | undefined>, ...args: unknown[]): void;
|
|
1990
|
-
error(message: string | ReadonlyArray<string | undefined>, ...args: unknown[]): void;
|
|
1991
|
-
};
|
|
2081
|
+
export declare const log: LogNamespace;
|
|
1992
2082
|
export { Series, BarData };
|
|
1993
2083
|
export { STRATEGY_DEFAULTS } from '../strategy/index.js';
|
|
1994
2084
|
export type { StrategyCloseAllOptions, StrategyCloseOptions, StrategyCommissionType, StrategyDirection, StrategyEngine, StrategyEntryOptions, StrategyExitOptions, StrategyNumberVariable, StrategyOcaType, StrategyOptions, StrategyProperties, StrategyQtyType, StrategyRiskDirection, StrategyRiskRule, StrategyRiskValueType, StrategyTextVariable, StrategyTrade, StrategyVariable, } from '../strategy/index.js';
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
pow(base: Series, exponent: Series): Series;
|
|
2017
|
-
pow(base: import("../index.js").float, exponent: import("../index.js").float): import("../index.js").float;
|
|
2018
|
-
exp(value: Series): Series;
|
|
2019
|
-
exp(value: import("../index.js").float): import("../index.js").float;
|
|
2020
|
-
log(value: Series): Series;
|
|
2021
|
-
log(value: import("../index.js").float): import("../index.js").float;
|
|
2022
|
-
log10(value: Series): Series;
|
|
2023
|
-
log10(value: import("../index.js").float): import("../index.js").float;
|
|
2024
|
-
sin(value: Series): Series;
|
|
2025
|
-
sin(value: import("../index.js").float): import("../index.js").float;
|
|
2026
|
-
cos(value: Series): Series;
|
|
2027
|
-
cos(value: import("../index.js").float): import("../index.js").float;
|
|
2028
|
-
tan(value: Series): Series;
|
|
2029
|
-
tan(value: import("../index.js").float): import("../index.js").float;
|
|
2030
|
-
asin(value: Series): Series;
|
|
2031
|
-
asin(value: import("../index.js").float): import("../index.js").float;
|
|
2032
|
-
acos(value: Series): Series;
|
|
2033
|
-
acos(value: import("../index.js").float): import("../index.js").float;
|
|
2034
|
-
atan(value: Series): Series;
|
|
2035
|
-
atan(value: import("../index.js").float): import("../index.js").float;
|
|
2036
|
-
toradians(degrees: Series): Series;
|
|
2037
|
-
toradians(degrees: import("../index.js").float): import("../index.js").float;
|
|
2038
|
-
todegrees(radians: Series): Series;
|
|
2039
|
-
todegrees(radians: import("../index.js").float): import("../index.js").float;
|
|
2040
|
-
seededRandom(seed: import("../index.js").int): (min?: import("../index.js").float, max?: import("../index.js").float) => import("../index.js").float;
|
|
2041
|
-
resetRandom(): void;
|
|
2042
|
-
sign(value: Series): Series;
|
|
2043
|
-
sign(value: import("../index.js").float): import("../index.js").int;
|
|
2044
|
-
pi: number;
|
|
2045
|
-
e: number;
|
|
2046
|
-
phi: 1.618033988749895;
|
|
2047
|
-
rphi: 0.6180339887498948;
|
|
2048
|
-
};
|
|
2049
|
-
export * as compare from '../compare/index.js';
|
|
2085
|
+
/**
|
|
2086
|
+
* Math functions and constants for numbers and Series: rounding, min and max, powers and logarithms, trigonometry,
|
|
2087
|
+
* random numbers, `math.pi`... A Series argument gives a Series, numbers give a number. `math.round_to_mintick`
|
|
2088
|
+
* uses the symbol's tick size.
|
|
2089
|
+
* @example
|
|
2090
|
+
* ```js
|
|
2091
|
+
* const range = math.abs(close.sub(open));
|
|
2092
|
+
* plot(math.round(ta.sma(range, 10), 2), "Body");
|
|
2093
|
+
* ```
|
|
2094
|
+
*/
|
|
2095
|
+
export declare const math: Omit<typeof mathCore, 'saveRandom' | 'restoreRandom'>;
|
|
2096
|
+
/**
|
|
2097
|
+
* Plain-English names for the most used calculations (`calc.average`, `calc.crossesAbove`...), beside the `ta.*` ones.
|
|
2098
|
+
* They take Series or numbers and give a Series; a condition gives 1 where true and 0 where false.
|
|
2099
|
+
*/
|
|
2100
|
+
export declare const calc: CalcNamespace;
|
|
2101
|
+
/**
|
|
2102
|
+
* Comparisons of two numbers with a tolerance of 1e-10 (`compare.eq(0.1 + 0.2, 0.3)` is true), for the plain numbers
|
|
2103
|
+
* of a bar loop.
|
|
2104
|
+
*/
|
|
2105
|
+
export declare const compare: typeof compareCore;
|
|
2050
2106
|
export { isInputActive } from '../runtime/input-active.js';
|
|
2051
2107
|
export type { Bar, IndicatorResult, TimeValue, InputConfig, InputCondition, PlotConfig, HLineConfig, FillConfig, ShapeConfig, ArrowConfig, BarColorConfig, CandleConfig, MarkerData, MarkerPosition, MarkerShape, ArrowData, BarColorData, BgColorData, PlotCandleData, PlotBarData, LabelData, LabelStyle, LineDrawingData, BoxData, LinefillData, PolylineData, TableData, TableCellData, TableMergeData, TablePosition, MarkerLocation, MarkerSize, PineSize, ShapeStyle, };
|
|
2108
|
+
export { defineIndicator, type DefineIndicatorOptions, type IndicatorCalculation, type IndicatorDefinition, type IndicatorLiveRun, } from './define.js';
|
|
2109
|
+
export { formula, evaluateFormula, FORMULA_FUNCTIONS, type FormulaVariables } from './formula.js';
|
|
2110
|
+
export { defineIndicatorFromJson, indicatorBodyFromJson, checkIndicatorJson, type IndicatorJson, type JsonInput, type JsonPlot, type JsonLevel, type JsonFill, type JsonSignal, type JsonColorRule, } from './json.js';
|
|
2052
2111
|
//# sourceMappingURL=index.d.ts.map
|