@invinite-org/chartlang-core 1.0.1
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/CHANGELOG.md +1694 -0
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/alert/alert.d.ts +32 -0
- package/dist/alert/alert.d.ts.map +1 -0
- package/dist/alert/alert.js +19 -0
- package/dist/alert/alert.js.map +1 -0
- package/dist/alert/index.d.ts +2 -0
- package/dist/alert/index.d.ts.map +1 -0
- package/dist/alert/index.js +4 -0
- package/dist/alert/index.js.map +1 -0
- package/dist/color/colorHelpers.d.ts +65 -0
- package/dist/color/colorHelpers.d.ts.map +1 -0
- package/dist/color/colorHelpers.js +137 -0
- package/dist/color/colorHelpers.js.map +1 -0
- package/dist/color/index.d.ts +37 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +23 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/parseColor.d.ts +48 -0
- package/dist/color/parseColor.d.ts.map +1 -0
- package/dist/color/parseColor.js +141 -0
- package/dist/color/parseColor.js.map +1 -0
- package/dist/define/defineAlert.d.ts +43 -0
- package/dist/define/defineAlert.d.ts.map +1 -0
- package/dist/define/defineAlert.js +49 -0
- package/dist/define/defineAlert.js.map +1 -0
- package/dist/define/defineAlertCondition.d.ts +65 -0
- package/dist/define/defineAlertCondition.d.ts.map +1 -0
- package/dist/define/defineAlertCondition.js +64 -0
- package/dist/define/defineAlertCondition.js.map +1 -0
- package/dist/define/defineDrawing.d.ts +62 -0
- package/dist/define/defineDrawing.d.ts.map +1 -0
- package/dist/define/defineDrawing.js +67 -0
- package/dist/define/defineDrawing.js.map +1 -0
- package/dist/define/defineIndicator.d.ts +48 -0
- package/dist/define/defineIndicator.d.ts.map +1 -0
- package/dist/define/defineIndicator.js +54 -0
- package/dist/define/defineIndicator.js.map +1 -0
- package/dist/define/index.d.ts +6 -0
- package/dist/define/index.d.ts.map +1 -0
- package/dist/define/index.js +7 -0
- package/dist/define/index.js.map +1 -0
- package/dist/define/overrides.d.ts +102 -0
- package/dist/define/overrides.d.ts.map +1 -0
- package/dist/define/overrides.js +4 -0
- package/dist/define/overrides.js.map +1 -0
- package/dist/draw/buckets.d.ts +57 -0
- package/dist/draw/buckets.d.ts.map +1 -0
- package/dist/draw/buckets.js +110 -0
- package/dist/draw/buckets.js.map +1 -0
- package/dist/draw/draw.d.ts +128 -0
- package/dist/draw/draw.d.ts.map +1 -0
- package/dist/draw/draw.js +40 -0
- package/dist/draw/draw.js.map +1 -0
- package/dist/draw/drawingKind.d.ts +80 -0
- package/dist/draw/drawingKind.d.ts.map +1 -0
- package/dist/draw/drawingKind.js +177 -0
- package/dist/draw/drawingKind.js.map +1 -0
- package/dist/draw/drawingState.d.ts +1420 -0
- package/dist/draw/drawingState.d.ts.map +1 -0
- package/dist/draw/drawingState.js +4 -0
- package/dist/draw/drawingState.js.map +1 -0
- package/dist/draw/drawingStyle.d.ts +219 -0
- package/dist/draw/drawingStyle.d.ts.map +1 -0
- package/dist/draw/drawingStyle.js +4 -0
- package/dist/draw/drawingStyle.js.map +1 -0
- package/dist/draw/handle.d.ts +32 -0
- package/dist/draw/handle.d.ts.map +1 -0
- package/dist/draw/handle.js +4 -0
- package/dist/draw/handle.js.map +1 -0
- package/dist/draw/index.d.ts +13 -0
- package/dist/draw/index.d.ts.map +1 -0
- package/dist/draw/index.js +7 -0
- package/dist/draw/index.js.map +1 -0
- package/dist/draw/table.d.ts +84 -0
- package/dist/draw/table.d.ts.map +1 -0
- package/dist/draw/table.js +22 -0
- package/dist/draw/table.js.map +1 -0
- package/dist/draw/worldPoint.d.ts +114 -0
- package/dist/draw/worldPoint.d.ts.map +1 -0
- package/dist/draw/worldPoint.js +4 -0
- package/dist/draw/worldPoint.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/index.js +4 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/input.d.ts +174 -0
- package/dist/input/input.d.ts.map +1 -0
- package/dist/input/input.js +174 -0
- package/dist/input/input.js.map +1 -0
- package/dist/input/inputDescriptor.d.ts +204 -0
- package/dist/input/inputDescriptor.d.ts.map +1 -0
- package/dist/input/inputDescriptor.js +4 -0
- package/dist/input/inputDescriptor.js.map +1 -0
- package/dist/interval/intervalToSeconds.d.ts +20 -0
- package/dist/interval/intervalToSeconds.d.ts.map +1 -0
- package/dist/interval/intervalToSeconds.js +50 -0
- package/dist/interval/intervalToSeconds.js.map +1 -0
- package/dist/plot/index.d.ts +2 -0
- package/dist/plot/index.d.ts.map +1 -0
- package/dist/plot/index.js +4 -0
- package/dist/plot/index.js.map +1 -0
- package/dist/plot/plot.d.ts +277 -0
- package/dist/plot/plot.d.ts.map +1 -0
- package/dist/plot/plot.js +37 -0
- package/dist/plot/plot.js.map +1 -0
- package/dist/request/index.d.ts +2 -0
- package/dist/request/index.d.ts.map +1 -0
- package/dist/request/index.js +4 -0
- package/dist/request/index.js.map +1 -0
- package/dist/request/request.d.ts +106 -0
- package/dist/request/request.d.ts.map +1 -0
- package/dist/request/request.js +44 -0
- package/dist/request/request.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/runtime.d.ts +84 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +72 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/state/index.d.ts +5 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/mutableSlot.d.ts +25 -0
- package/dist/state/mutableSlot.d.ts.map +1 -0
- package/dist/state/mutableSlot.js +4 -0
- package/dist/state/mutableSlot.js.map +1 -0
- package/dist/state/snapshot.d.ts +108 -0
- package/dist/state/snapshot.d.ts.map +1 -0
- package/dist/state/snapshot.js +4 -0
- package/dist/state/snapshot.js.map +1 -0
- package/dist/state/state.d.ts +86 -0
- package/dist/state/state.d.ts.map +1 -0
- package/dist/state/state.js +95 -0
- package/dist/state/state.js.map +1 -0
- package/dist/statefulPrimitives.d.ts +71 -0
- package/dist/statefulPrimitives.d.ts.map +1 -0
- package/dist/statefulPrimitives.js +234 -0
- package/dist/statefulPrimitives.js.map +1 -0
- package/dist/ta/index.d.ts +2 -0
- package/dist/ta/index.d.ts.map +1 -0
- package/dist/ta/index.js +4 -0
- package/dist/ta/index.js.map +1 -0
- package/dist/ta/ta.d.ts +2476 -0
- package/dist/ta/ta.d.ts.map +1 -0
- package/dist/ta/ta.js +312 -0
- package/dist/ta/ta.js.map +1 -0
- package/dist/time/_lib/dateTimeFormatCache.d.ts +11 -0
- package/dist/time/_lib/dateTimeFormatCache.d.ts.map +1 -0
- package/dist/time/_lib/dateTimeFormatCache.js +22 -0
- package/dist/time/_lib/dateTimeFormatCache.js.map +1 -0
- package/dist/time/index.d.ts +7 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/time/index.js +8 -0
- package/dist/time/index.js.map +1 -0
- package/dist/time/nyDayKey.d.ts +24 -0
- package/dist/time/nyDayKey.d.ts.map +1 -0
- package/dist/time/nyDayKey.js +49 -0
- package/dist/time/nyDayKey.js.map +1 -0
- package/dist/time/session.d.ts +16 -0
- package/dist/time/session.d.ts.map +1 -0
- package/dist/time/session.js +18 -0
- package/dist/time/session.js.map +1 -0
- package/dist/time/sessionBoundaries.d.ts +40 -0
- package/dist/time/sessionBoundaries.d.ts.map +1 -0
- package/dist/time/sessionBoundaries.js +102 -0
- package/dist/time/sessionBoundaries.js.map +1 -0
- package/dist/time/types.d.ts +34 -0
- package/dist/time/types.d.ts.map +1 -0
- package/dist/time/types.js +4 -0
- package/dist/time/types.js.map +1 -0
- package/dist/time/weekKey.d.ts +11 -0
- package/dist/time/weekKey.d.ts.map +1 -0
- package/dist/time/weekKey.js +25 -0
- package/dist/time/weekKey.js.map +1 -0
- package/dist/time/weekday.d.ts +12 -0
- package/dist/time/weekday.d.ts.map +1 -0
- package/dist/time/weekday.js +22 -0
- package/dist/time/weekday.js.map +1 -0
- package/dist/types.d.ts +464 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/views/barstate.d.ts +40 -0
- package/dist/views/barstate.d.ts.map +1 -0
- package/dist/views/barstate.js +22 -0
- package/dist/views/barstate.js.map +1 -0
- package/dist/views/index.d.ts +4 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +4 -0
- package/dist/views/index.js.map +1 -0
- package/dist/views/syminfo.d.ts +46 -0
- package/dist/views/syminfo.d.ts.map +1 -0
- package/dist/views/syminfo.js +25 -0
- package/dist/views/syminfo.js.map +1 -0
- package/dist/views/timeframe.d.ts +40 -0
- package/dist/views/timeframe.d.ts.map +1 -0
- package/dist/views/timeframe.js +21 -0
- package/dist/views/timeframe.js.map +1 -0
- package/package.json +45 -0
package/dist/ta/ta.d.ts
ADDED
|
@@ -0,0 +1,2476 @@
|
|
|
1
|
+
import type { PlotLineStyle, Series, Time } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options bag for `ta.sma`. `offset` shifts the output forward by `n`
|
|
4
|
+
* bars per the universal `opts.offset` convention (PLAN.md §9.1):
|
|
5
|
+
* positive `n` makes `series.current` return the value `n` bars ago,
|
|
6
|
+
* negative `n` reads into the future (NaN at the head).
|
|
7
|
+
*
|
|
8
|
+
* @formula N/A — placeholder
|
|
9
|
+
* @since 0.1
|
|
10
|
+
* @stable
|
|
11
|
+
* @example
|
|
12
|
+
* const opts: SmaOpts = { offset: 0 };
|
|
13
|
+
*/
|
|
14
|
+
export type SmaOpts = Readonly<{
|
|
15
|
+
offset?: number;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Options bag for `ta.ema`. `offset` matches {@link SmaOpts}.
|
|
19
|
+
*
|
|
20
|
+
* @formula N/A — placeholder
|
|
21
|
+
* @since 0.1
|
|
22
|
+
* @stable
|
|
23
|
+
* @example
|
|
24
|
+
* const opts: EmaOpts = { offset: 0 };
|
|
25
|
+
*/
|
|
26
|
+
export type EmaOpts = Readonly<{
|
|
27
|
+
offset?: number;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Options bag for `ta.stdev`. `biased` toggles between population (default)
|
|
31
|
+
* and sample standard deviation. `offset` matches {@link SmaOpts}.
|
|
32
|
+
*
|
|
33
|
+
* @formula σ_biased = sqrt(Σ(x_i − μ)² / N); σ_sample = sqrt(Σ / (N − 1))
|
|
34
|
+
* @since 0.1
|
|
35
|
+
* @stable
|
|
36
|
+
* @example
|
|
37
|
+
* const opts: StdevOpts = { biased: false, offset: 0 };
|
|
38
|
+
*/
|
|
39
|
+
export type StdevOpts = Readonly<{
|
|
40
|
+
biased?: boolean;
|
|
41
|
+
offset?: number;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Options bag for `ta.bb`. `multiplier` defaults to `2` and scales the upper /
|
|
45
|
+
* lower bands away from the middle. `offset` matches {@link SmaOpts} and
|
|
46
|
+
* shifts all three bands (upper / middle / lower) in lockstep.
|
|
47
|
+
*
|
|
48
|
+
* @formula upper = sma + multiplier * stdev, lower = sma − multiplier * stdev
|
|
49
|
+
* @since 0.1
|
|
50
|
+
* @stable
|
|
51
|
+
* @example
|
|
52
|
+
* const opts: BbOpts = { multiplier: 2, offset: 0 };
|
|
53
|
+
*/
|
|
54
|
+
export type BbOpts = Readonly<{
|
|
55
|
+
multiplier?: number;
|
|
56
|
+
offset?: number;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Options bag for `ta.rsi`. `offset` matches {@link SmaOpts}.
|
|
60
|
+
*
|
|
61
|
+
* @formula N/A — placeholder
|
|
62
|
+
* @since 0.1
|
|
63
|
+
* @stable
|
|
64
|
+
* @example
|
|
65
|
+
* const opts: RsiOpts = { offset: 0 };
|
|
66
|
+
*/
|
|
67
|
+
export type RsiOpts = Readonly<{
|
|
68
|
+
offset?: number;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Options bag for `ta.macd`. Fast / slow / signal lengths default to the
|
|
72
|
+
* Appel-era 12 / 26 / 9 when omitted. `offset` matches {@link SmaOpts}
|
|
73
|
+
* and shifts all three outputs (macd / signal / hist) in lockstep.
|
|
74
|
+
*
|
|
75
|
+
* @formula N/A — see `ta.macd` JSDoc
|
|
76
|
+
* @since 0.1
|
|
77
|
+
* @stable
|
|
78
|
+
* @example
|
|
79
|
+
* const opts: MacdOpts = { fastLength: 12, slowLength: 26, signalLength: 9 };
|
|
80
|
+
*/
|
|
81
|
+
export type MacdOpts = Readonly<{
|
|
82
|
+
fastLength?: number;
|
|
83
|
+
slowLength?: number;
|
|
84
|
+
signalLength?: number;
|
|
85
|
+
offset?: number;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Options bag for `ta.atr`. `offset` matches {@link SmaOpts}.
|
|
89
|
+
*
|
|
90
|
+
* @formula N/A — placeholder
|
|
91
|
+
* @since 0.1
|
|
92
|
+
* @stable
|
|
93
|
+
* @example
|
|
94
|
+
* const opts: AtrOpts = { offset: 0 };
|
|
95
|
+
*/
|
|
96
|
+
export type AtrOpts = Readonly<{
|
|
97
|
+
offset?: number;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Options bag for `ta.crossover`. `offset` matches {@link SmaOpts}
|
|
101
|
+
* (shifts the boolean output so `series.current` returns the crossover
|
|
102
|
+
* detection `offset` bars ago).
|
|
103
|
+
*
|
|
104
|
+
* @formula N/A — see `ta.crossover` JSDoc
|
|
105
|
+
* @since 0.1
|
|
106
|
+
* @stable
|
|
107
|
+
* @example
|
|
108
|
+
* const opts: CrossoverOpts = { offset: 0 };
|
|
109
|
+
*/
|
|
110
|
+
export type CrossoverOpts = Readonly<{
|
|
111
|
+
offset?: number;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Options bag for `ta.crossunder`. Mirrors {@link CrossoverOpts}.
|
|
115
|
+
*
|
|
116
|
+
* @formula N/A — see `ta.crossunder` JSDoc
|
|
117
|
+
* @since 0.1
|
|
118
|
+
* @stable
|
|
119
|
+
* @example
|
|
120
|
+
* const opts: CrossunderOpts = { offset: 0 };
|
|
121
|
+
*/
|
|
122
|
+
export type CrossunderOpts = Readonly<{
|
|
123
|
+
offset?: number;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Options bag for `ta.highest`. `offset` shifts the read window backwards
|
|
127
|
+
* by `n` bars (Phase-2 backfill — see PLAN.md §9.1).
|
|
128
|
+
*
|
|
129
|
+
* @formula N/A — see `ta.highest` JSDoc
|
|
130
|
+
* @since 0.2
|
|
131
|
+
* @stable
|
|
132
|
+
* @example
|
|
133
|
+
* const opts: HighestOpts = { offset: 0 };
|
|
134
|
+
*/
|
|
135
|
+
export type HighestOpts = Readonly<{
|
|
136
|
+
offset?: number;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Options bag for `ta.lowest`. Mirrors {@link HighestOpts}.
|
|
140
|
+
*
|
|
141
|
+
* @formula N/A — see `ta.lowest` JSDoc
|
|
142
|
+
* @since 0.2
|
|
143
|
+
* @stable
|
|
144
|
+
* @example
|
|
145
|
+
* const opts: LowestOpts = { offset: 0 };
|
|
146
|
+
*/
|
|
147
|
+
export type LowestOpts = Readonly<{
|
|
148
|
+
offset?: number;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Options bag for `ta.change`. `length` is the lookback distance (default
|
|
152
|
+
* `1` — first-difference); `offset` shifts the read window backwards.
|
|
153
|
+
*
|
|
154
|
+
* @formula out = source[0] − source[length]
|
|
155
|
+
* @since 0.2
|
|
156
|
+
* @stable
|
|
157
|
+
* @example
|
|
158
|
+
* const opts: ChangeOpts = { length: 1 };
|
|
159
|
+
*/
|
|
160
|
+
export type ChangeOpts = Readonly<{
|
|
161
|
+
length?: number;
|
|
162
|
+
offset?: number;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Options bag for `ta.valuewhen`. `offset` shifts the emitted series after the
|
|
166
|
+
* occurrence lookup has been evaluated.
|
|
167
|
+
*
|
|
168
|
+
* @formula N/A — see `ta.valuewhen` JSDoc
|
|
169
|
+
* @since 0.4
|
|
170
|
+
* @stable
|
|
171
|
+
* @example
|
|
172
|
+
* const opts: ValuewhenOpts = { offset: 0 };
|
|
173
|
+
*/
|
|
174
|
+
export type ValuewhenOpts = Readonly<{
|
|
175
|
+
offset?: number;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Options bag for `ta.barssince`. `offset` shifts the elapsed-bars output.
|
|
179
|
+
*
|
|
180
|
+
* @formula N/A — see `ta.barssince` JSDoc
|
|
181
|
+
* @since 0.4
|
|
182
|
+
* @stable
|
|
183
|
+
* @example
|
|
184
|
+
* const opts: BarssinceOpts = { offset: 0 };
|
|
185
|
+
*/
|
|
186
|
+
export type BarssinceOpts = Readonly<{
|
|
187
|
+
offset?: number;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Options bag for `ta.wma`. `offset` shifts the output forward by `n`
|
|
191
|
+
* bars (Task-29 universal-offset backfill). `lineStyle` is a
|
|
192
|
+
* pass-through for the script-author's downstream `plot(wma, { lineStyle })`
|
|
193
|
+
* call — not consumed by the primitive itself.
|
|
194
|
+
*
|
|
195
|
+
* @formula N/A — see `ta.wma` JSDoc
|
|
196
|
+
* @since 0.2
|
|
197
|
+
* @stable
|
|
198
|
+
* @example
|
|
199
|
+
* const opts: WmaOpts = { offset: 0 };
|
|
200
|
+
*/
|
|
201
|
+
export type WmaOpts = Readonly<{
|
|
202
|
+
offset?: number;
|
|
203
|
+
lineStyle?: PlotLineStyle;
|
|
204
|
+
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Options bag for `ta.vwma`. Mirrors {@link WmaOpts}.
|
|
207
|
+
*
|
|
208
|
+
* @formula N/A — see `ta.vwma` JSDoc
|
|
209
|
+
* @since 0.2
|
|
210
|
+
* @stable
|
|
211
|
+
* @example
|
|
212
|
+
* const opts: VwmaOpts = { offset: 0 };
|
|
213
|
+
*/
|
|
214
|
+
export type VwmaOpts = Readonly<{
|
|
215
|
+
offset?: number;
|
|
216
|
+
lineStyle?: PlotLineStyle;
|
|
217
|
+
}>;
|
|
218
|
+
/**
|
|
219
|
+
* Options bag for `ta.hma`. Mirrors {@link WmaOpts}.
|
|
220
|
+
*
|
|
221
|
+
* @formula N/A — see `ta.hma` JSDoc
|
|
222
|
+
* @since 0.2
|
|
223
|
+
* @stable
|
|
224
|
+
* @example
|
|
225
|
+
* const opts: HmaOpts = { offset: 0 };
|
|
226
|
+
*/
|
|
227
|
+
export type HmaOpts = Readonly<{
|
|
228
|
+
offset?: number;
|
|
229
|
+
lineStyle?: PlotLineStyle;
|
|
230
|
+
}>;
|
|
231
|
+
/**
|
|
232
|
+
* Options bag for `ta.smma` (smoothed moving average, Wilder's RMA).
|
|
233
|
+
* Mirrors {@link WmaOpts}.
|
|
234
|
+
*
|
|
235
|
+
* @formula N/A — see `ta.smma` JSDoc
|
|
236
|
+
* @since 0.2
|
|
237
|
+
* @stable
|
|
238
|
+
* @example
|
|
239
|
+
* const opts: SmmaOpts = { offset: 0 };
|
|
240
|
+
*/
|
|
241
|
+
export type SmmaOpts = Readonly<{
|
|
242
|
+
offset?: number;
|
|
243
|
+
lineStyle?: PlotLineStyle;
|
|
244
|
+
}>;
|
|
245
|
+
/**
|
|
246
|
+
* Options bag for `ta.dema` (double EMA). Mirrors {@link WmaOpts}.
|
|
247
|
+
*
|
|
248
|
+
* @formula N/A — see `ta.dema` JSDoc
|
|
249
|
+
* @since 0.2
|
|
250
|
+
* @stable
|
|
251
|
+
* @example
|
|
252
|
+
* const opts: DemaOpts = { offset: 0 };
|
|
253
|
+
*/
|
|
254
|
+
export type DemaOpts = Readonly<{
|
|
255
|
+
offset?: number;
|
|
256
|
+
lineStyle?: PlotLineStyle;
|
|
257
|
+
}>;
|
|
258
|
+
/**
|
|
259
|
+
* Options bag for `ta.tema` (triple EMA). Mirrors {@link WmaOpts}.
|
|
260
|
+
*
|
|
261
|
+
* @formula N/A — see `ta.tema` JSDoc
|
|
262
|
+
* @since 0.2
|
|
263
|
+
* @stable
|
|
264
|
+
* @example
|
|
265
|
+
* const opts: TemaOpts = { offset: 0 };
|
|
266
|
+
*/
|
|
267
|
+
export type TemaOpts = Readonly<{
|
|
268
|
+
offset?: number;
|
|
269
|
+
lineStyle?: PlotLineStyle;
|
|
270
|
+
}>;
|
|
271
|
+
/**
|
|
272
|
+
* Options bag for `ta.kama` (Kaufman Adaptive MA). `length` (default
|
|
273
|
+
* `10`) is the efficiency-ratio window; `fastLength` / `slowLength`
|
|
274
|
+
* (defaults `2` / `30`) define the bounding alphas the smoothing
|
|
275
|
+
* constant interpolates between. `offset` matches {@link WmaOpts};
|
|
276
|
+
* `lineStyle` is a forward-compat plot-styling hint.
|
|
277
|
+
*
|
|
278
|
+
* @formula N/A — see `ta.kama` JSDoc
|
|
279
|
+
* @since 0.2
|
|
280
|
+
* @stable
|
|
281
|
+
* @example
|
|
282
|
+
* const opts: KamaOpts = { length: 10, fastLength: 2, slowLength: 30 };
|
|
283
|
+
*/
|
|
284
|
+
export type KamaOpts = Readonly<{
|
|
285
|
+
length?: number;
|
|
286
|
+
fastLength?: number;
|
|
287
|
+
slowLength?: number;
|
|
288
|
+
offset?: number;
|
|
289
|
+
lineStyle?: PlotLineStyle;
|
|
290
|
+
}>;
|
|
291
|
+
/**
|
|
292
|
+
* Options bag for `ta.alma` (Arnaud Legoux MA). `offset` is the
|
|
293
|
+
* Gaussian-centre position in `[0, 1]` (default `0.85`) — NOT the
|
|
294
|
+
* universal bar-shift; the universal shift on ALMA uses the distinct
|
|
295
|
+
* `barShift` field. `sigma` (default `6`) sets the Gaussian spread
|
|
296
|
+
* (spread = `length / sigma`). `lineStyle` is a forward-compat
|
|
297
|
+
* plot-styling hint.
|
|
298
|
+
*
|
|
299
|
+
* @formula N/A — see `ta.alma` JSDoc
|
|
300
|
+
* @anchors offset, sigma
|
|
301
|
+
* @since 0.2
|
|
302
|
+
* @stable
|
|
303
|
+
* @example
|
|
304
|
+
* const opts: AlmaOpts = { offset: 0.85, sigma: 6 };
|
|
305
|
+
*/
|
|
306
|
+
export type AlmaOpts = Readonly<{
|
|
307
|
+
offset?: number;
|
|
308
|
+
sigma?: number;
|
|
309
|
+
barShift?: number;
|
|
310
|
+
lineStyle?: PlotLineStyle;
|
|
311
|
+
}>;
|
|
312
|
+
/**
|
|
313
|
+
* Options bag for `ta.lsma` (least-squares regression value at the
|
|
314
|
+
* trailing window's last bar). Mirrors {@link WmaOpts}.
|
|
315
|
+
*
|
|
316
|
+
* @formula N/A — see `ta.lsma` JSDoc
|
|
317
|
+
* @since 0.2
|
|
318
|
+
* @stable
|
|
319
|
+
* @example
|
|
320
|
+
* const opts: LsmaOpts = { offset: 0 };
|
|
321
|
+
*/
|
|
322
|
+
export type LsmaOpts = Readonly<{
|
|
323
|
+
offset?: number;
|
|
324
|
+
lineStyle?: PlotLineStyle;
|
|
325
|
+
}>;
|
|
326
|
+
/**
|
|
327
|
+
* Options bag for `ta.mcginley` (McGinley Dynamic). Mirrors
|
|
328
|
+
* {@link WmaOpts}.
|
|
329
|
+
*
|
|
330
|
+
* @formula N/A — see `ta.mcginley` JSDoc
|
|
331
|
+
* @since 0.2
|
|
332
|
+
* @stable
|
|
333
|
+
* @example
|
|
334
|
+
* const opts: McginleyOpts = { offset: 0 };
|
|
335
|
+
*/
|
|
336
|
+
export type McginleyOpts = Readonly<{
|
|
337
|
+
offset?: number;
|
|
338
|
+
lineStyle?: PlotLineStyle;
|
|
339
|
+
}>;
|
|
340
|
+
/**
|
|
341
|
+
* Canonical moving-average kind union, excluding `"vwma"`. Shared with
|
|
342
|
+
* the runtime's `lib/maTypes.ts` (byte-equal string-literal union) and
|
|
343
|
+
* referenced by the surface types that accept an `maType` opt
|
|
344
|
+
* (`ta.maRibbon` today; more once Phase-2 ports land). VWMA is
|
|
345
|
+
* excluded because it requires a parallel volume array — derived
|
|
346
|
+
* Float64 inputs (the chained-MA dispatch path) carry no matching
|
|
347
|
+
* volume stream.
|
|
348
|
+
*
|
|
349
|
+
* @formula N/A — string-literal union type
|
|
350
|
+
* @since 0.2
|
|
351
|
+
* @stable
|
|
352
|
+
* @example
|
|
353
|
+
* const k: MaTypeNoVolume = "ema";
|
|
354
|
+
*/
|
|
355
|
+
export type MaTypeNoVolume = "sma" | "ema" | "wma" | "smma";
|
|
356
|
+
/**
|
|
357
|
+
* Options bag for `ta.maRibbon` (a fan of K MAs at different lengths).
|
|
358
|
+
* Defaults: `lengths = [10, 20, 30, 40, 50]`, `maType = "sma"`.
|
|
359
|
+
* `offset` is the universal bar-shift (per PLAN.md §9.1) applied to
|
|
360
|
+
* every output series. `outputs` is forward-compat per-key plot styling
|
|
361
|
+
* (typed but not consumed by the runtime impl).
|
|
362
|
+
*
|
|
363
|
+
* @formula N/A — see `ta.maRibbon` JSDoc
|
|
364
|
+
* @anchors lengths, maType
|
|
365
|
+
* @since 0.2
|
|
366
|
+
* @stable
|
|
367
|
+
* @example
|
|
368
|
+
* const opts: MaRibbonOpts = { lengths: [10, 20, 30], maType: "ema" };
|
|
369
|
+
*/
|
|
370
|
+
export type MaRibbonOpts = Readonly<{
|
|
371
|
+
lengths?: ReadonlyArray<number>;
|
|
372
|
+
maType?: MaTypeNoVolume;
|
|
373
|
+
offset?: number;
|
|
374
|
+
outputs?: Readonly<Record<string, {
|
|
375
|
+
lineStyle?: PlotLineStyle;
|
|
376
|
+
}>>;
|
|
377
|
+
}>;
|
|
378
|
+
/**
|
|
379
|
+
* Result of `ta.maRibbon` — a dynamic-key record keyed by
|
|
380
|
+
* `ma_<length>` (one entry per resolved `lengths` value). Iteration
|
|
381
|
+
* order matches the resolved `lengths` array; use the sibling
|
|
382
|
+
* `maRibbonOutputKeys` helper (exported from
|
|
383
|
+
* `@invinite-org/chartlang-runtime`) for stable iteration over an
|
|
384
|
+
* `opts` value.
|
|
385
|
+
*
|
|
386
|
+
* @formula N/A — dynamic-key record type, see `ta.maRibbon` JSDoc
|
|
387
|
+
* @since 0.2
|
|
388
|
+
* @stable
|
|
389
|
+
* @example
|
|
390
|
+
* declare const r: MaRibbonResult;
|
|
391
|
+
* void r.ma_10?.current;
|
|
392
|
+
*/
|
|
393
|
+
export type MaRibbonResult = Readonly<Record<string, Series<number>>>;
|
|
394
|
+
/**
|
|
395
|
+
* Options bag for `ta.ao` (Awesome Oscillator). Fast / slow lengths
|
|
396
|
+
* default to the Pine-canonical `5` / `34` over the `hl2` midpoint.
|
|
397
|
+
* `lineStyle` is a forward-compat plot-styling hint surfaced for
|
|
398
|
+
* §9.1 ergonomics.
|
|
399
|
+
*
|
|
400
|
+
* @formula out = SMA(hl2, fastLength) − SMA(hl2, slowLength)
|
|
401
|
+
* @since 0.2
|
|
402
|
+
* @stable
|
|
403
|
+
* @example
|
|
404
|
+
* const opts: AoOpts = { fastLength: 5, slowLength: 34 };
|
|
405
|
+
*/
|
|
406
|
+
export type AoOpts = Readonly<{
|
|
407
|
+
fastLength?: number;
|
|
408
|
+
slowLength?: number;
|
|
409
|
+
offset?: number;
|
|
410
|
+
lineStyle?: PlotLineStyle;
|
|
411
|
+
}>;
|
|
412
|
+
/**
|
|
413
|
+
* Options bag for `ta.cmo` (Chande Momentum Oscillator). `offset` shifts
|
|
414
|
+
* the read window; `lineStyle` is a forward-compat plot-styling hint.
|
|
415
|
+
*
|
|
416
|
+
* @formula CMO = 100 · (Σ gain − Σ loss) / (Σ gain + Σ loss)
|
|
417
|
+
* @since 0.2
|
|
418
|
+
* @stable
|
|
419
|
+
* @example
|
|
420
|
+
* const opts: CmoOpts = { offset: 0 };
|
|
421
|
+
*/
|
|
422
|
+
export type CmoOpts = Readonly<{
|
|
423
|
+
offset?: number;
|
|
424
|
+
lineStyle?: PlotLineStyle;
|
|
425
|
+
}>;
|
|
426
|
+
/**
|
|
427
|
+
* Options bag for `ta.momentum` (Pine `mom`).
|
|
428
|
+
*
|
|
429
|
+
* @formula out = source[0] − source[length]
|
|
430
|
+
* @since 0.2
|
|
431
|
+
* @stable
|
|
432
|
+
* @example
|
|
433
|
+
* const opts: MomentumOpts = { offset: 0 };
|
|
434
|
+
*/
|
|
435
|
+
export type MomentumOpts = Readonly<{
|
|
436
|
+
offset?: number;
|
|
437
|
+
lineStyle?: PlotLineStyle;
|
|
438
|
+
}>;
|
|
439
|
+
/**
|
|
440
|
+
* Options bag for `ta.roc` (Rate of Change).
|
|
441
|
+
*
|
|
442
|
+
* @formula ROC = 100 · (source[0] − source[length]) / source[length]
|
|
443
|
+
* @since 0.2
|
|
444
|
+
* @stable
|
|
445
|
+
* @example
|
|
446
|
+
* const opts: RocOpts = { offset: 0 };
|
|
447
|
+
*/
|
|
448
|
+
export type RocOpts = Readonly<{
|
|
449
|
+
offset?: number;
|
|
450
|
+
lineStyle?: PlotLineStyle;
|
|
451
|
+
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Options bag for `ta.pmo` (Carl Swenlin's Price Momentum Oscillator).
|
|
454
|
+
* `firstSmoothing` / `secondSmoothing` / `signalLength` default to the
|
|
455
|
+
* TradingView-canonical `35` / `20` / `10`. The inner two stages use a
|
|
456
|
+
* non-canonical EMA factor (`α = 2 / length`); the signal line uses
|
|
457
|
+
* the standard EMA (`α = 2 / (length + 1)`).
|
|
458
|
+
*
|
|
459
|
+
* @formula N/A — see `ta.pmo` JSDoc
|
|
460
|
+
* @since 0.2
|
|
461
|
+
* @stable
|
|
462
|
+
* @example
|
|
463
|
+
* const opts: PmoOpts = { firstSmoothing: 35, secondSmoothing: 20, signalLength: 10 };
|
|
464
|
+
*/
|
|
465
|
+
export type PmoOpts = Readonly<{
|
|
466
|
+
firstSmoothing?: number;
|
|
467
|
+
secondSmoothing?: number;
|
|
468
|
+
signalLength?: number;
|
|
469
|
+
offset?: number;
|
|
470
|
+
lineStyle?: PlotLineStyle;
|
|
471
|
+
}>;
|
|
472
|
+
/**
|
|
473
|
+
* The two-series result of `ta.pmo` — the `pmo` line plus its `signal`
|
|
474
|
+
* line (standard EMA over the pmo output, `signalLength` window).
|
|
475
|
+
* `primarySeriesKey: "pmo"` is recorded on `TA_REGISTRY_METADATA`.
|
|
476
|
+
*
|
|
477
|
+
* @formula see `ta.pmo` JSDoc
|
|
478
|
+
* @since 0.2
|
|
479
|
+
* @stable
|
|
480
|
+
* @example
|
|
481
|
+
* const p = ta.pmo(bar.close);
|
|
482
|
+
* plot(p.pmo);
|
|
483
|
+
* plot(p.signal);
|
|
484
|
+
*/
|
|
485
|
+
export type PmoResult = Readonly<{
|
|
486
|
+
pmo: Series<number>;
|
|
487
|
+
signal: Series<number>;
|
|
488
|
+
}>;
|
|
489
|
+
/**
|
|
490
|
+
* Options bag for `ta.smi` (William Blau's Stochastic Momentum Index).
|
|
491
|
+
* `kLength` is the rolling high/low window (default `10`);
|
|
492
|
+
* `firstSmoothing` / `secondSmoothing` are the double-EMA smoothing
|
|
493
|
+
* lengths for both numerator and denominator (defaults `3` / `5`);
|
|
494
|
+
* `dLength` is the signal-line EMA length (default `3`).
|
|
495
|
+
*
|
|
496
|
+
* @formula N/A — see `ta.smi` JSDoc
|
|
497
|
+
* @since 0.2
|
|
498
|
+
* @stable
|
|
499
|
+
* @example
|
|
500
|
+
* const opts: SmiOpts = { kLength: 10, firstSmoothing: 3, secondSmoothing: 5, dLength: 3 };
|
|
501
|
+
*/
|
|
502
|
+
export type SmiOpts = Readonly<{
|
|
503
|
+
kLength?: number;
|
|
504
|
+
firstSmoothing?: number;
|
|
505
|
+
secondSmoothing?: number;
|
|
506
|
+
dLength?: number;
|
|
507
|
+
offset?: number;
|
|
508
|
+
lineStyle?: PlotLineStyle;
|
|
509
|
+
}>;
|
|
510
|
+
/**
|
|
511
|
+
* The two-series result of `ta.smi` — the `smi` line bounded
|
|
512
|
+
* `[-100, 100]` plus its `signal` line (EMA(`dLength`) of `smi`).
|
|
513
|
+
* `primarySeriesKey: "smi"` is recorded on `TA_REGISTRY_METADATA`
|
|
514
|
+
* with `yDomain: { kind: "fixed", min: -100, max: 100 }`.
|
|
515
|
+
*
|
|
516
|
+
* @formula see `ta.smi` JSDoc
|
|
517
|
+
* @since 0.2
|
|
518
|
+
* @stable
|
|
519
|
+
* @example
|
|
520
|
+
* const s = ta.smi();
|
|
521
|
+
* plot(s.smi);
|
|
522
|
+
* plot(s.signal);
|
|
523
|
+
*/
|
|
524
|
+
export type SmiResult = Readonly<{
|
|
525
|
+
smi: Series<number>;
|
|
526
|
+
signal: Series<number>;
|
|
527
|
+
}>;
|
|
528
|
+
/**
|
|
529
|
+
* Options bag for `ta.tsi` (William Blau's True Strength Index — the
|
|
530
|
+
* momentum-class oscillator). `firstSmoothing` is the outer (longer)
|
|
531
|
+
* EMA length (default `25`); `secondSmoothing` is the inner (shorter)
|
|
532
|
+
* EMA length (default `13`); `signalLength` is the signal-line EMA
|
|
533
|
+
* length (default `13`).
|
|
534
|
+
*
|
|
535
|
+
* @formula N/A — see `ta.tsi` JSDoc
|
|
536
|
+
* @since 0.2
|
|
537
|
+
* @stable
|
|
538
|
+
* @example
|
|
539
|
+
* const opts: TsiOpts = { firstSmoothing: 25, secondSmoothing: 13, signalLength: 13 };
|
|
540
|
+
*/
|
|
541
|
+
export type TsiOpts = Readonly<{
|
|
542
|
+
firstSmoothing?: number;
|
|
543
|
+
secondSmoothing?: number;
|
|
544
|
+
signalLength?: number;
|
|
545
|
+
offset?: number;
|
|
546
|
+
lineStyle?: PlotLineStyle;
|
|
547
|
+
}>;
|
|
548
|
+
/**
|
|
549
|
+
* The two-series result of `ta.tsi` — the `tsi` line bounded
|
|
550
|
+
* `[-100, 100]` by construction plus its `signal` line
|
|
551
|
+
* (EMA(`signalLength`) of `tsi`). `primarySeriesKey: "tsi"` is
|
|
552
|
+
* recorded on `TA_REGISTRY_METADATA` with `yDomain: { kind: "auto" }`
|
|
553
|
+
* (TSI rarely approaches ±100 — we follow invinite's plugin choice
|
|
554
|
+
* and let the renderer fit the visible range).
|
|
555
|
+
*
|
|
556
|
+
* @formula see `ta.tsi` JSDoc
|
|
557
|
+
* @since 0.2
|
|
558
|
+
* @stable
|
|
559
|
+
* @example
|
|
560
|
+
* const t = ta.tsi(bar.close);
|
|
561
|
+
* plot(t.tsi);
|
|
562
|
+
* plot(t.signal);
|
|
563
|
+
*/
|
|
564
|
+
export type TsiResult = Readonly<{
|
|
565
|
+
tsi: Series<number>;
|
|
566
|
+
signal: Series<number>;
|
|
567
|
+
}>;
|
|
568
|
+
/**
|
|
569
|
+
* Options bag for `ta.cci`. `offset` shifts the read window backwards
|
|
570
|
+
* (Phase-2 backfill — see PLAN.md §9.1). `lineStyle` is a pass-through
|
|
571
|
+
* for the script-author's downstream `plot(cci, { lineStyle })` call
|
|
572
|
+
* and is not consumed by the primitive itself.
|
|
573
|
+
*
|
|
574
|
+
* @formula N/A — see `ta.cci` JSDoc
|
|
575
|
+
* @since 0.2
|
|
576
|
+
* @stable
|
|
577
|
+
* @example
|
|
578
|
+
* const opts: CciOpts = { offset: 0 };
|
|
579
|
+
*/
|
|
580
|
+
export type CciOpts = Readonly<{
|
|
581
|
+
offset?: number;
|
|
582
|
+
lineStyle?: PlotLineStyle;
|
|
583
|
+
}>;
|
|
584
|
+
/**
|
|
585
|
+
* Options bag for `ta.stoch`. `kLength` / `kSmoothing` / `dLength`
|
|
586
|
+
* default to `14` / `3` / `3` — Pine's canonical Stochastic Oscillator
|
|
587
|
+
* defaults.
|
|
588
|
+
*
|
|
589
|
+
* @formula N/A — see `ta.stoch` JSDoc
|
|
590
|
+
* @since 0.2
|
|
591
|
+
* @stable
|
|
592
|
+
* @example
|
|
593
|
+
* const opts: StochOpts = { kLength: 14, kSmoothing: 3, dLength: 3 };
|
|
594
|
+
*/
|
|
595
|
+
export type StochOpts = Readonly<{
|
|
596
|
+
kLength?: number;
|
|
597
|
+
kSmoothing?: number;
|
|
598
|
+
dLength?: number;
|
|
599
|
+
offset?: number;
|
|
600
|
+
}>;
|
|
601
|
+
/**
|
|
602
|
+
* Options bag for `ta.williamsR`. Mirrors {@link CciOpts}.
|
|
603
|
+
*
|
|
604
|
+
* @formula N/A — see `ta.williamsR` JSDoc
|
|
605
|
+
* @since 0.2
|
|
606
|
+
* @stable
|
|
607
|
+
* @example
|
|
608
|
+
* const opts: WilliamsROpts = { offset: 0 };
|
|
609
|
+
*/
|
|
610
|
+
export type WilliamsROpts = Readonly<{
|
|
611
|
+
offset?: number;
|
|
612
|
+
lineStyle?: PlotLineStyle;
|
|
613
|
+
}>;
|
|
614
|
+
/**
|
|
615
|
+
* The two-series result of `ta.stoch` — the `%K` line and the `%D`
|
|
616
|
+
* signal line. Both Series are updated in lock-step with the source.
|
|
617
|
+
* `primarySeriesKey: "k"` (the registry metadata records this).
|
|
618
|
+
*
|
|
619
|
+
* @formula k = sma(kRaw, kSmoothing); d = sma(k, dLength)
|
|
620
|
+
* @since 0.2
|
|
621
|
+
* @stable
|
|
622
|
+
* @example
|
|
623
|
+
* const s = ta.stoch({ kLength: 14, kSmoothing: 3, dLength: 3 });
|
|
624
|
+
* plot(s.k);
|
|
625
|
+
* plot(s.d);
|
|
626
|
+
*/
|
|
627
|
+
export type StochResult = Readonly<{
|
|
628
|
+
k: Series<number>;
|
|
629
|
+
d: Series<number>;
|
|
630
|
+
}>;
|
|
631
|
+
/**
|
|
632
|
+
* Options bag for `ta.stochRsi`. `rsiLength` / `stochLength` /
|
|
633
|
+
* `kSmoothing` / `dSmoothing` default to the Pine-canonical
|
|
634
|
+
* `14` / `14` / `3` / `3` Stochastic-RSI settings. `offset`
|
|
635
|
+
* shifts the read window backwards (PLAN.md §9.1).
|
|
636
|
+
*
|
|
637
|
+
* @formula N/A — see `ta.stochRsi` JSDoc
|
|
638
|
+
* @since 0.2
|
|
639
|
+
* @stable
|
|
640
|
+
* @example
|
|
641
|
+
* const opts: StochRsiOpts = { rsiLength: 14, stochLength: 14, kSmoothing: 3, dSmoothing: 3 };
|
|
642
|
+
*/
|
|
643
|
+
export type StochRsiOpts = Readonly<{
|
|
644
|
+
rsiLength?: number;
|
|
645
|
+
stochLength?: number;
|
|
646
|
+
kSmoothing?: number;
|
|
647
|
+
dSmoothing?: number;
|
|
648
|
+
offset?: number;
|
|
649
|
+
}>;
|
|
650
|
+
/**
|
|
651
|
+
* Options bag for `ta.ultimateOsc`. `shortLength` / `mediumLength` /
|
|
652
|
+
* `longLength` default to Larry Williams' canonical `7` / `14` / `28`.
|
|
653
|
+
* `offset` shifts the read window backwards; `lineStyle` is a
|
|
654
|
+
* forward-compat plot-styling hint.
|
|
655
|
+
*
|
|
656
|
+
* @formula N/A — see `ta.ultimateOsc` JSDoc
|
|
657
|
+
* @since 0.2
|
|
658
|
+
* @stable
|
|
659
|
+
* @example
|
|
660
|
+
* const opts: UltimateOscOpts = { shortLength: 7, mediumLength: 14, longLength: 28 };
|
|
661
|
+
*/
|
|
662
|
+
export type UltimateOscOpts = Readonly<{
|
|
663
|
+
shortLength?: number;
|
|
664
|
+
mediumLength?: number;
|
|
665
|
+
longLength?: number;
|
|
666
|
+
offset?: number;
|
|
667
|
+
lineStyle?: PlotLineStyle;
|
|
668
|
+
}>;
|
|
669
|
+
/**
|
|
670
|
+
* Options bag for `ta.coppock`. `roc1Length` / `roc2Length` /
|
|
671
|
+
* `wmaLength` default to the Edwin Coppock canonical `11` / `14` /
|
|
672
|
+
* `10`. `offset` shifts the read window backwards; `lineStyle` is a
|
|
673
|
+
* forward-compat plot-styling hint.
|
|
674
|
+
*
|
|
675
|
+
* @formula N/A — see `ta.coppock` JSDoc
|
|
676
|
+
* @since 0.2
|
|
677
|
+
* @stable
|
|
678
|
+
* @example
|
|
679
|
+
* const opts: CoppockOpts = { roc1Length: 11, roc2Length: 14, wmaLength: 10 };
|
|
680
|
+
*/
|
|
681
|
+
export type CoppockOpts = Readonly<{
|
|
682
|
+
roc1Length?: number;
|
|
683
|
+
roc2Length?: number;
|
|
684
|
+
wmaLength?: number;
|
|
685
|
+
offset?: number;
|
|
686
|
+
lineStyle?: PlotLineStyle;
|
|
687
|
+
}>;
|
|
688
|
+
/**
|
|
689
|
+
* Options bag for `ta.ppo`. `fastLength` / `slowLength` / `signalLength`
|
|
690
|
+
* default to the Appel-era `12` / `26` / `9` (mirrors `ta.macd`).
|
|
691
|
+
* `offset` shifts all three outputs (`ppo`, `signal`, `hist`) in
|
|
692
|
+
* lockstep per the universal `opts.offset` convention (PLAN.md §9.1).
|
|
693
|
+
*
|
|
694
|
+
* @formula N/A — see `ta.ppo` JSDoc
|
|
695
|
+
* @since 0.2
|
|
696
|
+
* @stable
|
|
697
|
+
* @example
|
|
698
|
+
* const opts: PpoOpts = { fastLength: 12, slowLength: 26, signalLength: 9 };
|
|
699
|
+
*/
|
|
700
|
+
export type PpoOpts = Readonly<{
|
|
701
|
+
fastLength?: number;
|
|
702
|
+
slowLength?: number;
|
|
703
|
+
signalLength?: number;
|
|
704
|
+
offset?: number;
|
|
705
|
+
}>;
|
|
706
|
+
/**
|
|
707
|
+
* Options bag for `ta.dpo`. `offset` shifts the read window backwards
|
|
708
|
+
* (PLAN.md §9.1). `lineStyle` is a forward-compat plot-styling hint
|
|
709
|
+
* surfaced for §9.1 ergonomics — not consumed by the primitive
|
|
710
|
+
* itself.
|
|
711
|
+
*
|
|
712
|
+
* @formula N/A — see `ta.dpo` JSDoc
|
|
713
|
+
* @since 0.2
|
|
714
|
+
* @stable
|
|
715
|
+
* @example
|
|
716
|
+
* const opts: DpoOpts = { offset: 0 };
|
|
717
|
+
*/
|
|
718
|
+
export type DpoOpts = Readonly<{
|
|
719
|
+
offset?: number;
|
|
720
|
+
lineStyle?: PlotLineStyle;
|
|
721
|
+
}>;
|
|
722
|
+
/**
|
|
723
|
+
* Options bag for `ta.connorsRsi`. `rsiLength` / `streakLength` /
|
|
724
|
+
* `rocLength` default to Larry Connors' canonical `3` / `2` / `100`.
|
|
725
|
+
* `offset` shifts the read window backwards (PLAN.md §9.1).
|
|
726
|
+
*
|
|
727
|
+
* @formula N/A — see `ta.connorsRsi` JSDoc
|
|
728
|
+
* @since 0.2
|
|
729
|
+
* @stable
|
|
730
|
+
* @example
|
|
731
|
+
* const opts: ConnorsRsiOpts = { rsiLength: 3, streakLength: 2, rocLength: 100 };
|
|
732
|
+
*/
|
|
733
|
+
export type ConnorsRsiOpts = Readonly<{
|
|
734
|
+
rsiLength?: number;
|
|
735
|
+
streakLength?: number;
|
|
736
|
+
rocLength?: number;
|
|
737
|
+
offset?: number;
|
|
738
|
+
}>;
|
|
739
|
+
/**
|
|
740
|
+
* The three-series result of `ta.ppo` — the PPO line, its signal
|
|
741
|
+
* line, and the histogram of their difference. All three Series are
|
|
742
|
+
* updated in lock-step with the source. `primarySeriesKey: "ppo"` is
|
|
743
|
+
* recorded in `TA_REGISTRY_METADATA`.
|
|
744
|
+
*
|
|
745
|
+
* @formula ppo = 100 · (ema(src, fast) − ema(src, slow)) / ema(src, slow) ;
|
|
746
|
+
* signal = ema(ppo, signalLength) ;
|
|
747
|
+
* hist = ppo − signal
|
|
748
|
+
* @since 0.2
|
|
749
|
+
* @stable
|
|
750
|
+
* @example
|
|
751
|
+
* const p = ta.ppo(bar.close);
|
|
752
|
+
* plot(p.ppo); plot(p.signal); plot(p.hist);
|
|
753
|
+
*/
|
|
754
|
+
export type PpoResult = Readonly<{
|
|
755
|
+
ppo: Series<number>;
|
|
756
|
+
signal: Series<number>;
|
|
757
|
+
hist: Series<number>;
|
|
758
|
+
}>;
|
|
759
|
+
/**
|
|
760
|
+
* The two-series result of `ta.stochRsi` — the `%K` line (stochastic
|
|
761
|
+
* applied to the RSI series, smoothed by `kSmoothing`) and the `%D`
|
|
762
|
+
* signal (SMA of `%K` over `dSmoothing`). Both Series ∈ [0, 100]
|
|
763
|
+
* when defined; the runtime emits NaN through the warmup window or
|
|
764
|
+
* when the rolling RSI range is flat (zero denominator).
|
|
765
|
+
*
|
|
766
|
+
* `primarySeriesKey: "k"` (recorded in `TA_REGISTRY_METADATA`).
|
|
767
|
+
*
|
|
768
|
+
* @formula rsi = rsi(source, rsiLength) ;
|
|
769
|
+
* kRaw = 100 · (rsi − lowest(rsi, stochLength))
|
|
770
|
+
* / (highest(rsi, stochLength) − lowest(rsi, stochLength)) ;
|
|
771
|
+
* k = sma(kRaw, kSmoothing) ;
|
|
772
|
+
* d = sma(k, dSmoothing)
|
|
773
|
+
* @since 0.2
|
|
774
|
+
* @stable
|
|
775
|
+
* @example
|
|
776
|
+
* const s = ta.stochRsi(bar.close);
|
|
777
|
+
* plot(s.k);
|
|
778
|
+
* plot(s.d);
|
|
779
|
+
*/
|
|
780
|
+
export type StochRsiResult = Readonly<{
|
|
781
|
+
k: Series<number>;
|
|
782
|
+
d: Series<number>;
|
|
783
|
+
}>;
|
|
784
|
+
/**
|
|
785
|
+
* Options bag for `ta.kst` (Know Sure Thing). Defaults match Pring's
|
|
786
|
+
* canonical settings `(10, 15, 20, 30, 10, 10, 10, 15, 9)`. Source is
|
|
787
|
+
* positional (`ta.kst(source, opts?)`). `offset` shifts the read window
|
|
788
|
+
* backwards (PLAN.md §9.1 — accepted on the surface).
|
|
789
|
+
*
|
|
790
|
+
* @formula N/A — see `ta.kst` JSDoc
|
|
791
|
+
* @since 0.2
|
|
792
|
+
* @stable
|
|
793
|
+
* @example
|
|
794
|
+
* const opts: KstOpts = { roc1Length: 10, roc2Length: 15, roc3Length: 20, roc4Length: 30 };
|
|
795
|
+
*/
|
|
796
|
+
export type KstOpts = Readonly<{
|
|
797
|
+
roc1Length?: number;
|
|
798
|
+
roc2Length?: number;
|
|
799
|
+
roc3Length?: number;
|
|
800
|
+
roc4Length?: number;
|
|
801
|
+
roc1Smooth?: number;
|
|
802
|
+
roc2Smooth?: number;
|
|
803
|
+
roc3Smooth?: number;
|
|
804
|
+
roc4Smooth?: number;
|
|
805
|
+
signalLength?: number;
|
|
806
|
+
offset?: number;
|
|
807
|
+
}>;
|
|
808
|
+
/**
|
|
809
|
+
* The two-series result of `ta.kst` — the KST line (weighted sum of
|
|
810
|
+
* four smoothed percentage ROCs) and its SMA signal line.
|
|
811
|
+
* `primarySeriesKey: "kst"` (recorded in `TA_REGISTRY_METADATA`).
|
|
812
|
+
*
|
|
813
|
+
* @formula rN = sma(rocN(source, rocNLength), rocNSmooth) for N in 1..4 ;
|
|
814
|
+
* kst = r1 + 2·r2 + 3·r3 + 4·r4 ; NaN if any rN NaN ;
|
|
815
|
+
* signal = sma(kst, signalLength)
|
|
816
|
+
* @since 0.2
|
|
817
|
+
* @stable
|
|
818
|
+
* @example
|
|
819
|
+
* const k = ta.kst(bar.close);
|
|
820
|
+
* plot(k.kst);
|
|
821
|
+
* plot(k.signal);
|
|
822
|
+
*/
|
|
823
|
+
export type KstResult = Readonly<{
|
|
824
|
+
kst: Series<number>;
|
|
825
|
+
signal: Series<number>;
|
|
826
|
+
}>;
|
|
827
|
+
/**
|
|
828
|
+
* Options bag for `ta.fisher`. `length` is positional on the call
|
|
829
|
+
* (`ta.fisher(length, opts?)`); the bag carries only the universal
|
|
830
|
+
* `offset` (PLAN.md §9.1 — accepted on the surface).
|
|
831
|
+
*
|
|
832
|
+
* @formula N/A — see `ta.fisher` JSDoc
|
|
833
|
+
* @since 0.2
|
|
834
|
+
* @stable
|
|
835
|
+
* @example
|
|
836
|
+
* const opts: FisherOpts = { offset: 0 };
|
|
837
|
+
*/
|
|
838
|
+
export type FisherOpts = Readonly<{
|
|
839
|
+
offset?: number;
|
|
840
|
+
}>;
|
|
841
|
+
/**
|
|
842
|
+
* The two-series result of `ta.fisher` — the Fisher Transform line and
|
|
843
|
+
* its 1-bar-lagged `trigger` (the prior bar's Fisher value). Both are
|
|
844
|
+
* unbounded; `yDomain: { kind: "auto" }`. The first bar's `trigger` is
|
|
845
|
+
* NaN (no prior Fisher).
|
|
846
|
+
*
|
|
847
|
+
* `primarySeriesKey: "fisher"` (recorded in `TA_REGISTRY_METADATA`).
|
|
848
|
+
*
|
|
849
|
+
* @formula mid = (high + low) / 2 ;
|
|
850
|
+
* normalised = flatRange ? 0 : (mid − lowest(mid, length)) / (highest − lowest) − 0.5 ;
|
|
851
|
+
* x = 0.66 · normalised + 0.67 · prevX ; NaN at fisher if |x| ≥ 1 ;
|
|
852
|
+
* fisher = 0.5 · ln((1 + x) / (1 − x)) + 0.5 · prevFisher ;
|
|
853
|
+
* trigger[t] = prevFisher (the value of fisher before this close)
|
|
854
|
+
* @since 0.2
|
|
855
|
+
* @stable
|
|
856
|
+
* @example
|
|
857
|
+
* const f = ta.fisher(9);
|
|
858
|
+
* plot(f.fisher);
|
|
859
|
+
* plot(f.trigger);
|
|
860
|
+
*/
|
|
861
|
+
export type FisherResult = Readonly<{
|
|
862
|
+
fisher: Series<number>;
|
|
863
|
+
trigger: Series<number>;
|
|
864
|
+
}>;
|
|
865
|
+
/**
|
|
866
|
+
* Options bag for `ta.klinger` (Klinger Volume Oscillator). Defaults
|
|
867
|
+
* `(fastLength=34, slowLength=55, signalLength=13)` match invinite.
|
|
868
|
+
* `offset` shifts the read window backwards (PLAN.md §9.1 — accepted
|
|
869
|
+
* on the surface).
|
|
870
|
+
*
|
|
871
|
+
* @formula N/A — see `ta.klinger` JSDoc
|
|
872
|
+
* @since 0.2
|
|
873
|
+
* @stable
|
|
874
|
+
* @example
|
|
875
|
+
* const opts: KlingerOpts = { fastLength: 34, slowLength: 55, signalLength: 13 };
|
|
876
|
+
*/
|
|
877
|
+
export type KlingerOpts = Readonly<{
|
|
878
|
+
fastLength?: number;
|
|
879
|
+
slowLength?: number;
|
|
880
|
+
signalLength?: number;
|
|
881
|
+
offset?: number;
|
|
882
|
+
}>;
|
|
883
|
+
/**
|
|
884
|
+
* The two-series result of `ta.klinger` — the Klinger Oscillator line
|
|
885
|
+
* (`EMA(fast)(vf) − EMA(slow)(vf)` over the Volume Force accumulator)
|
|
886
|
+
* and its `EMA(signalLength)(klinger)` signal. `primarySeriesKey:
|
|
887
|
+
* "klinger"` (recorded in `TA_REGISTRY_METADATA`).
|
|
888
|
+
*
|
|
889
|
+
* @formula trend = sign(hlc − prevHlc) carried forward on equality ;
|
|
890
|
+
* cm = trend === prevTrend ? prevCm + dm : prevDm + dm ;
|
|
891
|
+
* vf = volume · |2·(dm/cm − 1)| · trend · 100 ; 0 on cm = 0 ;
|
|
892
|
+
* klinger = ema(vf, fastLength) − ema(vf, slowLength) ;
|
|
893
|
+
* signal = ema(klinger, signalLength)
|
|
894
|
+
* @since 0.2
|
|
895
|
+
* @stable
|
|
896
|
+
* @example
|
|
897
|
+
* const k = ta.klinger();
|
|
898
|
+
* plot(k.klinger);
|
|
899
|
+
* plot(k.signal);
|
|
900
|
+
*/
|
|
901
|
+
export type KlingerResult = Readonly<{
|
|
902
|
+
klinger: Series<number>;
|
|
903
|
+
signal: Series<number>;
|
|
904
|
+
}>;
|
|
905
|
+
/**
|
|
906
|
+
* Options bag for `ta.rvgi` (Relative Vigor Index). `length` is the SMA
|
|
907
|
+
* smoothing of the 4-bar weighted numerator / denominator (default
|
|
908
|
+
* `10`). `offset` shifts the read window backwards (PLAN.md §9.1 —
|
|
909
|
+
* accepted on the surface).
|
|
910
|
+
*
|
|
911
|
+
* @formula N/A — see `ta.rvgi` JSDoc
|
|
912
|
+
* @since 0.2
|
|
913
|
+
* @stable
|
|
914
|
+
* @example
|
|
915
|
+
* const opts: RvgiOpts = { length: 10 };
|
|
916
|
+
*/
|
|
917
|
+
export type RvgiOpts = Readonly<{
|
|
918
|
+
length?: number;
|
|
919
|
+
offset?: number;
|
|
920
|
+
}>;
|
|
921
|
+
/**
|
|
922
|
+
* The two-series result of `ta.rvgi` — the Relative Vigor Index line
|
|
923
|
+
* (`SMA(numerator, length) / SMA(denominator, length)`) and its 4-bar
|
|
924
|
+
* weighted signal. `primarySeriesKey: "rvgi"` (recorded in
|
|
925
|
+
* `TA_REGISTRY_METADATA`).
|
|
926
|
+
*
|
|
927
|
+
* @formula num = (co0 + 2·co1 + 2·co2 + co3) / 6 where coN = close − open ;
|
|
928
|
+
* den = (hl0 + 2·hl1 + 2·hl2 + hl3) / 6 where hlN = high − low ;
|
|
929
|
+
* rvgi = sma(num, length) / sma(den, length) ; NaN on flat den ;
|
|
930
|
+
* signal = (rvgi[0] + 2·rvgi[1] + 2·rvgi[2] + rvgi[3]) / 6
|
|
931
|
+
* @since 0.2
|
|
932
|
+
* @stable
|
|
933
|
+
* @example
|
|
934
|
+
* const r = ta.rvgi();
|
|
935
|
+
* plot(r.rvgi);
|
|
936
|
+
* plot(r.signal);
|
|
937
|
+
*/
|
|
938
|
+
export type RvgiResult = Readonly<{
|
|
939
|
+
rvgi: Series<number>;
|
|
940
|
+
signal: Series<number>;
|
|
941
|
+
}>;
|
|
942
|
+
/**
|
|
943
|
+
* Options bag for `ta.aroon`. `offset` shifts the read window backwards
|
|
944
|
+
* (PLAN.md §9.1). `outputs` carries per-output styling hints that
|
|
945
|
+
* downstream `plot()` callsites can lift defaults from; the runtime
|
|
946
|
+
* itself ignores it in Phase 2 — script-author `plot(a.up,
|
|
947
|
+
* { lineStyle })` is the styling seam.
|
|
948
|
+
*
|
|
949
|
+
* @formula N/A — see `ta.aroon` JSDoc
|
|
950
|
+
* @since 0.2
|
|
951
|
+
* @stable
|
|
952
|
+
* @example
|
|
953
|
+
* const opts: AroonOpts = { offset: 0 };
|
|
954
|
+
*/
|
|
955
|
+
export type AroonOpts = Readonly<{
|
|
956
|
+
offset?: number;
|
|
957
|
+
outputs?: Readonly<Record<"up" | "down", {
|
|
958
|
+
lineStyle?: PlotLineStyle;
|
|
959
|
+
}>>;
|
|
960
|
+
}>;
|
|
961
|
+
/**
|
|
962
|
+
* Options bag for `ta.aroonOsc`. `lineStyle` is a forward-compat
|
|
963
|
+
* plot-styling hint; the runtime itself reads `offset` only.
|
|
964
|
+
*
|
|
965
|
+
* @formula N/A — see `ta.aroonOsc` JSDoc
|
|
966
|
+
* @since 0.2
|
|
967
|
+
* @stable
|
|
968
|
+
* @example
|
|
969
|
+
* const opts: AroonOscOpts = { offset: 0 };
|
|
970
|
+
*/
|
|
971
|
+
export type AroonOscOpts = Readonly<{
|
|
972
|
+
offset?: number;
|
|
973
|
+
lineStyle?: PlotLineStyle;
|
|
974
|
+
}>;
|
|
975
|
+
/**
|
|
976
|
+
* Options bag for `ta.median` (rolling median). Mirrors {@link WmaOpts}.
|
|
977
|
+
*
|
|
978
|
+
* @formula N/A — see `ta.median` JSDoc
|
|
979
|
+
* @since 0.2
|
|
980
|
+
* @stable
|
|
981
|
+
* @example
|
|
982
|
+
* const opts: MedianOpts = { offset: 0 };
|
|
983
|
+
*/
|
|
984
|
+
export type MedianOpts = Readonly<{
|
|
985
|
+
offset?: number;
|
|
986
|
+
lineStyle?: PlotLineStyle;
|
|
987
|
+
}>;
|
|
988
|
+
/**
|
|
989
|
+
* Options bag for `ta.adr` (Average Daily Range). `length` defaults to
|
|
990
|
+
* `14` — Pine / TradingView canonical. `offset` shifts the read window
|
|
991
|
+
* backwards; `lineStyle` is a forward-compat plot-styling hint.
|
|
992
|
+
*
|
|
993
|
+
* @formula N/A — see `ta.adr` JSDoc
|
|
994
|
+
* @since 0.2
|
|
995
|
+
* @stable
|
|
996
|
+
* @example
|
|
997
|
+
* const opts: AdrOpts = { length: 14 };
|
|
998
|
+
*/
|
|
999
|
+
export type AdrOpts = Readonly<{
|
|
1000
|
+
length?: number;
|
|
1001
|
+
offset?: number;
|
|
1002
|
+
lineStyle?: PlotLineStyle;
|
|
1003
|
+
}>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Options bag for `ta.ulcerIndex`. Mirrors {@link WmaOpts}.
|
|
1006
|
+
*
|
|
1007
|
+
* @formula N/A — see `ta.ulcerIndex` JSDoc
|
|
1008
|
+
* @since 0.2
|
|
1009
|
+
* @stable
|
|
1010
|
+
* @example
|
|
1011
|
+
* const opts: UlcerIndexOpts = { offset: 0 };
|
|
1012
|
+
*/
|
|
1013
|
+
export type UlcerIndexOpts = Readonly<{
|
|
1014
|
+
offset?: number;
|
|
1015
|
+
lineStyle?: PlotLineStyle;
|
|
1016
|
+
}>;
|
|
1017
|
+
/**
|
|
1018
|
+
* Options bag for `ta.vol`. `offset` shifts the read window backwards
|
|
1019
|
+
* (PLAN.md §9.1 universal offset). `ta.vol` is a pass-through of
|
|
1020
|
+
* `bar.volume`; the opts bag exists so authors can attach the
|
|
1021
|
+
* universal `offset` without an extra wrapper.
|
|
1022
|
+
*
|
|
1023
|
+
* @formula N/A — see `ta.vol` JSDoc
|
|
1024
|
+
* @since 0.2
|
|
1025
|
+
* @stable
|
|
1026
|
+
* @example
|
|
1027
|
+
* const opts: VolOpts = { offset: 0 };
|
|
1028
|
+
*/
|
|
1029
|
+
export type VolOpts = Readonly<{
|
|
1030
|
+
offset?: number;
|
|
1031
|
+
}>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Options bag for `ta.vwap`. `source` selects the per-bar price
|
|
1034
|
+
* (default `"hlc3"` per Pine). `offset` shifts the read window
|
|
1035
|
+
* backwards (PLAN.md §9.1).
|
|
1036
|
+
*
|
|
1037
|
+
* @formula vwap = Σ(source · volume) / Σ(volume) per session window
|
|
1038
|
+
* @since 0.2
|
|
1039
|
+
* @stable
|
|
1040
|
+
* @example
|
|
1041
|
+
* const opts: VwapOpts = { source: "hlc3" };
|
|
1042
|
+
*/
|
|
1043
|
+
export type VwapOpts = Readonly<{
|
|
1044
|
+
source?: "hlc3" | "close" | "hl2" | "ohlc4" | "hlcc4";
|
|
1045
|
+
offset?: number;
|
|
1046
|
+
}>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Options bag for `ta.anchoredVwap`. Mirrors {@link VwapOpts}; the
|
|
1049
|
+
* `anchorTime` (a UTC millisecond epoch the script author hard-codes)
|
|
1050
|
+
* is passed positionally, not via this bag.
|
|
1051
|
+
*
|
|
1052
|
+
* @formula vwap_anchored = Σ_{t ≥ anchor}(source · volume) / Σ_{t ≥ anchor}(volume)
|
|
1053
|
+
* @since 0.2
|
|
1054
|
+
* @stable
|
|
1055
|
+
* @example
|
|
1056
|
+
* const opts: AnchoredVwapOpts = { source: "hlc3" };
|
|
1057
|
+
*/
|
|
1058
|
+
export type AnchoredVwapOpts = Readonly<{
|
|
1059
|
+
source?: "hlc3" | "close" | "hl2" | "ohlc4" | "hlcc4";
|
|
1060
|
+
offset?: number;
|
|
1061
|
+
}>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Options bag for `ta.visibleRangeVolumeProfile`. `rowSize` selects
|
|
1064
|
+
* the number of price rows when positive; `0` / omitted falls back to
|
|
1065
|
+
* the runtime's automatic row count. `valueAreaPct` accepts either
|
|
1066
|
+
* a fraction (`0.7`) or percentage (`70`). `bucketColor` is copied to
|
|
1067
|
+
* each emitted horizontal-histogram bucket.
|
|
1068
|
+
*
|
|
1069
|
+
* @formula N/A — see `ta.visibleRangeVolumeProfile` JSDoc
|
|
1070
|
+
* @since 0.5
|
|
1071
|
+
* @stable
|
|
1072
|
+
* @example
|
|
1073
|
+
* const opts: VisibleRangeVolumeProfileOpts = {
|
|
1074
|
+
* rowSize: 24,
|
|
1075
|
+
* valueAreaPct: 0.7,
|
|
1076
|
+
* bucketColor: "#90caf9",
|
|
1077
|
+
* };
|
|
1078
|
+
*/
|
|
1079
|
+
export type VisibleRangeVolumeProfileOpts = Readonly<{
|
|
1080
|
+
rowSize?: number;
|
|
1081
|
+
valueAreaPct?: number;
|
|
1082
|
+
offset?: number;
|
|
1083
|
+
bucketColor?: string;
|
|
1084
|
+
}>;
|
|
1085
|
+
/**
|
|
1086
|
+
* Multi-output result from `ta.visibleRangeVolumeProfile`.
|
|
1087
|
+
*
|
|
1088
|
+
* @formula POC / VAH / VAL from the visible-range volume-profile
|
|
1089
|
+
* bucket set.
|
|
1090
|
+
* @since 0.5
|
|
1091
|
+
* @stable
|
|
1092
|
+
* @example
|
|
1093
|
+
* declare const vp: VisibleRangeVolumeProfileResult;
|
|
1094
|
+
* const poc = vp.poc.current;
|
|
1095
|
+
*/
|
|
1096
|
+
export type VisibleRangeVolumeProfileResult = Readonly<{
|
|
1097
|
+
poc: Series<number>;
|
|
1098
|
+
valHigh: Series<number>;
|
|
1099
|
+
valLow: Series<number>;
|
|
1100
|
+
buckets: ReadonlyArray<Readonly<{
|
|
1101
|
+
price: number;
|
|
1102
|
+
volume: number;
|
|
1103
|
+
color?: string;
|
|
1104
|
+
}>>;
|
|
1105
|
+
}>;
|
|
1106
|
+
/**
|
|
1107
|
+
* Options bag for `ta.anchoredVolumeProfile`. `anchor` is a UTC
|
|
1108
|
+
* millisecond epoch, typically resolved from
|
|
1109
|
+
* `input.time(..., { pickFromChart: true })`; `rowSize` selects the
|
|
1110
|
+
* number of price rows when positive; `0` / omitted falls back to the
|
|
1111
|
+
* runtime's automatic row count. `valueAreaPct` accepts either a
|
|
1112
|
+
* fraction (`0.7`) or percentage (`70`). `bucketColor` is copied to
|
|
1113
|
+
* each emitted horizontal-histogram bucket.
|
|
1114
|
+
*
|
|
1115
|
+
* @formula N/A — see `ta.anchoredVolumeProfile` JSDoc
|
|
1116
|
+
* @since 0.5
|
|
1117
|
+
* @stable
|
|
1118
|
+
* @example
|
|
1119
|
+
* const opts: AnchoredVolumeProfileOpts = {
|
|
1120
|
+
* anchor: 1_700_000_000_000,
|
|
1121
|
+
* rowSize: 24,
|
|
1122
|
+
* valueAreaPct: 0.7,
|
|
1123
|
+
* };
|
|
1124
|
+
*/
|
|
1125
|
+
export type AnchoredVolumeProfileOpts = Readonly<{
|
|
1126
|
+
anchor: Time;
|
|
1127
|
+
rowSize?: number;
|
|
1128
|
+
valueAreaPct?: number;
|
|
1129
|
+
offset?: number;
|
|
1130
|
+
bucketColor?: string;
|
|
1131
|
+
}>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Multi-output result from `ta.anchoredVolumeProfile`.
|
|
1134
|
+
*
|
|
1135
|
+
* @formula POC / VAH / VAL from the anchor→current volume-profile
|
|
1136
|
+
* bucket set.
|
|
1137
|
+
* @since 0.5
|
|
1138
|
+
* @stable
|
|
1139
|
+
* @example
|
|
1140
|
+
* declare const vp: AnchoredVolumeProfileResult;
|
|
1141
|
+
* const buckets = vp.buckets;
|
|
1142
|
+
*/
|
|
1143
|
+
export type AnchoredVolumeProfileResult = Readonly<{
|
|
1144
|
+
poc: Series<number>;
|
|
1145
|
+
valHigh: Series<number>;
|
|
1146
|
+
valLow: Series<number>;
|
|
1147
|
+
buckets: ReadonlyArray<Readonly<{
|
|
1148
|
+
price: number;
|
|
1149
|
+
volume: number;
|
|
1150
|
+
color?: string;
|
|
1151
|
+
}>>;
|
|
1152
|
+
}>;
|
|
1153
|
+
/**
|
|
1154
|
+
* Options bag for `ta.sessionVolumeProfile`. `sessionStart` is an
|
|
1155
|
+
* explicit UTC millisecond boundary override; omitted values derive the
|
|
1156
|
+
* current session from `syminfo.session` when adapters provide it, or
|
|
1157
|
+
* UTC-day fallback boundaries otherwise. `rowSize`, `valueAreaPct`,
|
|
1158
|
+
* `offset`, and `bucketColor` mirror the other volume-profile primitives.
|
|
1159
|
+
*
|
|
1160
|
+
* @formula N/A — see `ta.sessionVolumeProfile` JSDoc
|
|
1161
|
+
* @since 0.5
|
|
1162
|
+
* @stable
|
|
1163
|
+
* @example
|
|
1164
|
+
* const opts: SessionVolumeProfileOpts = {
|
|
1165
|
+
* rowSize: 24,
|
|
1166
|
+
* valueAreaPct: 0.7,
|
|
1167
|
+
* sessionStart: 1_700_000_000_000,
|
|
1168
|
+
* };
|
|
1169
|
+
*/
|
|
1170
|
+
export type SessionVolumeProfileOpts = Readonly<{
|
|
1171
|
+
rowSize?: number;
|
|
1172
|
+
valueAreaPct?: number;
|
|
1173
|
+
offset?: number;
|
|
1174
|
+
bucketColor?: string;
|
|
1175
|
+
sessionStart?: Time;
|
|
1176
|
+
}>;
|
|
1177
|
+
/**
|
|
1178
|
+
* Multi-output result from `ta.sessionVolumeProfile`.
|
|
1179
|
+
*
|
|
1180
|
+
* @formula POC / VAH / VAL from the current-session volume-profile
|
|
1181
|
+
* bucket set.
|
|
1182
|
+
* @since 0.5
|
|
1183
|
+
* @stable
|
|
1184
|
+
* @example
|
|
1185
|
+
* declare const vp: SessionVolumeProfileResult;
|
|
1186
|
+
* const poc = vp.poc.current;
|
|
1187
|
+
*/
|
|
1188
|
+
export type SessionVolumeProfileResult = Readonly<{
|
|
1189
|
+
poc: Series<number>;
|
|
1190
|
+
valHigh: Series<number>;
|
|
1191
|
+
valLow: Series<number>;
|
|
1192
|
+
buckets: ReadonlyArray<Readonly<{
|
|
1193
|
+
price: number;
|
|
1194
|
+
volume: number;
|
|
1195
|
+
color?: string;
|
|
1196
|
+
}>>;
|
|
1197
|
+
}>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Options bag for `ta.fixedRangeVolumeProfile`. `from` and `to` are
|
|
1200
|
+
* UTC millisecond anchors, typically resolved from two
|
|
1201
|
+
* `input.time(..., { pickFromChart: true })` inputs. `from > to`
|
|
1202
|
+
* is invalid and diagnoses at runtime; `from === to` is a
|
|
1203
|
+
* single-bar window.
|
|
1204
|
+
*
|
|
1205
|
+
* @formula N/A — see `ta.fixedRangeVolumeProfile` JSDoc
|
|
1206
|
+
* @since 0.5
|
|
1207
|
+
* @stable
|
|
1208
|
+
* @example
|
|
1209
|
+
* const opts: FixedRangeVolumeProfileOpts = {
|
|
1210
|
+
* from: 1_700_000_000_000,
|
|
1211
|
+
* to: 1_700_060_000_000,
|
|
1212
|
+
* rowSize: 24,
|
|
1213
|
+
* };
|
|
1214
|
+
*/
|
|
1215
|
+
export type FixedRangeVolumeProfileOpts = Readonly<{
|
|
1216
|
+
from: Time;
|
|
1217
|
+
to: Time;
|
|
1218
|
+
rowSize?: number;
|
|
1219
|
+
valueAreaPct?: number;
|
|
1220
|
+
offset?: number;
|
|
1221
|
+
bucketColor?: string;
|
|
1222
|
+
}>;
|
|
1223
|
+
/**
|
|
1224
|
+
* Multi-output result from `ta.fixedRangeVolumeProfile`.
|
|
1225
|
+
*
|
|
1226
|
+
* @formula POC / VAH / VAL from the fixed-range volume-profile
|
|
1227
|
+
* bucket set.
|
|
1228
|
+
* @since 0.5
|
|
1229
|
+
* @stable
|
|
1230
|
+
* @example
|
|
1231
|
+
* declare const vp: FixedRangeVolumeProfileResult;
|
|
1232
|
+
* const buckets = vp.buckets;
|
|
1233
|
+
*/
|
|
1234
|
+
export type FixedRangeVolumeProfileResult = Readonly<{
|
|
1235
|
+
poc: Series<number>;
|
|
1236
|
+
valHigh: Series<number>;
|
|
1237
|
+
valLow: Series<number>;
|
|
1238
|
+
buckets: ReadonlyArray<Readonly<{
|
|
1239
|
+
price: number;
|
|
1240
|
+
volume: number;
|
|
1241
|
+
color?: string;
|
|
1242
|
+
}>>;
|
|
1243
|
+
}>;
|
|
1244
|
+
/**
|
|
1245
|
+
* Options bag for `ta.obv` (On-Balance Volume). `offset` shifts the
|
|
1246
|
+
* read window backwards (PLAN.md §9.1 universal offset). `lineStyle`
|
|
1247
|
+
* is a forward-compat plot-styling hint surfaced for §9.1 ergonomics —
|
|
1248
|
+
* not consumed by the primitive itself.
|
|
1249
|
+
*
|
|
1250
|
+
* @formula N/A — see `ta.obv` JSDoc
|
|
1251
|
+
* @since 0.2
|
|
1252
|
+
* @stable
|
|
1253
|
+
* @example
|
|
1254
|
+
* const opts: ObvOpts = { offset: 0 };
|
|
1255
|
+
*/
|
|
1256
|
+
export type ObvOpts = Readonly<{
|
|
1257
|
+
offset?: number;
|
|
1258
|
+
lineStyle?: PlotLineStyle;
|
|
1259
|
+
}>;
|
|
1260
|
+
/**
|
|
1261
|
+
* Options bag for `ta.adl` (Accumulation Distribution Line). Mirrors
|
|
1262
|
+
* {@link ObvOpts}.
|
|
1263
|
+
*
|
|
1264
|
+
* @formula N/A — see `ta.adl` JSDoc
|
|
1265
|
+
* @since 0.2
|
|
1266
|
+
* @stable
|
|
1267
|
+
* @example
|
|
1268
|
+
* const opts: AdlOpts = { offset: 0 };
|
|
1269
|
+
*/
|
|
1270
|
+
export type AdlOpts = Readonly<{
|
|
1271
|
+
offset?: number;
|
|
1272
|
+
lineStyle?: PlotLineStyle;
|
|
1273
|
+
}>;
|
|
1274
|
+
/**
|
|
1275
|
+
* Options bag for `ta.bop` (Balance of Power). Mirrors {@link ObvOpts}.
|
|
1276
|
+
*
|
|
1277
|
+
* @formula N/A — see `ta.bop` JSDoc
|
|
1278
|
+
* @since 0.2
|
|
1279
|
+
* @stable
|
|
1280
|
+
* @example
|
|
1281
|
+
* const opts: BopOpts = { offset: 0 };
|
|
1282
|
+
*/
|
|
1283
|
+
export type BopOpts = Readonly<{
|
|
1284
|
+
offset?: number;
|
|
1285
|
+
lineStyle?: PlotLineStyle;
|
|
1286
|
+
}>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Options bag for `ta.cmf` (Chaikin Money Flow). `length` is positional
|
|
1289
|
+
* on the call (Pine-canonical `ta.cmf(length)`), so the opts bag carries
|
|
1290
|
+
* only the universal `offset` + the styling hint.
|
|
1291
|
+
*
|
|
1292
|
+
* @formula N/A — see `ta.cmf` JSDoc
|
|
1293
|
+
* @since 0.2
|
|
1294
|
+
* @stable
|
|
1295
|
+
* @example
|
|
1296
|
+
* const opts: CmfOpts = { offset: 0 };
|
|
1297
|
+
*/
|
|
1298
|
+
export type CmfOpts = Readonly<{
|
|
1299
|
+
offset?: number;
|
|
1300
|
+
lineStyle?: PlotLineStyle;
|
|
1301
|
+
}>;
|
|
1302
|
+
/**
|
|
1303
|
+
* Options bag for `ta.chaikinOsc` (Chaikin Oscillator). Defaults
|
|
1304
|
+
* match Pine / invinite: `fastLength = 3`, `slowLength = 10`. `offset`
|
|
1305
|
+
* shifts the read window backwards (PLAN.md §9.1 universal offset).
|
|
1306
|
+
*
|
|
1307
|
+
* @formula N/A — see `ta.chaikinOsc` JSDoc
|
|
1308
|
+
* @since 0.2
|
|
1309
|
+
* @stable
|
|
1310
|
+
* @example
|
|
1311
|
+
* const opts: ChaikinOscOpts = { fastLength: 3, slowLength: 10 };
|
|
1312
|
+
*/
|
|
1313
|
+
export type ChaikinOscOpts = Readonly<{
|
|
1314
|
+
fastLength?: number;
|
|
1315
|
+
slowLength?: number;
|
|
1316
|
+
offset?: number;
|
|
1317
|
+
}>;
|
|
1318
|
+
/**
|
|
1319
|
+
* Options bag for `ta.mfi` (Money Flow Index). `length` is positional
|
|
1320
|
+
* on the call (Pine-canonical `ta.mfi(length)`), so the opts bag carries
|
|
1321
|
+
* only the universal `offset` + the styling hint.
|
|
1322
|
+
*
|
|
1323
|
+
* @formula N/A — see `ta.mfi` JSDoc
|
|
1324
|
+
* @since 0.2
|
|
1325
|
+
* @stable
|
|
1326
|
+
* @example
|
|
1327
|
+
* const opts: MfiOpts = { offset: 0 };
|
|
1328
|
+
*/
|
|
1329
|
+
export type MfiOpts = Readonly<{
|
|
1330
|
+
offset?: number;
|
|
1331
|
+
lineStyle?: PlotLineStyle;
|
|
1332
|
+
}>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Options bag for `ta.netVolume` (signed-volume cumulative — math
|
|
1335
|
+
* equals `ta.obv`, exposed separately for naming parity with Pine /
|
|
1336
|
+
* invinite). Mirrors {@link ObvOpts}.
|
|
1337
|
+
*
|
|
1338
|
+
* @formula N/A — see `ta.netVolume` JSDoc
|
|
1339
|
+
* @since 0.2
|
|
1340
|
+
* @stable
|
|
1341
|
+
* @example
|
|
1342
|
+
* const opts: NetVolumeOpts = { offset: 0 };
|
|
1343
|
+
*/
|
|
1344
|
+
export type NetVolumeOpts = Readonly<{
|
|
1345
|
+
offset?: number;
|
|
1346
|
+
lineStyle?: PlotLineStyle;
|
|
1347
|
+
}>;
|
|
1348
|
+
/**
|
|
1349
|
+
* Options bag for `ta.pvo` (Percentage Volume Oscillator). MACD-shape
|
|
1350
|
+
* applied to `bar.volume`. Defaults match Appel-era `12 / 26 / 9`
|
|
1351
|
+
* (mirrors `ta.ppo` / `ta.macd`). `offset` shifts all three outputs
|
|
1352
|
+
* (`pvo`, `signal`, `hist`) in lockstep per the universal `opts.offset`
|
|
1353
|
+
* convention (PLAN.md §9.1).
|
|
1354
|
+
*
|
|
1355
|
+
* @formula N/A — see `ta.pvo` JSDoc
|
|
1356
|
+
* @since 0.2
|
|
1357
|
+
* @stable
|
|
1358
|
+
* @example
|
|
1359
|
+
* const opts: PvoOpts = { fastLength: 12, slowLength: 26, signalLength: 9 };
|
|
1360
|
+
*/
|
|
1361
|
+
export type PvoOpts = Readonly<{
|
|
1362
|
+
fastLength?: number;
|
|
1363
|
+
slowLength?: number;
|
|
1364
|
+
signalLength?: number;
|
|
1365
|
+
offset?: number;
|
|
1366
|
+
}>;
|
|
1367
|
+
/**
|
|
1368
|
+
* The three-series result of `ta.pvo` — the PVO line, its signal
|
|
1369
|
+
* line, and the histogram of their difference. All three Series are
|
|
1370
|
+
* updated in lock-step with `bar.volume`. `primarySeriesKey: "pvo"`
|
|
1371
|
+
* is recorded in `TA_REGISTRY_METADATA`.
|
|
1372
|
+
*
|
|
1373
|
+
* @formula pvo = 100 · (ema(volume, fast) − ema(volume, slow)) / ema(volume, slow) ;
|
|
1374
|
+
* signal = ema(pvo, signalLength) ;
|
|
1375
|
+
* hist = pvo − signal
|
|
1376
|
+
* @since 0.2
|
|
1377
|
+
* @stable
|
|
1378
|
+
* @example
|
|
1379
|
+
* const p = ta.pvo();
|
|
1380
|
+
* plot(p.pvo); plot(p.signal); plot(p.hist);
|
|
1381
|
+
*/
|
|
1382
|
+
export type PvoResult = Readonly<{
|
|
1383
|
+
pvo: Series<number>;
|
|
1384
|
+
signal: Series<number>;
|
|
1385
|
+
hist: Series<number>;
|
|
1386
|
+
}>;
|
|
1387
|
+
/**
|
|
1388
|
+
* Options bag for `ta.pvt` (Price Volume Trend). Cumulative
|
|
1389
|
+
* `volume · (close − prevClose) / prevClose`. `offset` shifts the
|
|
1390
|
+
* read window backwards (PLAN.md §9.1 universal offset). `lineStyle`
|
|
1391
|
+
* is a forward-compat plot-styling hint surfaced for §9.1 ergonomics —
|
|
1392
|
+
* not consumed by the primitive itself.
|
|
1393
|
+
*
|
|
1394
|
+
* @formula N/A — see `ta.pvt` JSDoc
|
|
1395
|
+
* @since 0.2
|
|
1396
|
+
* @stable
|
|
1397
|
+
* @example
|
|
1398
|
+
* const opts: PvtOpts = { offset: 0 };
|
|
1399
|
+
*/
|
|
1400
|
+
export type PvtOpts = Readonly<{
|
|
1401
|
+
offset?: number;
|
|
1402
|
+
lineStyle?: PlotLineStyle;
|
|
1403
|
+
}>;
|
|
1404
|
+
/**
|
|
1405
|
+
* Options bag for `ta.eom` (Ease of Movement). `length` is positional
|
|
1406
|
+
* on the call (Pine-canonical `ta.eom(length)`), so the opts bag carries
|
|
1407
|
+
* only the universal `offset` + the styling hint.
|
|
1408
|
+
*
|
|
1409
|
+
* @formula N/A — see `ta.eom` JSDoc
|
|
1410
|
+
* @since 0.2
|
|
1411
|
+
* @stable
|
|
1412
|
+
* @example
|
|
1413
|
+
* const opts: EomOpts = { offset: 0 };
|
|
1414
|
+
*/
|
|
1415
|
+
export type EomOpts = Readonly<{
|
|
1416
|
+
offset?: number;
|
|
1417
|
+
lineStyle?: PlotLineStyle;
|
|
1418
|
+
}>;
|
|
1419
|
+
/**
|
|
1420
|
+
* Options bag for `ta.nvi` (Negative Volume Index). Cumulative `prev ·
|
|
1421
|
+
* (1 + (close − prevClose) / prevClose)` on bars where `volume <
|
|
1422
|
+
* prevVolume`; carry forward otherwise. Seeded at 1000 (pinned by the
|
|
1423
|
+
* runtime's `@anchors seedValue`).
|
|
1424
|
+
*
|
|
1425
|
+
* @formula N/A — see `ta.nvi` JSDoc
|
|
1426
|
+
* @since 0.2
|
|
1427
|
+
* @stable
|
|
1428
|
+
* @example
|
|
1429
|
+
* const opts: NviOpts = { offset: 0 };
|
|
1430
|
+
*/
|
|
1431
|
+
export type NviOpts = Readonly<{
|
|
1432
|
+
offset?: number;
|
|
1433
|
+
lineStyle?: PlotLineStyle;
|
|
1434
|
+
}>;
|
|
1435
|
+
/**
|
|
1436
|
+
* Options bag for `ta.pvi` (Positive Volume Index). Mirror of
|
|
1437
|
+
* {@link NviOpts}; updates only on bars where `volume > prevVolume`.
|
|
1438
|
+
* Seeded at 1000.
|
|
1439
|
+
*
|
|
1440
|
+
* @formula N/A — see `ta.pvi` JSDoc
|
|
1441
|
+
* @since 0.2
|
|
1442
|
+
* @stable
|
|
1443
|
+
* @example
|
|
1444
|
+
* const opts: PviOpts = { offset: 0 };
|
|
1445
|
+
*/
|
|
1446
|
+
export type PviOpts = Readonly<{
|
|
1447
|
+
offset?: number;
|
|
1448
|
+
lineStyle?: PlotLineStyle;
|
|
1449
|
+
}>;
|
|
1450
|
+
/**
|
|
1451
|
+
* The two-series result of `ta.aroon` — the Up line tracking
|
|
1452
|
+
* recency of N-bar highs and the Down line tracking recency of
|
|
1453
|
+
* N-bar lows. Both Series ∈ [0, 100] when defined; the runtime
|
|
1454
|
+
* emits NaN through the `length` warmup window.
|
|
1455
|
+
*
|
|
1456
|
+
* @formula up = 100 · (length − barsSinceHigh) / length ;
|
|
1457
|
+
* down = 100 · (length − barsSinceLow) / length
|
|
1458
|
+
* @since 0.2
|
|
1459
|
+
* @stable
|
|
1460
|
+
* @example
|
|
1461
|
+
* const a = ta.aroon(14);
|
|
1462
|
+
* plot(a.up);
|
|
1463
|
+
* plot(a.down);
|
|
1464
|
+
*/
|
|
1465
|
+
export type AroonResult = Readonly<{
|
|
1466
|
+
up: Series<number>;
|
|
1467
|
+
down: Series<number>;
|
|
1468
|
+
}>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Options bag for `ta.bbPercentB`. `multiplier` scales the BB envelope
|
|
1471
|
+
* (defaults to `2`, mirroring Pine / TradingView). `offset` shifts the
|
|
1472
|
+
* read window backwards (PLAN.md §9.1); `lineStyle` is a forward-compat
|
|
1473
|
+
* plot-styling hint surfaced for §9.1 ergonomics.
|
|
1474
|
+
*
|
|
1475
|
+
* @formula N/A — see `ta.bbPercentB` JSDoc
|
|
1476
|
+
* @since 0.2
|
|
1477
|
+
* @stable
|
|
1478
|
+
* @example
|
|
1479
|
+
* const opts: BbPercentBOpts = { multiplier: 2 };
|
|
1480
|
+
*/
|
|
1481
|
+
export type BbPercentBOpts = Readonly<{
|
|
1482
|
+
multiplier?: number;
|
|
1483
|
+
offset?: number;
|
|
1484
|
+
lineStyle?: PlotLineStyle;
|
|
1485
|
+
}>;
|
|
1486
|
+
/**
|
|
1487
|
+
* Options bag for `ta.bbw`. Mirrors {@link BbPercentBOpts}; the
|
|
1488
|
+
* runtime emits the raw `(upper − lower) / middle` ratio (no ×100
|
|
1489
|
+
* TV-parity scale — multiply in the script for that).
|
|
1490
|
+
*
|
|
1491
|
+
* @formula N/A — see `ta.bbw` JSDoc
|
|
1492
|
+
* @since 0.2
|
|
1493
|
+
* @stable
|
|
1494
|
+
* @example
|
|
1495
|
+
* const opts: BbwOpts = { multiplier: 2 };
|
|
1496
|
+
*/
|
|
1497
|
+
export type BbwOpts = Readonly<{
|
|
1498
|
+
multiplier?: number;
|
|
1499
|
+
offset?: number;
|
|
1500
|
+
lineStyle?: PlotLineStyle;
|
|
1501
|
+
}>;
|
|
1502
|
+
/**
|
|
1503
|
+
* Options bag for `ta.historicalVolatility`. `annualisationFactor`
|
|
1504
|
+
* defaults to `365` (TradingView's "Crypto" / 24-7 convention; use
|
|
1505
|
+
* `252` for trading-day equity series). `offset` shifts the read
|
|
1506
|
+
* window backwards (PLAN.md §9.1).
|
|
1507
|
+
*
|
|
1508
|
+
* @formula N/A — see `ta.historicalVolatility` JSDoc
|
|
1509
|
+
* @anchors annualisationFactor
|
|
1510
|
+
* @since 0.2
|
|
1511
|
+
* @stable
|
|
1512
|
+
* @example
|
|
1513
|
+
* const opts: HvOpts = { annualisationFactor: 252 };
|
|
1514
|
+
*/
|
|
1515
|
+
export type HvOpts = Readonly<{
|
|
1516
|
+
annualisationFactor?: number;
|
|
1517
|
+
offset?: number;
|
|
1518
|
+
lineStyle?: PlotLineStyle;
|
|
1519
|
+
}>;
|
|
1520
|
+
/**
|
|
1521
|
+
* Options bag for `ta.rvi`. `offset` shifts the read window
|
|
1522
|
+
* backwards (PLAN.md §9.1); `lineStyle` is a forward-compat
|
|
1523
|
+
* plot-styling hint surfaced for §9.1 ergonomics.
|
|
1524
|
+
*
|
|
1525
|
+
* @formula N/A — see `ta.rvi` JSDoc
|
|
1526
|
+
* @since 0.2
|
|
1527
|
+
* @stable
|
|
1528
|
+
* @example
|
|
1529
|
+
* const opts: RviOpts = { offset: 0 };
|
|
1530
|
+
*/
|
|
1531
|
+
export type RviOpts = Readonly<{
|
|
1532
|
+
offset?: number;
|
|
1533
|
+
lineStyle?: PlotLineStyle;
|
|
1534
|
+
}>;
|
|
1535
|
+
/**
|
|
1536
|
+
* Options bag for `ta.massIndex`. `emaLength` defaults to `9` (the
|
|
1537
|
+
* inner EMA-of-range and outer EMA-of-EMA window); `sumLength`
|
|
1538
|
+
* defaults to `25` (the rolling-sum-of-ratio window). `offset`
|
|
1539
|
+
* shifts the read window backwards (PLAN.md §9.1).
|
|
1540
|
+
*
|
|
1541
|
+
* @formula N/A — see `ta.massIndex` JSDoc
|
|
1542
|
+
* @since 0.2
|
|
1543
|
+
* @stable
|
|
1544
|
+
* @example
|
|
1545
|
+
* const opts: MassIndexOpts = { emaLength: 9, sumLength: 25 };
|
|
1546
|
+
*/
|
|
1547
|
+
export type MassIndexOpts = Readonly<{
|
|
1548
|
+
emaLength?: number;
|
|
1549
|
+
sumLength?: number;
|
|
1550
|
+
offset?: number;
|
|
1551
|
+
lineStyle?: PlotLineStyle;
|
|
1552
|
+
}>;
|
|
1553
|
+
/**
|
|
1554
|
+
* Options bag for `ta.donchian`. `offset` shifts the read window
|
|
1555
|
+
* backwards (PLAN.md §9.1). `outputs` carries per-output styling
|
|
1556
|
+
* hints downstream `plot()` callsites can lift defaults from; the
|
|
1557
|
+
* runtime itself ignores it in Phase 2.
|
|
1558
|
+
*
|
|
1559
|
+
* @formula N/A — see `ta.donchian` JSDoc
|
|
1560
|
+
* @since 0.2
|
|
1561
|
+
* @stable
|
|
1562
|
+
* @example
|
|
1563
|
+
* const opts: DonchianOpts = { offset: 0 };
|
|
1564
|
+
*/
|
|
1565
|
+
export type DonchianOpts = Readonly<{
|
|
1566
|
+
offset?: number;
|
|
1567
|
+
outputs?: Readonly<Record<"upper" | "middle" | "lower", {
|
|
1568
|
+
lineStyle?: PlotLineStyle;
|
|
1569
|
+
}>>;
|
|
1570
|
+
}>;
|
|
1571
|
+
/**
|
|
1572
|
+
* The three-series result of `ta.donchian` — the upper / middle /
|
|
1573
|
+
* lower bands of the Donchian channel envelope. All three Series are
|
|
1574
|
+
* updated in lock-step with the trailing `length`-bar high/low
|
|
1575
|
+
* window. `primarySeriesKey: "middle"` (recorded in
|
|
1576
|
+
* `TA_REGISTRY_METADATA`).
|
|
1577
|
+
*
|
|
1578
|
+
* @formula upper = highest(high, length) ;
|
|
1579
|
+
* lower = lowest(low, length) ;
|
|
1580
|
+
* middle = (upper + lower) / 2
|
|
1581
|
+
* @since 0.2
|
|
1582
|
+
* @stable
|
|
1583
|
+
* @example
|
|
1584
|
+
* const d = ta.donchian(20);
|
|
1585
|
+
* plot(d.upper);
|
|
1586
|
+
* plot(d.middle);
|
|
1587
|
+
* plot(d.lower);
|
|
1588
|
+
*/
|
|
1589
|
+
export type DonchianResult = Readonly<{
|
|
1590
|
+
upper: Series<number>;
|
|
1591
|
+
middle: Series<number>;
|
|
1592
|
+
lower: Series<number>;
|
|
1593
|
+
}>;
|
|
1594
|
+
/**
|
|
1595
|
+
* Options bag for `ta.keltner` (Keltner Channels). `length` is the
|
|
1596
|
+
* MA / ATR period (default `20`); `multiplier` scales the ATR-derived
|
|
1597
|
+
* band offset from the middle MA (default `2`); `maType` picks the
|
|
1598
|
+
* middle MA kind (default `"ema"` per the Linda Raschke / TradingView
|
|
1599
|
+
* canonical form — Chester Keltner's original used SMA over a hand-
|
|
1600
|
+
* rolled "typical range", but every modern reference defaults to EMA
|
|
1601
|
+
* over close + Wilder ATR). `offset` is the universal bar-shift
|
|
1602
|
+
* (PLAN.md §9.1 — accepted on the surface). `outputs` carries
|
|
1603
|
+
* per-output styling hints downstream `plot()` callsites can lift
|
|
1604
|
+
* defaults from; the runtime itself ignores it in Phase 2.
|
|
1605
|
+
*
|
|
1606
|
+
* @formula N/A — see `ta.keltner` JSDoc
|
|
1607
|
+
* @anchors maType
|
|
1608
|
+
* @since 0.2
|
|
1609
|
+
* @stable
|
|
1610
|
+
* @example
|
|
1611
|
+
* const opts: KeltnerOpts = { length: 20, multiplier: 2, maType: "ema" };
|
|
1612
|
+
*/
|
|
1613
|
+
export type KeltnerOpts = Readonly<{
|
|
1614
|
+
length?: number;
|
|
1615
|
+
multiplier?: number;
|
|
1616
|
+
maType?: MaTypeNoVolume;
|
|
1617
|
+
offset?: number;
|
|
1618
|
+
outputs?: Readonly<Record<"upper" | "middle" | "lower", {
|
|
1619
|
+
lineStyle?: PlotLineStyle;
|
|
1620
|
+
}>>;
|
|
1621
|
+
}>;
|
|
1622
|
+
/**
|
|
1623
|
+
* The three-series result of `ta.keltner` — the upper / middle /
|
|
1624
|
+
* lower bands of the Keltner channel envelope. All three Series
|
|
1625
|
+
* update in lock-step with the source close + ATR. The middle band
|
|
1626
|
+
* is identity-shared with the composed MA sub-primitive's output;
|
|
1627
|
+
* the upper / lower bands are derived per bar.
|
|
1628
|
+
*
|
|
1629
|
+
* @formula middle = MA(close, length, maType) ;
|
|
1630
|
+
* upper = middle + multiplier · atr(length) ;
|
|
1631
|
+
* lower = middle − multiplier · atr(length)
|
|
1632
|
+
* @since 0.2
|
|
1633
|
+
* @stable
|
|
1634
|
+
* @example
|
|
1635
|
+
* const k = ta.keltner({ length: 20, multiplier: 2 });
|
|
1636
|
+
* plot(k.upper);
|
|
1637
|
+
* plot(k.middle);
|
|
1638
|
+
* plot(k.lower);
|
|
1639
|
+
*/
|
|
1640
|
+
export type KeltnerResult = Readonly<{
|
|
1641
|
+
upper: Series<number>;
|
|
1642
|
+
middle: Series<number>;
|
|
1643
|
+
lower: Series<number>;
|
|
1644
|
+
}>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Options bag for `ta.envelope` (price-percent envelope). `length`
|
|
1647
|
+
* is the MA period (default `20`); `percent` is the band offset as a
|
|
1648
|
+
* percentage of the middle MA (default `10`); `maType` picks the MA
|
|
1649
|
+
* kind (default `"sma"`). `offset` is the universal bar-shift
|
|
1650
|
+
* (PLAN.md §9.1 — accepted on the surface).
|
|
1651
|
+
*
|
|
1652
|
+
* @formula N/A — see `ta.envelope` JSDoc
|
|
1653
|
+
* @anchors maType
|
|
1654
|
+
* @since 0.2
|
|
1655
|
+
* @stable
|
|
1656
|
+
* @example
|
|
1657
|
+
* const opts: EnvelopeOpts = { length: 20, percent: 10, maType: "sma" };
|
|
1658
|
+
*/
|
|
1659
|
+
export type EnvelopeOpts = Readonly<{
|
|
1660
|
+
length?: number;
|
|
1661
|
+
percent?: number;
|
|
1662
|
+
maType?: MaTypeNoVolume;
|
|
1663
|
+
offset?: number;
|
|
1664
|
+
}>;
|
|
1665
|
+
/**
|
|
1666
|
+
* The three-series result of `ta.envelope` — the upper / middle /
|
|
1667
|
+
* lower bands of a price-percent envelope around an MA. The middle
|
|
1668
|
+
* band is identity-shared with the composed MA sub-primitive's
|
|
1669
|
+
* output; the bands are a pure multiplicative offset.
|
|
1670
|
+
*
|
|
1671
|
+
* @formula middle = MA(source, length, maType) ;
|
|
1672
|
+
* upper = middle · (1 + percent / 100) ;
|
|
1673
|
+
* lower = middle · (1 − percent / 100)
|
|
1674
|
+
* @since 0.2
|
|
1675
|
+
* @stable
|
|
1676
|
+
* @example
|
|
1677
|
+
* const e = ta.envelope(bar.close, { percent: 10 });
|
|
1678
|
+
* plot(e.upper);
|
|
1679
|
+
* plot(e.middle);
|
|
1680
|
+
* plot(e.lower);
|
|
1681
|
+
*/
|
|
1682
|
+
export type EnvelopeResult = Readonly<{
|
|
1683
|
+
upper: Series<number>;
|
|
1684
|
+
middle: Series<number>;
|
|
1685
|
+
lower: Series<number>;
|
|
1686
|
+
}>;
|
|
1687
|
+
/**
|
|
1688
|
+
* Options bag for `ta.chop` (Choppiness Index). `offset` is the
|
|
1689
|
+
* universal bar-shift (PLAN.md §9.1 — accepted on the surface).
|
|
1690
|
+
* `lineStyle` is a forward-compat plot-styling hint surfaced for
|
|
1691
|
+
* §9.1 ergonomics — not consumed by the primitive itself.
|
|
1692
|
+
*
|
|
1693
|
+
* @formula N/A — see `ta.chop` JSDoc
|
|
1694
|
+
* @since 0.2
|
|
1695
|
+
* @stable
|
|
1696
|
+
* @example
|
|
1697
|
+
* const opts: ChopOpts = { offset: 0 };
|
|
1698
|
+
*/
|
|
1699
|
+
export type ChopOpts = Readonly<{
|
|
1700
|
+
offset?: number;
|
|
1701
|
+
lineStyle?: PlotLineStyle;
|
|
1702
|
+
}>;
|
|
1703
|
+
/**
|
|
1704
|
+
* Options bag for `ta.psar` (Parabolic SAR). `accelerationStart` /
|
|
1705
|
+
* `accelerationStep` / `accelerationMax` default to the canonical
|
|
1706
|
+
* Wilder values `0.02` / `0.02` / `0.2`. `offset` shifts the read
|
|
1707
|
+
* window backwards (PLAN.md §9.1 — accepted on the surface).
|
|
1708
|
+
*
|
|
1709
|
+
* @formula N/A — see `ta.psar` JSDoc
|
|
1710
|
+
* @anchors accelerationStart, accelerationStep, accelerationMax
|
|
1711
|
+
* @since 0.2
|
|
1712
|
+
* @stable
|
|
1713
|
+
* @example
|
|
1714
|
+
* const opts: PsarOpts = { accelerationStart: 0.02, accelerationStep: 0.02, accelerationMax: 0.2 };
|
|
1715
|
+
*/
|
|
1716
|
+
export type PsarOpts = Readonly<{
|
|
1717
|
+
accelerationStart?: number;
|
|
1718
|
+
accelerationStep?: number;
|
|
1719
|
+
accelerationMax?: number;
|
|
1720
|
+
offset?: number;
|
|
1721
|
+
}>;
|
|
1722
|
+
/**
|
|
1723
|
+
* The two-series result of `ta.psar` — the SAR (stop-and-reverse)
|
|
1724
|
+
* level and the per-bar `direction` (`+1` uptrend, `-1` downtrend,
|
|
1725
|
+
* NaN during warmup or NaN-suspension). `direction` carries plain
|
|
1726
|
+
* `number` (not a narrow `+1 | -1` literal) to match the runtime's
|
|
1727
|
+
* `Series<number>` convention.
|
|
1728
|
+
*
|
|
1729
|
+
* @formula sar derived from extreme-point + acceleration-factor recurrence ;
|
|
1730
|
+
* direction flips when bar.low ≤ candidateSar (up→down) or
|
|
1731
|
+
* bar.high ≥ candidateSar (down→up)
|
|
1732
|
+
* @since 0.2
|
|
1733
|
+
* @stable
|
|
1734
|
+
* @example
|
|
1735
|
+
* const p = ta.psar();
|
|
1736
|
+
* plot(p.sar);
|
|
1737
|
+
*/
|
|
1738
|
+
export type PsarResult = Readonly<{
|
|
1739
|
+
sar: Series<number>;
|
|
1740
|
+
direction: Series<number>;
|
|
1741
|
+
}>;
|
|
1742
|
+
/**
|
|
1743
|
+
* Options bag for `ta.supertrend`. `length` is the ATR period
|
|
1744
|
+
* (default `10`); `multiplier` scales the band offset from `hl2`
|
|
1745
|
+
* (default `3`). `offset` shifts the read window backwards
|
|
1746
|
+
* (PLAN.md §9.1 — accepted on the surface). The source is hard-coded
|
|
1747
|
+
* to `hl2` (Pine-canonical Supertrend); a `source` opt could land in
|
|
1748
|
+
* a follow-up.
|
|
1749
|
+
*
|
|
1750
|
+
* @formula N/A — see `ta.supertrend` JSDoc
|
|
1751
|
+
* @since 0.2
|
|
1752
|
+
* @stable
|
|
1753
|
+
* @example
|
|
1754
|
+
* const opts: SupertrendOpts = { length: 10, multiplier: 3 };
|
|
1755
|
+
*/
|
|
1756
|
+
export type SupertrendOpts = Readonly<{
|
|
1757
|
+
length?: number;
|
|
1758
|
+
multiplier?: number;
|
|
1759
|
+
offset?: number;
|
|
1760
|
+
}>;
|
|
1761
|
+
/**
|
|
1762
|
+
* The two-series result of `ta.supertrend` — the trailing-stop
|
|
1763
|
+
* `line` (the active final band per current direction) and the
|
|
1764
|
+
* per-bar `direction` (`+1` uptrend → `line = finalLower`,
|
|
1765
|
+
* `-1` downtrend → `line = finalUpper`, NaN during warmup).
|
|
1766
|
+
*
|
|
1767
|
+
* @formula finalUpper, finalLower derived from hl2 ± multiplier·atr ;
|
|
1768
|
+
* direction flips when close crosses prior finalUpper / finalLower ;
|
|
1769
|
+
* line = direction === +1 ? finalLower : finalUpper
|
|
1770
|
+
* @since 0.2
|
|
1771
|
+
* @stable
|
|
1772
|
+
* @example
|
|
1773
|
+
* const s = ta.supertrend({ length: 10, multiplier: 3 });
|
|
1774
|
+
* plot(s.line);
|
|
1775
|
+
*/
|
|
1776
|
+
export type SupertrendResult = Readonly<{
|
|
1777
|
+
line: Series<number>;
|
|
1778
|
+
direction: Series<number>;
|
|
1779
|
+
}>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Options bag for `ta.chandelier` (Chandelier Exit). `length` is the
|
|
1782
|
+
* ATR period AND the rolling extreme window (default `22`);
|
|
1783
|
+
* `multiplier` scales the ATR offset (default `3`). `offset` shifts
|
|
1784
|
+
* the read window backwards (PLAN.md §9.1 — accepted on the surface).
|
|
1785
|
+
*
|
|
1786
|
+
* @formula N/A — see `ta.chandelier` JSDoc
|
|
1787
|
+
* @anchors length, multiplier
|
|
1788
|
+
* @since 0.2
|
|
1789
|
+
* @stable
|
|
1790
|
+
* @example
|
|
1791
|
+
* const opts: ChandelierOpts = { length: 22, multiplier: 3 };
|
|
1792
|
+
*/
|
|
1793
|
+
export type ChandelierOpts = Readonly<{
|
|
1794
|
+
length?: number;
|
|
1795
|
+
multiplier?: number;
|
|
1796
|
+
offset?: number;
|
|
1797
|
+
}>;
|
|
1798
|
+
/**
|
|
1799
|
+
* The two-series result of `ta.chandelier` — `long` is the trailing
|
|
1800
|
+
* stop for long trades (`highest(high, length) − multiplier · atr`),
|
|
1801
|
+
* `short` is the trailing stop for short trades (`lowest(low, length)
|
|
1802
|
+
* + multiplier · atr`). Both Series carry NaN through the
|
|
1803
|
+
* `length`-bar warmup (ATR + highest/lowest sub-slots' warmups).
|
|
1804
|
+
*
|
|
1805
|
+
* @formula long = highest(high, length) − multiplier · atr(length) ;
|
|
1806
|
+
* short = lowest(low, length) + multiplier · atr(length)
|
|
1807
|
+
* @since 0.2
|
|
1808
|
+
* @stable
|
|
1809
|
+
* @example
|
|
1810
|
+
* const c = ta.chandelier({ length: 22, multiplier: 3 });
|
|
1811
|
+
* plot(c.long);
|
|
1812
|
+
* plot(c.short);
|
|
1813
|
+
*/
|
|
1814
|
+
export type ChandelierResult = Readonly<{
|
|
1815
|
+
long: Series<number>;
|
|
1816
|
+
short: Series<number>;
|
|
1817
|
+
}>;
|
|
1818
|
+
/**
|
|
1819
|
+
* Options bag for `ta.chandeKrollStop`. `length` controls BOTH the
|
|
1820
|
+
* ATR period AND the first-pass rolling extreme window (default
|
|
1821
|
+
* `10`); `multiplier` scales the ATR offset (default `1`);
|
|
1822
|
+
* `smoothingLength` is the second-pass extreme window (default `9`)
|
|
1823
|
+
* — matches Chande Kroll's 1995 paper. `offset` shifts the read
|
|
1824
|
+
* window backwards (PLAN.md §9.1 — accepted on the surface).
|
|
1825
|
+
*
|
|
1826
|
+
* @formula N/A — see `ta.chandeKrollStop` JSDoc
|
|
1827
|
+
* @anchors length, multiplier
|
|
1828
|
+
* @since 0.2
|
|
1829
|
+
* @stable
|
|
1830
|
+
* @example
|
|
1831
|
+
* const opts: ChandeKrollStopOpts = { length: 10, multiplier: 1, smoothingLength: 9 };
|
|
1832
|
+
*/
|
|
1833
|
+
export type ChandeKrollStopOpts = Readonly<{
|
|
1834
|
+
length?: number;
|
|
1835
|
+
multiplier?: number;
|
|
1836
|
+
smoothingLength?: number;
|
|
1837
|
+
offset?: number;
|
|
1838
|
+
}>;
|
|
1839
|
+
/**
|
|
1840
|
+
* The two-series result of `ta.chandeKrollStop` — `long` is the
|
|
1841
|
+
* smoothed long-trade trailing stop (second-pass max of the
|
|
1842
|
+
* first-pass long stops); `short` is the smoothed short-trade
|
|
1843
|
+
* trailing stop (second-pass min of the first-pass short stops).
|
|
1844
|
+
* Both Series carry NaN through the `length + smoothingLength`
|
|
1845
|
+
* warmup.
|
|
1846
|
+
*
|
|
1847
|
+
* @formula firstHigh = highest(high, length) − multiplier · atr(length) ;
|
|
1848
|
+
* firstLow = lowest(low, length) + multiplier · atr(length) ;
|
|
1849
|
+
* long = max(firstHigh over smoothingLength bars) ;
|
|
1850
|
+
* short = min(firstLow over smoothingLength bars)
|
|
1851
|
+
* @since 0.2
|
|
1852
|
+
* @stable
|
|
1853
|
+
* @example
|
|
1854
|
+
* const c = ta.chandeKrollStop();
|
|
1855
|
+
* plot(c.long);
|
|
1856
|
+
* plot(c.short);
|
|
1857
|
+
*/
|
|
1858
|
+
export type ChandeKrollStopResult = Readonly<{
|
|
1859
|
+
long: Series<number>;
|
|
1860
|
+
short: Series<number>;
|
|
1861
|
+
}>;
|
|
1862
|
+
/**
|
|
1863
|
+
* Options bag for `ta.williamsFractal`. `length` is the symmetric
|
|
1864
|
+
* left / right window size (default `2` — total 5-bar window: 2
|
|
1865
|
+
* left + centre + 2 right). `offset` shifts the read window
|
|
1866
|
+
* backwards (PLAN.md §9.1 — accepted on the surface).
|
|
1867
|
+
*
|
|
1868
|
+
* @formula N/A — see `ta.williamsFractal` JSDoc
|
|
1869
|
+
* @anchors length
|
|
1870
|
+
* @since 0.2
|
|
1871
|
+
* @stable
|
|
1872
|
+
* @example
|
|
1873
|
+
* const opts: WilliamsFractalOpts = { length: 2 };
|
|
1874
|
+
*/
|
|
1875
|
+
export type WilliamsFractalOpts = Readonly<{
|
|
1876
|
+
length?: number;
|
|
1877
|
+
offset?: number;
|
|
1878
|
+
}>;
|
|
1879
|
+
/**
|
|
1880
|
+
* The two-series result of `ta.williamsFractal` — the centred
|
|
1881
|
+
* fractal markers. `up.current` is the centre bar's `bar.high` when
|
|
1882
|
+
* the centre bar is an up-fractal (its high is strictly greater
|
|
1883
|
+
* than the `length` bars on either side), NaN otherwise.
|
|
1884
|
+
* `down.current` is the centre bar's `bar.low` for down-fractals.
|
|
1885
|
+
*
|
|
1886
|
+
* The output is centred: at live bar `t`, the value emitted is the
|
|
1887
|
+
* fractal status of bar `t − length` (when bar `t` closes, we now
|
|
1888
|
+
* have enough right-window bars to confirm bar `t − length`). The
|
|
1889
|
+
* most recent `length` bars of each Series are intentionally NaN
|
|
1890
|
+
* (pending right-window confirmation).
|
|
1891
|
+
*
|
|
1892
|
+
* Note: deviates from the task spec's literal `Series<boolean>`
|
|
1893
|
+
* wording in favour of price levels (matches invinite's
|
|
1894
|
+
* `upFractals[i] = high`). This gives the `marker` plot a y-anchor
|
|
1895
|
+
* — the high or low at which the fractal triggered — which is what
|
|
1896
|
+
* TradingView visually shows.
|
|
1897
|
+
*
|
|
1898
|
+
* @formula up = bar.high(centre) when centre is up-fractal, NaN otherwise ;
|
|
1899
|
+
* down = bar.low(centre) when centre is down-fractal, NaN otherwise
|
|
1900
|
+
* @since 0.2
|
|
1901
|
+
* @stable
|
|
1902
|
+
* @example
|
|
1903
|
+
* const f = ta.williamsFractal();
|
|
1904
|
+
* plot(f.up, { style: { kind: "marker", shape: "triangle-up", size: 6 } });
|
|
1905
|
+
* plot(f.down, { style: { kind: "marker", shape: "triangle-down", size: 6 } });
|
|
1906
|
+
*/
|
|
1907
|
+
export type WilliamsFractalResult = Readonly<{
|
|
1908
|
+
up: Series<number>;
|
|
1909
|
+
down: Series<number>;
|
|
1910
|
+
}>;
|
|
1911
|
+
/**
|
|
1912
|
+
* Options bag for `ta.zigZag`. `deviation` is the percentage move
|
|
1913
|
+
* (default `5`) required to confirm a reversal pivot from the running
|
|
1914
|
+
* candidate; `depth` is the minimum number of bars (default `10`) that
|
|
1915
|
+
* must elapse before a pivot can be confirmed. `offset` shifts the
|
|
1916
|
+
* read window backwards (PLAN.md §9.1 — accepted on the surface).
|
|
1917
|
+
*
|
|
1918
|
+
* @formula N/A — see `ta.zigZag` JSDoc
|
|
1919
|
+
* @anchors deviation, depth
|
|
1920
|
+
* @since 0.2
|
|
1921
|
+
* @stable
|
|
1922
|
+
* @example
|
|
1923
|
+
* const opts: ZigZagOpts = { deviation: 5, depth: 10 };
|
|
1924
|
+
*/
|
|
1925
|
+
export type ZigZagOpts = Readonly<{
|
|
1926
|
+
deviation?: number;
|
|
1927
|
+
depth?: number;
|
|
1928
|
+
offset?: number;
|
|
1929
|
+
}>;
|
|
1930
|
+
/**
|
|
1931
|
+
* The two-series result of `ta.zigZag` — `value` carries the price of
|
|
1932
|
+
* the most-recently-confirmed swing pivot (held constant between
|
|
1933
|
+
* confirmations, NaN until the first confirmation); `direction` is
|
|
1934
|
+
* `+1` (uptrend), `-1` (downtrend), or NaN before the first
|
|
1935
|
+
* confirmation.
|
|
1936
|
+
*
|
|
1937
|
+
* Streaming adaptation of invinite's batch ZigZag: the runtime is
|
|
1938
|
+
* append-only and cannot retroactively rewrite earlier output slots,
|
|
1939
|
+
* so the linear-interpolation rendering between confirmed pivots that
|
|
1940
|
+
* invinite paints is intentionally not modelled here — the output
|
|
1941
|
+
* series is the "last-confirmed-pivot level" (a trailing horizontal
|
|
1942
|
+
* line a Pine author would use as a reference).
|
|
1943
|
+
*
|
|
1944
|
+
* @formula see `ta.zigZag` JSDoc
|
|
1945
|
+
* @since 0.2
|
|
1946
|
+
* @stable
|
|
1947
|
+
* @example
|
|
1948
|
+
* const z = ta.zigZag({ deviation: 5 });
|
|
1949
|
+
* plot(z.value);
|
|
1950
|
+
*/
|
|
1951
|
+
export type ZigZagResult = Readonly<{
|
|
1952
|
+
value: Series<number>;
|
|
1953
|
+
direction: Series<number>;
|
|
1954
|
+
}>;
|
|
1955
|
+
/**
|
|
1956
|
+
* Options bag for `ta.pivotsHighLow`. `leftLength` / `rightLength`
|
|
1957
|
+
* default to `4` (a 9-bar centred window); they may differ to surface
|
|
1958
|
+
* asymmetric `ta.pivothigh` / `ta.pivotlow` behaviour. `offset` shifts
|
|
1959
|
+
* the read window backwards (PLAN.md §9.1 — accepted on the surface).
|
|
1960
|
+
*
|
|
1961
|
+
* @formula N/A — see `ta.pivotsHighLow` JSDoc
|
|
1962
|
+
* @anchors leftLength, rightLength
|
|
1963
|
+
* @since 0.2
|
|
1964
|
+
* @stable
|
|
1965
|
+
* @example
|
|
1966
|
+
* const opts: PivotsHighLowOpts = { leftLength: 4, rightLength: 4 };
|
|
1967
|
+
*/
|
|
1968
|
+
export type PivotsHighLowOpts = Readonly<{
|
|
1969
|
+
leftLength?: number;
|
|
1970
|
+
rightLength?: number;
|
|
1971
|
+
offset?: number;
|
|
1972
|
+
}>;
|
|
1973
|
+
/**
|
|
1974
|
+
* The two-series result of `ta.pivotsHighLow` — the centred swing-
|
|
1975
|
+
* high / swing-low markers. `high.current` = `bar.high(centre)` when
|
|
1976
|
+
* the centre bar is a confirmed up-pivot (strict-greater on the left
|
|
1977
|
+
* window, geq on the right — matches Pine `ta.pivothigh`); NaN
|
|
1978
|
+
* otherwise. `low.current` mirrors for down-pivots with `bar.low`.
|
|
1979
|
+
*
|
|
1980
|
+
* Output is centred — at live bar `t`, the value emitted is the
|
|
1981
|
+
* pivot status of bar `t − rightLength` (when bar `t` closes, we now
|
|
1982
|
+
* have enough right-window bars to confirm bar `t − rightLength`).
|
|
1983
|
+
* The most recent `rightLength` slots of each Series are
|
|
1984
|
+
* intentionally NaN (pending right-window confirmation).
|
|
1985
|
+
*
|
|
1986
|
+
* @formula high = bar.high(centre) when centre is up-pivot, NaN otherwise ;
|
|
1987
|
+
* low = bar.low(centre) when centre is down-pivot, NaN otherwise
|
|
1988
|
+
* @since 0.2
|
|
1989
|
+
* @stable
|
|
1990
|
+
* @example
|
|
1991
|
+
* const p = ta.pivotsHighLow({ leftLength: 4, rightLength: 4 });
|
|
1992
|
+
* plot(p.high);
|
|
1993
|
+
* plot(p.low);
|
|
1994
|
+
*/
|
|
1995
|
+
export type PivotsHighLowResult = Readonly<{
|
|
1996
|
+
high: Series<number>;
|
|
1997
|
+
low: Series<number>;
|
|
1998
|
+
}>;
|
|
1999
|
+
/**
|
|
2000
|
+
* The classical pivot-points formula systems supported by
|
|
2001
|
+
* `ta.pivotsStandard`. `"classic"` is the default; `"fibonacci"` /
|
|
2002
|
+
* `"camarilla"` / `"woodie"` mirror the published TradingView
|
|
2003
|
+
* formulas. DeMark / Traditional are deferred to a later phase.
|
|
2004
|
+
*
|
|
2005
|
+
* @formula N/A — string-literal union type
|
|
2006
|
+
* @since 0.2
|
|
2007
|
+
* @stable
|
|
2008
|
+
* @example
|
|
2009
|
+
* const sys: PivotsStandardSystem = "classic";
|
|
2010
|
+
*/
|
|
2011
|
+
export type PivotsStandardSystem = "classic" | "fibonacci" | "camarilla" | "woodie";
|
|
2012
|
+
/**
|
|
2013
|
+
* Options bag for `ta.pivotsStandard`. `system` picks the formula
|
|
2014
|
+
* family (default `"classic"`). `offset` shifts the read window
|
|
2015
|
+
* backwards (PLAN.md §9.1 — accepted on the surface).
|
|
2016
|
+
*
|
|
2017
|
+
* @formula N/A — see `ta.pivotsStandard` JSDoc
|
|
2018
|
+
* @anchors system
|
|
2019
|
+
* @since 0.2
|
|
2020
|
+
* @stable
|
|
2021
|
+
* @example
|
|
2022
|
+
* const opts: PivotsStandardOpts = { system: "fibonacci" };
|
|
2023
|
+
*/
|
|
2024
|
+
export type PivotsStandardOpts = Readonly<{
|
|
2025
|
+
system?: PivotsStandardSystem;
|
|
2026
|
+
offset?: number;
|
|
2027
|
+
}>;
|
|
2028
|
+
/**
|
|
2029
|
+
* The seven-series result of `ta.pivotsStandard` — the classical
|
|
2030
|
+
* pivot point `pp` plus three resistance / three support levels
|
|
2031
|
+
* derived from the prior UTC-day's high / low / close. The runtime
|
|
2032
|
+
* resets the day aggregate on every UTC-day boundary (detected via
|
|
2033
|
+
* `Math.floor(bar.time / 86_400_000)`); the levels for the current
|
|
2034
|
+
* day are computed from the prior closed day's HLC.
|
|
2035
|
+
*
|
|
2036
|
+
* R4 / R5 / S4 / S5 are intentionally deferred — Phase 2 ships
|
|
2037
|
+
* R1..R3 / S1..S3 only per the Phase-2 README "Deferred / Follow-Up
|
|
2038
|
+
* Work" footnote.
|
|
2039
|
+
*
|
|
2040
|
+
* @formula see `ta.pivotsStandard` JSDoc (per-system formula table)
|
|
2041
|
+
* @since 0.2
|
|
2042
|
+
* @stable
|
|
2043
|
+
* @example
|
|
2044
|
+
* const p = ta.pivotsStandard();
|
|
2045
|
+
* plot(p.pp);
|
|
2046
|
+
* plot(p.r1);
|
|
2047
|
+
* plot(p.s1);
|
|
2048
|
+
*/
|
|
2049
|
+
export type PivotsStandardResult = Readonly<{
|
|
2050
|
+
pp: Series<number>;
|
|
2051
|
+
r1: Series<number>;
|
|
2052
|
+
s1: Series<number>;
|
|
2053
|
+
r2: Series<number>;
|
|
2054
|
+
s2: Series<number>;
|
|
2055
|
+
r3: Series<number>;
|
|
2056
|
+
s3: Series<number>;
|
|
2057
|
+
}>;
|
|
2058
|
+
/**
|
|
2059
|
+
* Options bag for `ta.volatilityStop`. `length` is the ATR period
|
|
2060
|
+
* (default `20`); `multiplier` scales the ATR offset (default `2`).
|
|
2061
|
+
* `offset` shifts the read window backwards (PLAN.md §9.1 — accepted
|
|
2062
|
+
* on the surface). Source is hard-coded to `bar.close` (Pine
|
|
2063
|
+
* `ta.vstop` convention); an explicit `source` opt could land in a
|
|
2064
|
+
* follow-up.
|
|
2065
|
+
*
|
|
2066
|
+
* @formula N/A — see `ta.volatilityStop` JSDoc
|
|
2067
|
+
* @anchors length, multiplier
|
|
2068
|
+
* @since 0.2
|
|
2069
|
+
* @stable
|
|
2070
|
+
* @example
|
|
2071
|
+
* const opts: VolatilityStopOpts = { length: 20, multiplier: 2 };
|
|
2072
|
+
*/
|
|
2073
|
+
export type VolatilityStopOpts = Readonly<{
|
|
2074
|
+
length?: number;
|
|
2075
|
+
multiplier?: number;
|
|
2076
|
+
offset?: number;
|
|
2077
|
+
}>;
|
|
2078
|
+
/**
|
|
2079
|
+
* The two-series result of `ta.volatilityStop` — the trailing-stop
|
|
2080
|
+
* `value` (analogous to PSAR's `sar`) and the per-bar `direction`
|
|
2081
|
+
* (`+1` uptrend → stop is BELOW price, `-1` downtrend → stop is
|
|
2082
|
+
* ABOVE price, NaN during warmup or NaN-suspension).
|
|
2083
|
+
*
|
|
2084
|
+
* @formula trend up: value = max(prevStop, src − multiplier · atr) ;
|
|
2085
|
+
* trend down: value = min(prevStop, src + multiplier · atr) ;
|
|
2086
|
+
* flip on src crossing the stop
|
|
2087
|
+
* @since 0.2
|
|
2088
|
+
* @stable
|
|
2089
|
+
* @example
|
|
2090
|
+
* const v = ta.volatilityStop({ length: 20, multiplier: 2 });
|
|
2091
|
+
* plot(v.value);
|
|
2092
|
+
*/
|
|
2093
|
+
export type VolatilityStopResult = Readonly<{
|
|
2094
|
+
value: Series<number>;
|
|
2095
|
+
direction: Series<number>;
|
|
2096
|
+
}>;
|
|
2097
|
+
/**
|
|
2098
|
+
* Options bag for `ta.adx` (Wilder's Average Directional Index).
|
|
2099
|
+
* `smoothing` is the second-stage Wilder window applied to DX
|
|
2100
|
+
* (default `14` — matches the DI window). `offset` shifts the
|
|
2101
|
+
* output (PLAN.md §9.1). `lineStyle` is a forward-compat plot-
|
|
2102
|
+
* styling hint surfaced for §9.1 ergonomics — not consumed by the
|
|
2103
|
+
* primitive itself.
|
|
2104
|
+
*
|
|
2105
|
+
* @formula N/A — see `ta.adx` JSDoc
|
|
2106
|
+
* @anchors smoothing
|
|
2107
|
+
* @since 0.2
|
|
2108
|
+
* @stable
|
|
2109
|
+
* @example
|
|
2110
|
+
* const opts: AdxOpts = { smoothing: 14 };
|
|
2111
|
+
*/
|
|
2112
|
+
export type AdxOpts = Readonly<{
|
|
2113
|
+
smoothing?: number;
|
|
2114
|
+
offset?: number;
|
|
2115
|
+
lineStyle?: PlotLineStyle;
|
|
2116
|
+
}>;
|
|
2117
|
+
/**
|
|
2118
|
+
* Options bag for `ta.dmi` (Directional Movement Index). `offset`
|
|
2119
|
+
* shifts both output series in lockstep (PLAN.md §9.1). `outputs`
|
|
2120
|
+
* carries per-output styling hints downstream `plot()` callsites
|
|
2121
|
+
* can lift defaults from; the runtime itself ignores it in Phase 2
|
|
2122
|
+
* — script-author `plot(d.plusDi, { lineStyle })` is the styling
|
|
2123
|
+
* seam.
|
|
2124
|
+
*
|
|
2125
|
+
* @formula N/A — see `ta.dmi` JSDoc
|
|
2126
|
+
* @since 0.2
|
|
2127
|
+
* @stable
|
|
2128
|
+
* @example
|
|
2129
|
+
* const opts: DmiOpts = { offset: 0 };
|
|
2130
|
+
*/
|
|
2131
|
+
export type DmiOpts = Readonly<{
|
|
2132
|
+
offset?: number;
|
|
2133
|
+
outputs?: Readonly<Record<"plusDi" | "minusDi", {
|
|
2134
|
+
lineStyle?: PlotLineStyle;
|
|
2135
|
+
}>>;
|
|
2136
|
+
}>;
|
|
2137
|
+
/**
|
|
2138
|
+
* The two-series result of `ta.dmi` — Wilder's `+DI` / `−DI` pair.
|
|
2139
|
+
* Both ∈ [0, 100] when defined; NaN through the `length` warmup
|
|
2140
|
+
* window. `primarySeriesKey: "plusDi"` (recorded in
|
|
2141
|
+
* `TA_REGISTRY_METADATA`) with `yDomain: { kind: "fixed", min: 0,
|
|
2142
|
+
* max: 100 }`.
|
|
2143
|
+
*
|
|
2144
|
+
* @formula see `ta.dmi` JSDoc
|
|
2145
|
+
* @since 0.2
|
|
2146
|
+
* @stable
|
|
2147
|
+
* @example
|
|
2148
|
+
* const d = ta.dmi(14);
|
|
2149
|
+
* plot(d.plusDi);
|
|
2150
|
+
* plot(d.minusDi);
|
|
2151
|
+
*/
|
|
2152
|
+
export type DmiResult = Readonly<{
|
|
2153
|
+
plusDi: Series<number>;
|
|
2154
|
+
minusDi: Series<number>;
|
|
2155
|
+
}>;
|
|
2156
|
+
/**
|
|
2157
|
+
* Options bag for `ta.trix` (Triple-smoothed EMA Rate-of-Change).
|
|
2158
|
+
* `signalLength` is the EMA-smoothing length of the TRIX signal
|
|
2159
|
+
* line (default `9`). `offset` shifts both output series in
|
|
2160
|
+
* lockstep (PLAN.md §9.1).
|
|
2161
|
+
*
|
|
2162
|
+
* @formula N/A — see `ta.trix` JSDoc
|
|
2163
|
+
* @anchors signalLength
|
|
2164
|
+
* @since 0.2
|
|
2165
|
+
* @stable
|
|
2166
|
+
* @example
|
|
2167
|
+
* const opts: TrixOpts = { signalLength: 9 };
|
|
2168
|
+
*/
|
|
2169
|
+
export type TrixOpts = Readonly<{
|
|
2170
|
+
signalLength?: number;
|
|
2171
|
+
offset?: number;
|
|
2172
|
+
}>;
|
|
2173
|
+
/**
|
|
2174
|
+
* The two-series result of `ta.trix` — the TRIX momentum line and
|
|
2175
|
+
* its EMA signal line. Both are unbounded; `yDomain: { kind:
|
|
2176
|
+
* "auto" }`. `primarySeriesKey: "trix"` (recorded in
|
|
2177
|
+
* `TA_REGISTRY_METADATA`).
|
|
2178
|
+
*
|
|
2179
|
+
* @formula see `ta.trix` JSDoc
|
|
2180
|
+
* @since 0.2
|
|
2181
|
+
* @stable
|
|
2182
|
+
* @example
|
|
2183
|
+
* const t = ta.trix(bar.close, 18);
|
|
2184
|
+
* plot(t.trix);
|
|
2185
|
+
* plot(t.signal);
|
|
2186
|
+
*/
|
|
2187
|
+
export type TrixResult = Readonly<{
|
|
2188
|
+
trix: Series<number>;
|
|
2189
|
+
signal: Series<number>;
|
|
2190
|
+
}>;
|
|
2191
|
+
/**
|
|
2192
|
+
* Options bag for `ta.vortex` (Botes & Siepman Vortex Indicator).
|
|
2193
|
+
* `length` is positional on the call (`ta.vortex(length, opts?)`), so
|
|
2194
|
+
* the opts bag carries only the universal `offset` (PLAN.md §9.1) +
|
|
2195
|
+
* per-output styling hints. The runtime emits `NaN` on zero-TR
|
|
2196
|
+
* windows (chartlang surfaces the degenerate window — invinite emits
|
|
2197
|
+
* 0 in the same case).
|
|
2198
|
+
*
|
|
2199
|
+
* @formula N/A — see `ta.vortex` JSDoc
|
|
2200
|
+
* @since 0.2
|
|
2201
|
+
* @stable
|
|
2202
|
+
* @example
|
|
2203
|
+
* const opts: VortexOpts = { offset: 0 };
|
|
2204
|
+
*/
|
|
2205
|
+
export type VortexOpts = Readonly<{
|
|
2206
|
+
offset?: number;
|
|
2207
|
+
outputs?: Readonly<Record<"plus" | "minus", {
|
|
2208
|
+
lineStyle?: PlotLineStyle;
|
|
2209
|
+
}>>;
|
|
2210
|
+
}>;
|
|
2211
|
+
/**
|
|
2212
|
+
* The two-series result of `ta.vortex` — the `+VI` / `−VI` Vortex
|
|
2213
|
+
* lines (Botes & Siepman, 2010). Typical operating range `[0, 2]`
|
|
2214
|
+
* (`yDomain: { kind: "auto" }`). `primarySeriesKey: "plus"` is
|
|
2215
|
+
* recorded in `TA_REGISTRY_METADATA`.
|
|
2216
|
+
*
|
|
2217
|
+
* @formula see `ta.vortex` JSDoc
|
|
2218
|
+
* @since 0.2
|
|
2219
|
+
* @stable
|
|
2220
|
+
* @example
|
|
2221
|
+
* const v = ta.vortex(14);
|
|
2222
|
+
* plot(v.plus);
|
|
2223
|
+
* plot(v.minus);
|
|
2224
|
+
*/
|
|
2225
|
+
export type VortexResult = Readonly<{
|
|
2226
|
+
plus: Series<number>;
|
|
2227
|
+
minus: Series<number>;
|
|
2228
|
+
}>;
|
|
2229
|
+
/**
|
|
2230
|
+
* Options bag for `ta.trendStrengthIndex` — TradingView's Trend
|
|
2231
|
+
* Strength Index, the Pearson correlation between `source` and the
|
|
2232
|
+
* bar index. Distinct from `ta.tsi` (Task 14's True Strength Index
|
|
2233
|
+
* momentum oscillator). Default `length = 20` (positional). `offset`
|
|
2234
|
+
* matches the universal §9.1 convention.
|
|
2235
|
+
*
|
|
2236
|
+
* @formula N/A — see `ta.trendStrengthIndex` JSDoc
|
|
2237
|
+
* @since 0.2
|
|
2238
|
+
* @stable
|
|
2239
|
+
* @example
|
|
2240
|
+
* const opts: TrendStrengthIndexOpts = { offset: 0 };
|
|
2241
|
+
*/
|
|
2242
|
+
export type TrendStrengthIndexOpts = Readonly<{
|
|
2243
|
+
offset?: number;
|
|
2244
|
+
lineStyle?: PlotLineStyle;
|
|
2245
|
+
}>;
|
|
2246
|
+
/**
|
|
2247
|
+
* Options bag for `ta.ichimoku`. Defaults follow Pine / TradingView
|
|
2248
|
+
* canonical Ichimoku — `conversionLength = 9, baseLength = 26,
|
|
2249
|
+
* leadingSpanBLength = 52, displacement = 26`. `offset` shifts all
|
|
2250
|
+
* five outputs in lockstep (PLAN.md §9.1). `outputs` carries
|
|
2251
|
+
* per-output styling hints downstream `plot()` callsites can lift
|
|
2252
|
+
* defaults from; the runtime itself ignores it in Phase 2.
|
|
2253
|
+
*
|
|
2254
|
+
* @formula N/A — see `ta.ichimoku` JSDoc
|
|
2255
|
+
* @anchors displacement, conversionLength, baseLength, leadingSpanBLength
|
|
2256
|
+
* @since 0.2
|
|
2257
|
+
* @stable
|
|
2258
|
+
* @example
|
|
2259
|
+
* const opts: IchimokuOpts = {
|
|
2260
|
+
* conversionLength: 9,
|
|
2261
|
+
* baseLength: 26,
|
|
2262
|
+
* leadingSpanBLength: 52,
|
|
2263
|
+
* displacement: 26,
|
|
2264
|
+
* };
|
|
2265
|
+
*/
|
|
2266
|
+
export type IchimokuOpts = Readonly<{
|
|
2267
|
+
conversionLength?: number;
|
|
2268
|
+
baseLength?: number;
|
|
2269
|
+
leadingSpanBLength?: number;
|
|
2270
|
+
displacement?: number;
|
|
2271
|
+
offset?: number;
|
|
2272
|
+
outputs?: Readonly<Record<"tenkan" | "kijun" | "senkouA" | "senkouB" | "chikou", {
|
|
2273
|
+
lineStyle?: PlotLineStyle;
|
|
2274
|
+
}>>;
|
|
2275
|
+
}>;
|
|
2276
|
+
/**
|
|
2277
|
+
* The five-series result of `ta.ichimoku` — Tenkan (Conversion Line),
|
|
2278
|
+
* Kijun (Base Line), Senkou Span A / B (Leading Spans, forward-shifted
|
|
2279
|
+
* by `displacement`), Chikou (Lagging Span — backward-shifted close).
|
|
2280
|
+
* `primarySeriesKey: "tenkan"` (recorded in `TA_REGISTRY_METADATA`)
|
|
2281
|
+
* with `yDomain: { kind: "auto" }`. The cloud renders as a
|
|
2282
|
+
* `filled-band` PlotKind (Task 1 prerequisite) between `senkouA` and
|
|
2283
|
+
* `senkouB`; the script author drives this via their `plot()` call —
|
|
2284
|
+
* the runtime emits the two series.
|
|
2285
|
+
*
|
|
2286
|
+
* @formula see `ta.ichimoku` JSDoc
|
|
2287
|
+
* @since 0.2
|
|
2288
|
+
* @stable
|
|
2289
|
+
* @example
|
|
2290
|
+
* const i = ta.ichimoku();
|
|
2291
|
+
* plot(i.tenkan);
|
|
2292
|
+
* plot(i.kijun);
|
|
2293
|
+
* plot(i.senkouA);
|
|
2294
|
+
* plot(i.senkouB);
|
|
2295
|
+
* plot(i.chikou);
|
|
2296
|
+
*/
|
|
2297
|
+
export type IchimokuResult = Readonly<{
|
|
2298
|
+
tenkan: Series<number>;
|
|
2299
|
+
kijun: Series<number>;
|
|
2300
|
+
senkouA: Series<number>;
|
|
2301
|
+
senkouB: Series<number>;
|
|
2302
|
+
chikou: Series<number>;
|
|
2303
|
+
}>;
|
|
2304
|
+
/**
|
|
2305
|
+
* The three-series result of `ta.bb`. Each component is a separate `Series`
|
|
2306
|
+
* the runtime updates in lock-step with the source.
|
|
2307
|
+
*
|
|
2308
|
+
* @formula upper = sma + k * stdev, lower = sma − k * stdev
|
|
2309
|
+
* @since 0.1
|
|
2310
|
+
* @stable
|
|
2311
|
+
* @example
|
|
2312
|
+
* declare const close: Series<number>;
|
|
2313
|
+
* const bands = ta.bb(close, 20, { multiplier: 2 });
|
|
2314
|
+
* plot(bands.upper);
|
|
2315
|
+
*/
|
|
2316
|
+
export type BbResult = Readonly<{
|
|
2317
|
+
upper: Series<number>;
|
|
2318
|
+
middle: Series<number>;
|
|
2319
|
+
lower: Series<number>;
|
|
2320
|
+
}>;
|
|
2321
|
+
/**
|
|
2322
|
+
* The three-series result of `ta.macd` — the MACD line, its signal line, and
|
|
2323
|
+
* the histogram of their difference.
|
|
2324
|
+
*
|
|
2325
|
+
* @formula macd = ema(src, fast) − ema(src, slow); signal = ema(macd, signal);
|
|
2326
|
+
* hist = macd − signal
|
|
2327
|
+
* @since 0.1
|
|
2328
|
+
* @stable
|
|
2329
|
+
* @example
|
|
2330
|
+
* declare const close: Series<number>;
|
|
2331
|
+
* const m = ta.macd(close);
|
|
2332
|
+
* plot(m.hist);
|
|
2333
|
+
*/
|
|
2334
|
+
export type MacdResult = Readonly<{
|
|
2335
|
+
macd: Series<number>;
|
|
2336
|
+
signal: Series<number>;
|
|
2337
|
+
hist: Series<number>;
|
|
2338
|
+
}>;
|
|
2339
|
+
/**
|
|
2340
|
+
* The typed surface of the `ta` namespace. The runtime registers concrete
|
|
2341
|
+
* implementations against this interface; scripts call it through the
|
|
2342
|
+
* `ta` constant exported from `@invinite-org/chartlang-core`.
|
|
2343
|
+
*
|
|
2344
|
+
* `ta.atr` takes no `source` because ATR is derived from bar OHLC in the
|
|
2345
|
+
* runtime (mirrors Pine's signature).
|
|
2346
|
+
*
|
|
2347
|
+
* @formula see per-method JSDoc on the `ta` const below
|
|
2348
|
+
* @since 0.1
|
|
2349
|
+
* @stable
|
|
2350
|
+
* @example
|
|
2351
|
+
* declare const close: Series<number>;
|
|
2352
|
+
* const e: Series<number> = ta.ema(close, 20);
|
|
2353
|
+
*/
|
|
2354
|
+
export type TaNamespace = {
|
|
2355
|
+
sma(source: Series<number>, length: number, opts?: SmaOpts): Series<number>;
|
|
2356
|
+
ema(source: Series<number>, length: number, opts?: EmaOpts): Series<number>;
|
|
2357
|
+
stdev(source: Series<number>, length: number, opts?: StdevOpts): Series<number>;
|
|
2358
|
+
bb(source: Series<number>, length: number, opts?: BbOpts): BbResult;
|
|
2359
|
+
rsi(source: Series<number>, length: number, opts?: RsiOpts): Series<number>;
|
|
2360
|
+
macd(source: Series<number>, opts?: MacdOpts): MacdResult;
|
|
2361
|
+
atr(length: number, opts?: AtrOpts): Series<number>;
|
|
2362
|
+
crossover(a: Series<number>, b: Series<number> | number, opts?: CrossoverOpts): Series<boolean>;
|
|
2363
|
+
crossunder(a: Series<number>, b: Series<number> | number, opts?: CrossunderOpts): Series<boolean>;
|
|
2364
|
+
nz(value: number, replacement?: number): number;
|
|
2365
|
+
highest(source: Series<number>, length: number, opts?: HighestOpts): Series<number>;
|
|
2366
|
+
lowest(source: Series<number>, length: number, opts?: LowestOpts): Series<number>;
|
|
2367
|
+
change(source: Series<number>, opts?: ChangeOpts): Series<number>;
|
|
2368
|
+
valuewhen(condition: Series<boolean>, source: Series<number>, occurrence?: number, opts?: ValuewhenOpts): Series<number>;
|
|
2369
|
+
barssince(condition: Series<boolean>, opts?: BarssinceOpts): Series<number>;
|
|
2370
|
+
wma(source: Series<number>, length: number, opts?: WmaOpts): Series<number>;
|
|
2371
|
+
vwma(source: Series<number>, length: number, opts?: VwmaOpts): Series<number>;
|
|
2372
|
+
hma(source: Series<number>, length: number, opts?: HmaOpts): Series<number>;
|
|
2373
|
+
smma(source: Series<number>, length: number, opts?: SmmaOpts): Series<number>;
|
|
2374
|
+
dema(source: Series<number>, length: number, opts?: DemaOpts): Series<number>;
|
|
2375
|
+
tema(source: Series<number>, length: number, opts?: TemaOpts): Series<number>;
|
|
2376
|
+
kama(source: Series<number>, opts?: KamaOpts): Series<number>;
|
|
2377
|
+
alma(source: Series<number>, length: number, opts?: AlmaOpts): Series<number>;
|
|
2378
|
+
lsma(source: Series<number>, length: number, opts?: LsmaOpts): Series<number>;
|
|
2379
|
+
mcginley(source: Series<number>, length: number, opts?: McginleyOpts): Series<number>;
|
|
2380
|
+
maRibbon(source: Series<number>, opts?: MaRibbonOpts): MaRibbonResult;
|
|
2381
|
+
cci(source: Series<number>, length: number, opts?: CciOpts): Series<number>;
|
|
2382
|
+
stoch(opts?: StochOpts): StochResult;
|
|
2383
|
+
williamsR(length: number, opts?: WilliamsROpts): Series<number>;
|
|
2384
|
+
stochRsi(source: Series<number>, opts?: StochRsiOpts): StochRsiResult;
|
|
2385
|
+
ultimateOsc(opts?: UltimateOscOpts): Series<number>;
|
|
2386
|
+
coppock(source: Series<number>, opts?: CoppockOpts): Series<number>;
|
|
2387
|
+
ppo(source: Series<number>, opts?: PpoOpts): PpoResult;
|
|
2388
|
+
dpo(source: Series<number>, length: number, opts?: DpoOpts): Series<number>;
|
|
2389
|
+
connorsRsi(source: Series<number>, opts?: ConnorsRsiOpts): Series<number>;
|
|
2390
|
+
kst(source: Series<number>, opts?: KstOpts): KstResult;
|
|
2391
|
+
fisher(length: number, opts?: FisherOpts): FisherResult;
|
|
2392
|
+
klinger(opts?: KlingerOpts): KlingerResult;
|
|
2393
|
+
rvgi(opts?: RvgiOpts): RvgiResult;
|
|
2394
|
+
ao(opts?: AoOpts): Series<number>;
|
|
2395
|
+
cmo(source: Series<number>, length: number, opts?: CmoOpts): Series<number>;
|
|
2396
|
+
momentum(source: Series<number>, length: number, opts?: MomentumOpts): Series<number>;
|
|
2397
|
+
roc(source: Series<number>, length: number, opts?: RocOpts): Series<number>;
|
|
2398
|
+
pmo(source: Series<number>, opts?: PmoOpts): PmoResult;
|
|
2399
|
+
smi(opts?: SmiOpts): SmiResult;
|
|
2400
|
+
tsi(source: Series<number>, opts?: TsiOpts): TsiResult;
|
|
2401
|
+
aroon(length: number, opts?: AroonOpts): AroonResult;
|
|
2402
|
+
aroonOsc(length: number, opts?: AroonOscOpts): Series<number>;
|
|
2403
|
+
median(source: Series<number>, length: number, opts?: MedianOpts): Series<number>;
|
|
2404
|
+
adr(opts?: AdrOpts): Series<number>;
|
|
2405
|
+
ulcerIndex(source: Series<number>, length: number, opts?: UlcerIndexOpts): Series<number>;
|
|
2406
|
+
vol(opts?: VolOpts): Series<number>;
|
|
2407
|
+
vwap(opts?: VwapOpts): Series<number>;
|
|
2408
|
+
anchoredVwap(anchorTime: number, opts?: AnchoredVwapOpts): Series<number>;
|
|
2409
|
+
anchoredVolumeProfile(opts: AnchoredVolumeProfileOpts): AnchoredVolumeProfileResult;
|
|
2410
|
+
fixedRangeVolumeProfile(opts: FixedRangeVolumeProfileOpts): FixedRangeVolumeProfileResult;
|
|
2411
|
+
sessionVolumeProfile(opts?: SessionVolumeProfileOpts): SessionVolumeProfileResult;
|
|
2412
|
+
visibleRangeVolumeProfile(opts?: VisibleRangeVolumeProfileOpts): VisibleRangeVolumeProfileResult;
|
|
2413
|
+
obv(opts?: ObvOpts): Series<number>;
|
|
2414
|
+
adl(opts?: AdlOpts): Series<number>;
|
|
2415
|
+
bop(opts?: BopOpts): Series<number>;
|
|
2416
|
+
cmf(length: number, opts?: CmfOpts): Series<number>;
|
|
2417
|
+
chaikinOsc(opts?: ChaikinOscOpts): Series<number>;
|
|
2418
|
+
mfi(length: number, opts?: MfiOpts): Series<number>;
|
|
2419
|
+
netVolume(opts?: NetVolumeOpts): Series<number>;
|
|
2420
|
+
pvo(opts?: PvoOpts): PvoResult;
|
|
2421
|
+
pvt(opts?: PvtOpts): Series<number>;
|
|
2422
|
+
eom(length: number, opts?: EomOpts): Series<number>;
|
|
2423
|
+
nvi(opts?: NviOpts): Series<number>;
|
|
2424
|
+
pvi(opts?: PviOpts): Series<number>;
|
|
2425
|
+
bbPercentB(source: Series<number>, length: number, opts?: BbPercentBOpts): Series<number>;
|
|
2426
|
+
bbw(source: Series<number>, length: number, opts?: BbwOpts): Series<number>;
|
|
2427
|
+
donchian(length: number, opts?: DonchianOpts): DonchianResult;
|
|
2428
|
+
keltner(opts?: KeltnerOpts): KeltnerResult;
|
|
2429
|
+
envelope(source: Series<number>, opts?: EnvelopeOpts): EnvelopeResult;
|
|
2430
|
+
chop(length: number, opts?: ChopOpts): Series<number>;
|
|
2431
|
+
historicalVolatility(source: Series<number>, length: number, opts?: HvOpts): Series<number>;
|
|
2432
|
+
rvi(source: Series<number>, length: number, opts?: RviOpts): Series<number>;
|
|
2433
|
+
massIndex(opts?: MassIndexOpts): Series<number>;
|
|
2434
|
+
psar(opts?: PsarOpts): PsarResult;
|
|
2435
|
+
supertrend(opts?: SupertrendOpts): SupertrendResult;
|
|
2436
|
+
chandelier(opts?: ChandelierOpts): ChandelierResult;
|
|
2437
|
+
chandeKrollStop(opts?: ChandeKrollStopOpts): ChandeKrollStopResult;
|
|
2438
|
+
williamsFractal(opts?: WilliamsFractalOpts): WilliamsFractalResult;
|
|
2439
|
+
zigZag(opts?: ZigZagOpts): ZigZagResult;
|
|
2440
|
+
pivotsHighLow(opts?: PivotsHighLowOpts): PivotsHighLowResult;
|
|
2441
|
+
pivotsStandard(opts?: PivotsStandardOpts): PivotsStandardResult;
|
|
2442
|
+
volatilityStop(opts?: VolatilityStopOpts): VolatilityStopResult;
|
|
2443
|
+
adx(length: number, opts?: AdxOpts): Series<number>;
|
|
2444
|
+
dmi(length: number, opts?: DmiOpts): DmiResult;
|
|
2445
|
+
trix(source: Series<number>, length: number, opts?: TrixOpts): TrixResult;
|
|
2446
|
+
vortex(length: number, opts?: VortexOpts): VortexResult;
|
|
2447
|
+
trendStrengthIndex(source: Series<number>, length: number, opts?: TrendStrengthIndexOpts): Series<number>;
|
|
2448
|
+
ichimoku(opts?: IchimokuOpts): IchimokuResult;
|
|
2449
|
+
};
|
|
2450
|
+
/**
|
|
2451
|
+
* The compile-time callable hole for the `ta` namespace. Every method throws
|
|
2452
|
+
* the `"ta.<name> called outside compiled runtime"` sentinel — the compiler
|
|
2453
|
+
* (Task 2) rewrites callsites to re-target the real runtime implementations.
|
|
2454
|
+
*
|
|
2455
|
+
* Scripts import this constant; the compiler swaps the call target at build
|
|
2456
|
+
* time. Direct invocation (outside a compiled script) is the failure mode
|
|
2457
|
+
* these sentinels guard.
|
|
2458
|
+
*
|
|
2459
|
+
* @formula see method-specific JSDoc on the runtime implementations
|
|
2460
|
+
* @since 0.1
|
|
2461
|
+
* @stable
|
|
2462
|
+
* @example
|
|
2463
|
+
* ```ts
|
|
2464
|
+
* import { defineIndicator, ta, plot } from "@invinite-org/chartlang-core";
|
|
2465
|
+
*
|
|
2466
|
+
* export default defineIndicator({
|
|
2467
|
+
* name: "EMA(20)",
|
|
2468
|
+
* apiVersion: 1,
|
|
2469
|
+
* compute: ({ bar }) => {
|
|
2470
|
+
* plot(ta.ema(bar.close, 20));
|
|
2471
|
+
* },
|
|
2472
|
+
* });
|
|
2473
|
+
* ```
|
|
2474
|
+
*/
|
|
2475
|
+
export declare const ta: TaNamespace;
|
|
2476
|
+
//# sourceMappingURL=ta.d.ts.map
|