oakscriptjs 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/check/format.d.ts.map +1 -1
- package/dist/cjs/check/format.js +5 -0
- package/dist/cjs/check/format.js.map +2 -2
- package/dist/cjs/check/harness.d.ts +24 -0
- package/dist/cjs/check/harness.d.ts.map +1 -1
- package/dist/cjs/check/harness.js +33 -0
- package/dist/cjs/check/harness.js.map +2 -2
- package/dist/cjs/check/index.d.ts +9 -0
- package/dist/cjs/check/index.d.ts.map +1 -1
- package/dist/cjs/check/index.js +7 -0
- package/dist/cjs/check/index.js.map +2 -2
- package/dist/cjs/color/index.d.ts.map +1 -1
- package/dist/cjs/color/index.js +19 -2
- package/dist/cjs/color/index.js.map +2 -2
- package/dist/cjs/color/parse.d.ts +8 -6
- package/dist/cjs/color/parse.d.ts.map +1 -1
- package/dist/cjs/color/parse.js +15 -2
- package/dist/cjs/color/parse.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +32 -0
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +179 -45
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/runtime/series.d.ts +16 -0
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +19 -2
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/closure-writes.d.ts +16 -0
- package/dist/cjs/script/closure-writes.d.ts.map +1 -0
- package/dist/cjs/script/closure-writes.js +435 -0
- package/dist/cjs/script/closure-writes.js.map +7 -0
- package/dist/cjs/script/globals.d.ts +2 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/incremental.d.ts +140 -0
- package/dist/cjs/script/incremental.d.ts.map +1 -0
- package/dist/cjs/script/incremental.js +142 -0
- package/dist/cjs/script/incremental.js.map +7 -0
- package/dist/cjs/script/index.d.ts +116 -31
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +471 -25
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/session/bars.d.ts +3 -0
- package/dist/cjs/session/bars.d.ts.map +1 -1
- package/dist/cjs/session/bars.js +10 -3
- package/dist/cjs/session/bars.js.map +2 -2
- package/dist/cjs/session/calendar.d.ts +19 -6
- package/dist/cjs/session/calendar.d.ts.map +1 -1
- package/dist/cjs/session/calendar.js +57 -18
- package/dist/cjs/session/calendar.js.map +2 -2
- package/dist/cjs/session/context.d.ts.map +1 -1
- package/dist/cjs/session/context.js +25 -8
- package/dist/cjs/session/context.js.map +2 -2
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +23 -0
- package/dist/cjs/str/numberformat.js.map +2 -2
- package/dist/cjs/strategy/index.d.ts +8 -0
- package/dist/cjs/strategy/index.d.ts.map +1 -1
- package/dist/cjs/strategy/index.js.map +1 -1
- package/dist/cjs/ta/running-sum.d.ts.map +1 -1
- package/dist/cjs/ta/running-sum.js +72 -3
- package/dist/cjs/ta/running-sum.js.map +2 -2
- package/dist/cjs/ta/step.d.ts +476 -0
- package/dist/cjs/ta/step.d.ts.map +1 -0
- package/dist/cjs/ta/step.js +1000 -0
- package/dist/cjs/ta/step.js.map +7 -0
- package/dist/cjs/ta-series.d.ts +1 -1
- package/dist/cjs/ta-series.js +3 -3
- package/dist/cjs/ta-series.js.map +1 -1
- package/dist/cjs/time/timezone.d.ts +13 -1
- package/dist/cjs/time/timezone.d.ts.map +1 -1
- package/dist/cjs/time/timezone.js +52 -13
- package/dist/cjs/time/timezone.js.map +2 -2
- package/dist/esm/check/format.d.ts.map +1 -1
- package/dist/esm/check/format.js +5 -0
- package/dist/esm/check/format.js.map +1 -1
- package/dist/esm/check/harness.d.ts +24 -0
- package/dist/esm/check/harness.d.ts.map +1 -1
- package/dist/esm/check/harness.js +40 -6
- package/dist/esm/check/harness.js.map +1 -1
- package/dist/esm/check/index.d.ts +9 -0
- package/dist/esm/check/index.d.ts.map +1 -1
- package/dist/esm/check/index.js +11 -1
- package/dist/esm/check/index.js.map +1 -1
- package/dist/esm/color/index.d.ts.map +1 -1
- package/dist/esm/color/index.js +23 -3
- package/dist/esm/color/index.js.map +1 -1
- package/dist/esm/color/parse.d.ts +8 -6
- package/dist/esm/color/parse.d.ts.map +1 -1
- package/dist/esm/color/parse.js +19 -2
- package/dist/esm/color/parse.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +32 -0
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +214 -51
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/runtime/series.d.ts +16 -0
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +21 -1
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/closure-writes.d.ts +16 -0
- package/dist/esm/script/closure-writes.d.ts.map +1 -0
- package/dist/esm/script/closure-writes.js +323 -0
- package/dist/esm/script/closure-writes.js.map +1 -0
- package/dist/esm/script/globals.d.ts +2 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/incremental.d.ts +140 -0
- package/dist/esm/script/incremental.d.ts.map +1 -0
- package/dist/esm/script/incremental.js +173 -0
- package/dist/esm/script/incremental.js.map +1 -0
- package/dist/esm/script/index.d.ts +116 -31
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +561 -24
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/session/bars.d.ts +3 -0
- package/dist/esm/session/bars.d.ts.map +1 -1
- package/dist/esm/session/bars.js +11 -3
- package/dist/esm/session/bars.js.map +1 -1
- package/dist/esm/session/calendar.d.ts +19 -6
- package/dist/esm/session/calendar.d.ts.map +1 -1
- package/dist/esm/session/calendar.js +74 -21
- package/dist/esm/session/calendar.js.map +1 -1
- package/dist/esm/session/context.d.ts.map +1 -1
- package/dist/esm/session/context.js +34 -9
- package/dist/esm/session/context.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +30 -0
- package/dist/esm/str/numberformat.js.map +1 -1
- package/dist/esm/strategy/index.d.ts +8 -0
- package/dist/esm/strategy/index.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.js +79 -4
- package/dist/esm/ta/running-sum.js.map +1 -1
- package/dist/esm/ta/step.d.ts +476 -0
- package/dist/esm/ta/step.d.ts.map +1 -0
- package/dist/esm/ta/step.js +1089 -0
- package/dist/esm/ta/step.js.map +1 -0
- package/dist/esm/ta-series.d.ts +1 -1
- package/dist/esm/ta-series.js +4 -4
- package/dist/esm/time/timezone.d.ts +13 -1
- package/dist/esm/time/timezone.d.ts.map +1 -1
- package/dist/esm/time/timezone.js +78 -17
- package/dist/esm/time/timezone.js.map +1 -1
- package/package.json +1 -1
- package/skills/oakscript/SKILL.md +2 -2
- package/skills/oakscript/reference/check.md +5 -0
- package/skills/oakscript/reference/errors.md +0 -1
- package/skills/oakscript/reference/pine-differences.md +1 -2
- package/skills/oakscript/reference/plotting.md +5 -7
- package/skills/oakscript/reference/script-structure.md +6 -0
- package/src/check/format.ts +7 -0
- package/src/check/harness.ts +57 -0
- package/src/check/index.ts +16 -0
- package/src/color/index.ts +22 -3
- package/src/color/parse.ts +28 -3
- package/src/drawing/registry.ts +233 -50
- package/src/index.ts +4 -1
- package/src/runtime/series.ts +33 -1
- package/src/script/closure-writes.ts +279 -0
- package/src/script/globals.ts +2 -0
- package/src/script/incremental.ts +246 -0
- package/src/script/index.ts +695 -26
- package/src/session/bars.ts +11 -3
- package/src/session/calendar.ts +84 -21
- package/src/session/context.ts +36 -9
- package/src/str/numberformat.ts +29 -0
- package/src/strategy/index.ts +8 -0
- package/src/ta/running-sum.ts +78 -3
- package/src/ta/step.ts +1145 -0
- package/src/ta-series.ts +4 -4
- package/src/time/timezone.ts +76 -15
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ta/step.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * ta.* functions one bar at a time (#196).\n *\n * Each machine is the state of one ta.* call. {@link BarStep.step} gives the result of the current bar from the kept\n * state of the earlier bars, without changing it: calling it again on the same bar (a live update of the forming bar,\n * or the same call in a loop) starts again from the same state. {@link BarStep.commit} ends the bar: its last step is\n * kept for the next bars. A bar without a step is not in the history of the call (a call in an `if` block), and a\n * commit without a step does nothing.\n *\n * Driven once per bar over an array (step, commit), a machine gives the doubles of the array function of `ta`, bit for\n * bit (tests/ta/step.test.ts): the same rules for na and \u00B1Infinity, the same operation order.\n */\nimport { RunningSum, isNa } from './running-sum.js';\nimport { checkPositiveLength, checkSumLength, checkWindowLength } from './limits.js';\nimport { eq, ge, gt, le } from '../compare/index.js';\n\nexport interface BarStep<A extends unknown[], R> {\n /** The result of the current bar from the state of the earlier bars (a later step of the same bar replaces it) */\n step(...args: A): R;\n /** The current bar is final: its last step is kept */\n commit(): void;\n}\n\n/** A value ta.* functions skip: na (NaN, null, undefined) or \u00B1Infinity. */\nconst skipped = (v: number): boolean => v === undefined || v === null || !Number.isFinite(v);\n\n// \u2500\u2500 Window sums \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * `math.sum(source, length)`: the correctly rounded sum of the last `length` non-na values; a bar with an na value\n * keeps the previous result. The length can change from one bar to the next (series length).\n */\nexport class SumStep implements BarStep<[value: number, length: number], number> {\n private readonly sum = new RunningSum();\n private stepped = false;\n\n step(value: number, length: number): number {\n const len = Math.floor(length);\n this.stepped = len >= 1;\n if (!this.stepped) return NaN;\n return isNa(value) ? this.sum.stepNa(len) : this.sum.step(value, len);\n }\n\n commit(): void {\n if (this.stepped) this.sum.commit();\n this.stepped = false;\n }\n\n /** Forget the steps of the current bar (the bar is not in the history) */\n discard(): void {\n this.stepped = false;\n }\n}\n\n/** `ta.sma(source, length)`: {@link SumStep} divided by the length. */\nexport class SmaStep implements BarStep<[value: number, length: number], number> {\n private readonly sum = new SumStep();\n\n step(value: number, length: number): number {\n checkSumLength('ta.sma', Math.floor(length), 0);\n return this.sum.step(value, length) / Math.floor(length);\n }\n\n commit(): void {\n this.sum.commit();\n }\n}\n\n/**\n * `ta.variance(source, length, biased)` from the window sums of the values and of their squares: biased\n * `sumSq / n - mean * mean`, unbiased `sumSq / (n - 1) - mean * sum / (n - 1)` (na for a length of 1).\n */\nexport class VarianceStep implements BarStep<[value: number, length: number, biased?: boolean], number> {\n private readonly sums = new SumStep();\n private readonly squares = new SumStep();\n\n constructor(private readonly name = 'ta.variance') {}\n\n step(value: number, length: number, biased = true): number {\n const len = Math.floor(length);\n checkSumLength(this.name, len, 0);\n const sum = this.sums.step(value, len);\n const sq = this.squares.step(isNa(value) ? NaN : value * value, len);\n if ((biased ? len : len - 1) <= 0) return NaN;\n const mean = sum / len;\n return biased ? sq / len - mean * mean : sq / (len - 1) - (mean * sum) / (len - 1);\n }\n\n commit(): void {\n this.sums.commit();\n this.squares.commit();\n }\n}\n\n/** `ta.stdev(source, length, biased)`: the square root of {@link VarianceStep} (0 when it is not positive). */\nexport class StdevStep implements BarStep<[value: number, length: number, biased?: boolean], number> {\n private readonly variance = new VarianceStep('ta.stdev');\n\n step(value: number, length: number, biased = true): number {\n const v = this.variance.step(value, length, biased);\n return Number.isNaN(v) ? NaN : v > 0 ? Math.sqrt(v) : 0;\n }\n\n commit(): void {\n this.variance.commit();\n }\n}\n\n// \u2500\u2500 Moving averages \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Exponential averages seeded with `ta.sma` on the bar of the `length`-th non-na value (ta.ema, ta.rma); a bar with an\n * na value gives na and keeps the state.\n */\nabstract class SeededAverage implements BarStep<[value: number], number> {\n private readonly seed = new SumStep();\n private value = NaN;\n private count = 0;\n private stepped = false;\n /** The last step of the bar added its value to the seed sum */\n private seeded = false;\n private nextValue = NaN;\n private nextCount = 0;\n protected readonly len: number;\n\n constructor(name: string, length: number) {\n checkPositiveLength(name, length, 0);\n this.len = Math.floor(length);\n }\n\n protected abstract next(value: number, previous: number): number;\n\n step(value: number): number {\n this.stepped = true;\n this.seeded = false;\n this.nextValue = this.value;\n this.nextCount = this.count;\n if (skipped(value)) return NaN;\n this.nextCount = this.count + 1;\n if (this.count < this.len) {\n this.seeded = true;\n const s = this.seed.step(value, this.len);\n if (this.nextCount < this.len) return NaN;\n this.nextValue = s / this.len;\n return this.nextValue;\n }\n this.nextValue = this.next(value, this.value);\n return this.nextValue;\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n if (this.seeded) this.seed.commit();\n else this.seed.discard();\n this.value = this.nextValue;\n this.count = this.nextCount;\n }\n}\n\n/** `ta.ema(source, length)`: `(source - ema) * 2 / (length + 1) + ema` after the seed. */\nexport class EmaStep extends SeededAverage {\n private readonly multiplier: number;\n\n constructor(length: number) {\n super('ema', length);\n this.multiplier = 2 / (this.len + 1);\n }\n\n protected next(value: number, previous: number): number {\n return (value - previous) * this.multiplier + previous;\n }\n}\n\n/** `ta.rma(source, length)`: `(source + (length - 1) * rma) / length` after the seed. */\nexport class RmaStep extends SeededAverage {\n constructor(length: number, name = 'rma') {\n super(name, length);\n }\n\n protected next(value: number, previous: number): number {\n return (value + (this.len - 1) * previous) / this.len;\n }\n}\n\n/** The PineScript ta.wma partial sum: `a + b`, 0 when `|a + b| <= 1e-10 * max(1, |a| + |b|)`. */\nfunction wmaAdd(a: number, b: number): number {\n const sum = a + b;\n return Math.abs(sum) <= 1e-10 * Math.max(1, Math.abs(a) + Math.abs(b)) ? 0 : sum;\n}\n\n/**\n * `ta.wma(source, length)`: na on a bar with an na value and until `length` non-na values; otherwise the last `length`\n * bars (an na bar holds the previous non-na value), summed from the oldest with the PineScript zero rule.\n */\nexport class WmaStep implements BarStep<[value: number, length: number], number> {\n private readonly filled: number[] = [];\n private last = NaN;\n private count = 0;\n private stepped = false;\n private nextFilled = NaN;\n private nextValid = false;\n\n step(value: number, length: number): number {\n const len = Math.floor(length);\n checkPositiveLength('wma', len, this.filled.length);\n this.stepped = true;\n const na = skipped(value);\n this.nextValid = !na;\n this.nextFilled = na ? this.last : value;\n if (na || !(len >= 1) || this.count + 1 < len) return NaN;\n const n = this.filled.length;\n let sum = 0;\n let weightSum = 0;\n for (let j = len - 1; j >= 0; j--) {\n const weight = len - j;\n sum = wmaAdd(sum, (j === 0 ? this.nextFilled : this.filled[n - j]!) * weight);\n weightSum += weight;\n }\n return sum / weightSum;\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n if (this.nextValid) {\n this.last = this.nextFilled;\n this.count++;\n }\n this.filled.push(this.nextFilled);\n }\n}\n\n// \u2500\u2500 Changes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** The values of the earlier bars of a call (one per bar with a step), for the `source[length]` of ta.change & co. */\nabstract class HistoryStep<A extends unknown[], R> implements BarStep<A, R> {\n protected readonly history: number[] = [];\n private stepped = false;\n private pending = NaN;\n\n /** The current bar's value, kept by commit() */\n protected keep(value: number): void {\n this.stepped = true;\n this.pending = value;\n }\n\n /** The value `k` bars back (k >= 1), NaN before the first bar */\n protected back(k: number): number {\n const i = this.history.length - k;\n return i >= 0 ? this.history[i]! : NaN;\n }\n\n abstract step(...args: A): R;\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n this.history.push(this.pending);\n }\n}\n\n/** `ta.change(source, length)`: `source - source[length]` (na for the first `length` bars). */\nexport class ChangeStep extends HistoryStep<[value: number], number> {\n constructor(private readonly length = 1) {\n super();\n checkPositiveLength('change', length, 0);\n }\n\n step(value: number): number {\n this.keep(value);\n return this.history.length < this.length ? NaN : value - this.back(this.length);\n }\n}\n\n/** `ta.mom(source, length)`: `source - source[length]`, na when either is na. */\nexport class MomStep extends HistoryStep<[value: number], number> {\n constructor(private readonly length: number) {\n super();\n checkPositiveLength('mom', length, 0);\n }\n\n step(value: number): number {\n this.keep(value);\n if (this.history.length < this.length) return NaN;\n const old = this.back(this.length);\n return Number.isNaN(value) || Number.isNaN(old) ? NaN : value - old;\n }\n}\n\n/** `ta.roc(source, length)`: `100 * (source - source[length]) / source[length]` (a zero base gives \u00B1Infinity). */\nexport class RocStep extends HistoryStep<[value: number], number> {\n constructor(private readonly length: number) {\n super();\n checkPositiveLength('roc', length, 0);\n }\n\n step(value: number): number {\n this.keep(value);\n if (this.history.length < this.length) return NaN;\n const old = this.back(this.length);\n if (Number.isNaN(old) || Number.isNaN(value)) return NaN;\n return (100 * (value - old)) / old;\n }\n}\n\n/** `ta.tr(handle_na)`: max(high - low, |high - close[1]|, |low - close[1]|); on the first bar or after an na close, na\n * (or high - low with handle_na). */\nexport class TrStep extends HistoryStep<[high: number, low: number, close: number], number> {\n constructor(private readonly handleNa = false) {\n super();\n }\n\n step(high: number, low: number, close: number): number {\n this.keep(close);\n const prev = this.back(1);\n if (this.history.length === 0 || Number.isNaN(prev)) return this.handleNa ? high - low : NaN;\n return Math.max(high - low, Math.abs(high - prev), Math.abs(low - prev));\n }\n}\n\n/** `ta.atr(length)`: {@link RmaStep} of `ta.tr(true)`. */\nexport class AtrStep implements BarStep<[high: number, low: number, close: number], number> {\n private readonly tr = new TrStep(true);\n private readonly rma: RmaStep;\n\n constructor(length: number) {\n checkPositiveLength('atr->rma', length, 0);\n this.rma = new RmaStep(length, 'atr->rma');\n }\n\n step(high: number, low: number, close: number): number {\n return this.rma.step(this.tr.step(high, low, close));\n }\n\n commit(): void {\n this.tr.commit();\n this.rma.commit();\n }\n}\n\n/**\n * `ta.rsi(source, length)`: the rma of the gains and of the losses of the changes from the previous bar; 100 when the\n * average loss is 0, else 0 when the average gain is 0 (comparisons with the 1e-10 tolerance).\n */\nexport class RsiStep extends HistoryStep<[value: number], number> {\n private readonly gains: RmaStep;\n private readonly losses: RmaStep;\n\n constructor(length: number) {\n super();\n checkPositiveLength('rsi', length, 0, 'y');\n this.gains = new RmaStep(length);\n this.losses = new RmaStep(length);\n }\n\n step(value: number): number {\n this.keep(value);\n if (this.history.length === 0) return NaN;\n const c = value - this.back(1);\n const up = this.gains.step(Number.isNaN(c) ? NaN : c > 0 ? c : 0);\n const down = this.losses.step(Number.isNaN(c) ? NaN : c < 0 ? -c : 0);\n if (eq(down, 0)) return 100;\n if (eq(up, 0)) return 0;\n return 100 - 100 / (1 + up / down);\n }\n\n override commit(): void {\n super.commit();\n this.gains.commit();\n this.losses.commit();\n }\n}\n\n// \u2500\u2500 Running state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** `ta.cum(source)`: the sum of the non-na values; na on a bar with an na value. */\nexport class CumStep implements BarStep<[value: number], number> {\n private sum = 0;\n private next = 0;\n private stepped = false;\n\n step(value: number): number {\n this.stepped = true;\n this.next = this.sum;\n if (!Number.isFinite(value)) return NaN;\n this.next = this.sum + value;\n return this.next;\n }\n\n commit(): void {\n if (this.stepped) this.sum = this.next;\n this.stepped = false;\n }\n}\n\n/** Compared with the last earlier bar where both values were not na (ta.crossover, ta.crossunder). */\nclass CrossTestStep implements BarStep<[a: number, b: number], boolean> {\n private prevA = NaN;\n private prevB = NaN;\n private nextA = NaN;\n private nextB = NaN;\n private stepped = false;\n\n constructor(private readonly test: (a: number, b: number, pa: number, pb: number) => boolean) {}\n\n step(a: number, b: number): boolean {\n this.stepped = true;\n const both = !Number.isNaN(a) && !Number.isNaN(b);\n this.nextA = both ? a : this.prevA;\n this.nextB = both ? b : this.prevB;\n return this.test(a, b, this.prevA, this.prevB);\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n this.prevA = this.nextA;\n this.prevB = this.nextB;\n }\n}\n\n/** `ta.crossover(a, b)` */\nexport class CrossoverStep extends CrossTestStep {\n constructor() {\n super((a, b, pa, pb) => a > b && pa <= pb);\n }\n}\n\n/** `ta.crossunder(a, b)` */\nexport class CrossunderStep extends CrossTestStep {\n constructor() {\n super((a, b, pa, pb) => a < b && pa >= pb);\n }\n}\n\n/** `ta.cross(a, b)`: true when the values are strictly on the other side of the last strict side. */\nexport class CrossStep implements BarStep<[a: number, b: number], boolean> {\n private side = 0;\n private next = 0;\n private stepped = false;\n\n step(a: number, b: number): boolean {\n this.stepped = true;\n this.next = this.side;\n if (Number.isNaN(a) || Number.isNaN(b)) return false;\n const crossed = (this.side < 0 && a > b) || (this.side > 0 && a < b);\n if (a < b) this.next = -1;\n else if (a > b) this.next = 1;\n return crossed;\n }\n\n commit(): void {\n if (this.stepped) this.side = this.next;\n this.stepped = false;\n }\n}\n\n/** `ta.barssince(condition)`: 0 on a true bar, then +1 per bar; na before the first true bar. */\nexport class BarssinceStep implements BarStep<[condition: boolean | number], number> {\n private value = NaN;\n private next = NaN;\n private stepped = false;\n\n step(condition: boolean | number): number {\n this.stepped = true;\n this.next = condition ? 0 : Number.isNaN(this.value) ? NaN : this.value + 1;\n return this.next;\n }\n\n commit(): void {\n if (this.stepped) this.value = this.next;\n this.stepped = false;\n }\n}\n\n/** `ta.valuewhen(condition, source, occurrence)`: the source value of the `occurrence`-th last true bar (0: the last). */\nexport class ValuewhenStep implements BarStep<[condition: boolean | number, value: number], number> {\n private readonly values: number[] = [];\n private pending: number | null = null;\n private stepped = false;\n\n constructor(private readonly occurrence: number) {}\n\n step(condition: boolean | number, value: number): number {\n this.stepped = true;\n this.pending = condition ? value : null;\n const n = this.values.length + (condition ? 1 : 0);\n const k = n - 1 - this.occurrence;\n if (k < 0 || k >= n) return NaN;\n return k === this.values.length ? value : (this.values[k] ?? NaN);\n }\n\n commit(): void {\n if (this.stepped && this.pending !== null) this.values.push(this.pending);\n this.stepped = false;\n this.pending = null;\n }\n}\n\n/** `ta.obv`: the cumulated `sign(close - close[1]) * volume` (na on the first bar). */\nexport class ObvStep extends HistoryStep<[close: number, volume: number], number> {\n private readonly cum = new CumStep();\n\n step(close: number, volume: number): number {\n this.keep(close);\n return this.cum.step(this.history.length === 0 ? NaN : Math.sign(close - this.back(1)) * volume);\n }\n\n override commit(): void {\n super.commit();\n this.cum.commit();\n }\n}\n\n// \u2500\u2500 Window extremes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * `ta.highest` / `ta.lowest`: the extreme of the last `length` non-na values (all of them when fewer), also on a bar\n * whose own value is na; na before bar `length - 1` and while no value was received. Math.max / Math.min of the\n * window: +0 wins over -0 for the highest, -0 for the lowest.\n */\nclass ExtremeStep implements BarStep<[value: number, length: number], number> {\n private readonly values: number[] = [];\n private bars = 0;\n private pending = NaN;\n private stepped = false;\n\n constructor(private readonly lowest: boolean) {}\n\n step(value: number, length: number): number {\n checkWindowLength(this.lowest ? 'lowest' : 'highest', length, this.bars);\n this.stepped = true;\n this.pending = value;\n const len = Math.trunc(length);\n const own = !skipped(value);\n const n = this.values.length + (own ? 1 : 0);\n if (this.bars < len - 1 || n === 0) return NaN;\n let best = own ? value : this.values[n - 1]!;\n const from = Math.max(0, n - len);\n for (let i = from; i < this.values.length; i++) {\n const v = this.values[i]!;\n best = this.lowest ? Math.min(best, v) : Math.max(best, v);\n }\n return best;\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n this.bars++;\n if (!skipped(this.pending)) this.values.push(this.pending);\n }\n}\n\n/** `ta.highest(source, length)` */\nexport class HighestStep extends ExtremeStep {\n constructor() {\n super(false);\n }\n}\n\n/** `ta.lowest(source, length)` */\nexport class LowestStep extends ExtremeStep {\n constructor() {\n super(true);\n }\n}\n\n// \u2500\u2500 Composites \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** `ta.macd(source, fast, slow, signal)`: `[macd, signal, histogram]`. */\nexport class MacdStep implements BarStep<[value: number], [number, number, number]> {\n private readonly fast: EmaStep;\n private readonly slow: EmaStep;\n private readonly signal: EmaStep;\n\n constructor(fastLength: number, slowLength: number, signalLength: number) {\n this.fast = new EmaStep(fastLength);\n this.slow = new EmaStep(slowLength);\n this.signal = new EmaStep(signalLength);\n }\n\n step(value: number): [number, number, number] {\n const line = this.fast.step(value) - this.slow.step(value);\n const signal = this.signal.step(line);\n return [line, signal, line - signal];\n }\n\n commit(): void {\n this.fast.commit();\n this.slow.commit();\n this.signal.commit();\n }\n}\n\n/** `ta.bb(source, length, mult)`: `[basis, upper, lower]`. */\nexport class BbStep implements BarStep<[value: number], [number, number, number]> {\n private readonly basis = new SumStep();\n private readonly dev = new StdevStep();\n private readonly len: number;\n\n constructor(length: number, private readonly mult: number) {\n checkSumLength('ta.bb', length, 0);\n this.len = Math.floor(length);\n }\n\n step(value: number): [number, number, number] {\n const basis = this.basis.step(value, this.len) / this.len;\n const dev = this.dev.step(value, this.len);\n return [basis, basis + this.mult * dev, basis - this.mult * dev];\n }\n\n commit(): void {\n this.basis.commit();\n this.dev.commit();\n }\n}\n\n/** `ta.vwma(source, length)`: `sma(source * volume) / sma(volume)`, na when the volume average is 0 or na. */\nexport class VwmaStep implements BarStep<[value: number, volume: number], number> {\n private readonly numerator = new SumStep();\n private readonly denominator = new SumStep();\n private readonly len: number;\n\n constructor(length: number) {\n checkPositiveLength('vwma->sma', length, 0);\n this.len = Math.floor(length);\n }\n\n step(value: number, volume: number): number {\n checkSumLength('ta.sma', this.len, 0);\n const num = this.numerator.step(value * volume, this.len) / this.len;\n const den = this.denominator.step(volume, this.len) / this.len;\n return den === 0 || Number.isNaN(den) ? NaN : num / den;\n }\n\n commit(): void {\n this.numerator.commit();\n this.denominator.commit();\n }\n}\n\n/**\n * `ta.stoch(source, high, low, length)`: `100 * (source - lowest(low)) / (highest(high) - lowest(low))`; an na result\n * keeps the previous one.\n */\nexport class StochStep implements BarStep<[source: number, high: number, low: number], number> {\n private readonly highest = new HighestStep();\n private readonly lowest = new LowestStep();\n private previous = NaN;\n private next = NaN;\n private stepped = false;\n\n constructor(private readonly length: number) {\n checkPositiveLength('stoch->highest', length, 0);\n }\n\n step(source: number, high: number, low: number): number {\n this.stepped = true;\n const lo = this.lowest.step(low, this.length);\n const k = (100 * (source - lo)) / (this.highest.step(high, this.length) - lo);\n this.next = Number.isNaN(k) ? this.previous : k;\n return this.next;\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n this.previous = this.next;\n this.highest.commit();\n this.lowest.commit();\n }\n}\n\n// \u2500\u2500 More composites \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** `ta.hma(source, length)`: wma(2 * wma(source, length / 2) - wma(source, length), floor(sqrt(length))). */\nexport class HmaStep implements BarStep<[value: number], number> {\n private readonly half = new WmaStep();\n private readonly full = new WmaStep();\n private readonly outer = new WmaStep();\n private readonly halfLength: number;\n private readonly sqrtLength: number;\n\n constructor(private readonly length: number) {\n checkPositiveLength('hma', length, 0);\n this.halfLength = Math.floor(length / 2);\n this.sqrtLength = Math.floor(Math.sqrt(length));\n }\n\n step(value: number): number {\n const diff = 2 * this.half.step(value, this.halfLength) - this.full.step(value, this.length);\n return this.outer.step(diff, this.sqrtLength);\n }\n\n commit(): void {\n this.half.commit();\n this.full.commit();\n this.outer.commit();\n }\n}\n\n/** `ta.dev(source, length)`: the mean of |source - sma| over the last `length` bars (na until bar length - 1). */\nexport class DevStep extends HistoryStep<[value: number], number> {\n private readonly mean = new SmaStep();\n private readonly len: number;\n\n constructor(length: number) {\n super();\n checkPositiveLength('dev', length, 0);\n this.len = Math.floor(length);\n }\n\n step(value: number): number {\n this.keep(value);\n const mean = this.mean.step(value, this.len);\n if (this.history.length < this.len - 1 || Number.isNaN(mean)) return NaN;\n let sum = 0;\n for (let k = 0; k < this.len; k++) sum += Math.abs((k === 0 ? value : this.back(k)) - mean);\n return sum / this.len;\n }\n\n override commit(): void {\n super.commit();\n this.mean.commit();\n }\n}\n\n/** `ta.cci(source, length)`: (source - sma) / (0.015 * dev); a zero dev keeps the previous value (0 at the start). */\nexport class CciStep implements BarStep<[value: number], number> {\n private readonly mean = new SmaStep();\n private readonly dev: DevStep;\n private last = 0;\n private next = 0;\n private stepped = false;\n\n constructor(private readonly length: number) {\n checkPositiveLength('cci', length, 0);\n this.dev = new DevStep(length);\n }\n\n step(value: number): number {\n this.stepped = true;\n this.next = this.last;\n const mean = this.mean.step(value, this.length);\n const d = this.dev.step(value);\n if (Number.isNaN(mean) || Number.isNaN(d)) return NaN;\n if (!eq(d, 0)) this.next = (value - mean) / (0.015 * d);\n return this.next;\n }\n\n commit(): void {\n if (this.stepped) this.last = this.next;\n this.stepped = false;\n this.mean.commit();\n this.dev.commit();\n }\n}\n\n/** `ta.mfi(source, length)`: the window sums of the money flow of the up and down bars. */\nexport class MfiStep extends HistoryStep<[value: number, volume: number], number> {\n private readonly upper = new SumStep();\n private readonly lower = new SumStep();\n\n constructor(private readonly length: number) {\n super();\n checkPositiveLength('mfi', length, 0);\n }\n\n step(value: number, volume: number): number {\n this.keep(value);\n const change = this.history.length === 0 ? NaN : value - this.back(1);\n const flow = volume * value;\n const zero = (x: number): number => (Math.abs(x) <= 1e-10 ? 0 : x);\n const u = zero(this.upper.step(le(change, 0) ? 0 : flow, this.length));\n const l = zero(this.lower.step(ge(change, 0) ? 0 : flow, this.length));\n if (Number.isNaN(u) || Number.isNaN(l)) return NaN;\n if (l === 0) return 100;\n const ratio = 1 + u / l;\n return ratio === 0 ? NaN : 100 - 100 / ratio;\n }\n\n override commit(): void {\n super.commit();\n this.upper.commit();\n this.lower.commit();\n }\n}\n\n/** `ta.dmi(diLength, adxSmoothing)`: [+DI, -DI, ADX]; a DI that cannot be computed keeps the previous one. */\nexport class DmiStep implements BarStep<[high: number, low: number, close: number], [number, number, number]> {\n private readonly tr = new TrStep(false);\n private readonly trur: RmaStep;\n private readonly plus: RmaStep;\n private readonly minus: RmaStep;\n private readonly adx: RmaStep;\n private prevHigh = NaN;\n private prevLow = NaN;\n private bars = 0;\n private lastPlus = NaN;\n private lastMinus = NaN;\n private next: [number, number, number, number] = [NaN, NaN, NaN, NaN];\n private stepped = false;\n\n constructor(diLength: number, adxSmoothing: number) {\n this.trur = new RmaStep(diLength);\n this.plus = new RmaStep(diLength);\n this.minus = new RmaStep(diLength);\n this.adx = new RmaStep(adxSmoothing);\n }\n\n step(high: number, low: number, close: number): [number, number, number] {\n this.stepped = true;\n const up = this.bars === 0 ? NaN : high - this.prevHigh;\n const down = this.bars === 0 ? NaN : this.prevLow - low;\n const plusDM = Number.isNaN(up) ? NaN : gt(up, down) && gt(up, 0) ? up : 0;\n const minusDM = Number.isNaN(down) ? NaN : gt(down, up) && gt(down, 0) ? down : 0;\n const t = this.trur.step(this.tr.step(high, low, close));\n const directional = (v: number, last: number): number => {\n const value = t === 0 ? NaN : (100 * v) / t;\n return Number.isNaN(value) ? last : value;\n };\n const plus = directional(this.plus.step(plusDM), this.lastPlus);\n const minus = directional(this.minus.step(minusDM), this.lastMinus);\n const sum = plus + minus;\n const dx = Math.abs(plus - minus) / (eq(sum, 0) ? 1 : sum);\n const adx = 100 * this.adx.step(dx);\n this.next = [plus, minus, high, low];\n return [plus, minus, adx];\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n [this.lastPlus, this.lastMinus, this.prevHigh, this.prevLow] = this.next;\n this.bars++;\n this.tr.commit();\n this.trur.commit();\n this.plus.commit();\n this.minus.commit();\n this.adx.commit();\n }\n}\n\n/** `ta.linreg(source, length, offset)`: least squares line of the last `length` bars (na when one of them is NaN). */\nexport class LinregStep extends HistoryStep<[value: number], number> {\n private readonly len: number;\n\n constructor(length: number, private readonly offset = 0) {\n super();\n checkPositiveLength('linreg', length, 0);\n this.len = Math.floor(length);\n }\n\n step(value: number): number {\n this.keep(value);\n const len = this.len;\n if (this.history.length < len - 1) return NaN;\n const at = (j: number): number => (j === len - 1 ? value : this.back(len - 1 - j));\n for (let j = 0; j < len; j++) if (isNaN(at(j))) return NaN;\n let sumX = 0;\n let sumY = 0;\n let sumXY = 0;\n let sumX2 = 0;\n for (let j = 0; j < len; j++) {\n const x = j + 1;\n const y = at(j);\n sumX += x;\n sumY += y;\n sumXY += x * y;\n sumX2 += x * x;\n }\n const slope = (len * sumXY - sumX * sumY) / (len * sumX2 - sumX * sumX);\n const intercept = sumY / len - (slope * sumX) / len + slope;\n return intercept + slope * (len - 1 - this.offset);\n }\n}\n\n/** `ta.percentrank(source, length)`: the percentage of the `length` bars before that are less than or equal to the bar. */\nexport class PercentrankStep extends HistoryStep<[value: number], number> {\n constructor(private readonly length: number) {\n super();\n checkPositiveLength('percentrank', length, 0);\n }\n\n step(value: number): number {\n this.keep(value);\n if (this.history.length < this.length) return NaN;\n let count = 0;\n for (let j = 1; j <= this.length; j++) if (le(this.back(j), value)) count++;\n return (count * 100) / this.length;\n }\n}\n\n/** `ta.median(source, length)`: the median of the last `length` non-na values (sorted as ta.median keeps them). */\nexport class MedianStep implements BarStep<[value: number], number> {\n private sorted: number[] = [];\n private readonly kept: number[] = [];\n private nextSorted: number[] | null = null;\n private nextValue: number | null = null;\n private stepped = false;\n private readonly len: number;\n\n constructor(length: number) {\n checkPositiveLength('median', length, 0);\n this.len = Math.floor(length);\n }\n\n private static bound(sorted: readonly number[], v: number, after: boolean): number {\n let lo = 0;\n let hi = sorted.length;\n while (lo < hi) {\n const m = (lo + hi) >> 1;\n if (after ? sorted[m]! <= v : sorted[m]! < v) lo = m + 1;\n else hi = m;\n }\n return lo;\n }\n\n step(value: number): number {\n this.stepped = true;\n const len = this.len;\n let sorted = this.sorted;\n let count = this.kept.length;\n this.nextValue = null;\n this.nextSorted = null;\n if (Number.isFinite(value)) {\n sorted = sorted.slice();\n count++;\n sorted.splice(MedianStep.bound(sorted, value, false), 0, value);\n // the value that leaves the window: kept[count - 1 - len] in the order of the kept values (this one is last)\n if (count > len) {\n const k = count - 1 - len;\n const leaving = k === this.kept.length ? value : this.kept[k]!;\n sorted.splice(MedianStep.bound(sorted, leaving, true) - 1, 1);\n }\n this.nextValue = value;\n this.nextSorted = sorted;\n }\n if (!(len >= 1) || count < len) return NaN;\n const mid = Math.floor(len / 2);\n return len % 2 === 0 ? (sorted[mid - 1]! + sorted[mid]!) / 2 : sorted[mid]!;\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n if (this.nextValue !== null) {\n this.kept.push(this.nextValue);\n this.sorted = this.nextSorted!;\n }\n }\n}\n\n/** `ta.correlation(source1, source2, length)`: covariance over the square root of the two variances. */\nexport class CorrelationStep implements BarStep<[a: number, b: number], number> {\n private readonly meanXY = new SmaStep();\n private readonly meanX = new SmaStep();\n private readonly meanY = new SmaStep();\n private readonly varX = new VarianceStep();\n private readonly varY = new VarianceStep();\n\n constructor(private readonly length: number) {\n checkPositiveLength('correlation', length, 0);\n }\n\n step(a: number, b: number): number {\n const product = a === null || a === undefined || b === null || b === undefined ? NaN : a * b;\n const mxy = this.meanXY.step(product, this.length);\n const cov = mxy - this.meanX.step(a, this.length) * this.meanY.step(b, this.length);\n const vx = this.varX.step(a, this.length);\n const vy = this.varY.step(b, this.length);\n if (Number.isNaN(cov)) return NaN;\n if (Math.abs(cov) <= 1e-10) return 0;\n const denominator = Math.sqrt(vx * vy);\n return denominator === 0 ? NaN : cov / denominator;\n }\n\n commit(): void {\n this.meanXY.commit();\n this.meanX.commit();\n this.meanY.commit();\n this.varX.commit();\n this.varY.commit();\n }\n}\n\n/** `ta.wpr(length)`: 100 * (close - highest(high)) / (highest(high) - lowest(low)); na on a zero range. */\nexport class WprStep implements BarStep<[high: number, low: number, close: number], number> {\n private readonly highest = new HighestStep();\n private readonly lowest = new LowestStep();\n\n constructor(private readonly length = 14) {\n checkPositiveLength('wpr', length, 0);\n }\n\n step(high: number, low: number, close: number): number {\n const hmax = this.highest.step(high, this.length);\n const range = hmax - this.lowest.step(low, this.length);\n return range === 0 ? NaN : (100 * (close - hmax)) / range;\n }\n\n commit(): void {\n this.highest.commit();\n this.lowest.commit();\n }\n}\n\n/** `ta.supertrend(factor, atrPeriod)`: [supertrend, direction] (bands from hl2 and the atr, as ta.supertrend). */\nexport class SupertrendStep implements BarStep<[high: number, low: number, close: number], [number, number]> {\n private readonly atr: AtrStep;\n private lastLower = NaN;\n private lastUpper = NaN;\n private prevSuperTrend = NaN;\n private prevAtr = NaN;\n private prevHigh = NaN;\n private prevLow = NaN;\n private bars = 0;\n private next: [number, number, number, number, number, number] = [NaN, NaN, NaN, NaN, NaN, NaN];\n private stepped = false;\n\n constructor(private readonly factor: number, atrPeriod: number, private readonly wicks = false) {\n this.atr = new AtrStep(atrPeriod);\n }\n\n step(high: number, low: number, close: number): [number, number] {\n this.stepped = true;\n const nz = (v: number): number => (isNaN(v) ? 0 : v);\n const source = (high + low) / 2;\n const atr = this.atr.step(high, low, close);\n const atrValue = atr * this.factor;\n let upperBand = source + atrValue;\n let lowerBand = source - atrValue;\n const prevLowerBand = nz(this.lastLower);\n const prevUpperBand = nz(this.lastUpper);\n const highPrice = this.wicks ? high : close;\n const lowPrice = this.wicks ? low : close;\n const prevLowPrice = this.bars > 0 ? this.prevLow : NaN;\n const prevHighPrice = this.bars > 0 ? this.prevHigh : NaN;\n lowerBand = lowerBand > prevLowerBand || prevLowPrice < prevLowerBand ? lowerBand : prevLowerBand;\n upperBand = upperBand < prevUpperBand || prevHighPrice > prevUpperBand ? upperBand : prevUpperBand;\n let direction: number;\n if (this.bars === 0 || isNaN(this.prevAtr)) direction = 1;\n else if (this.prevSuperTrend === prevUpperBand) direction = highPrice > upperBand ? -1 : 1;\n else direction = lowPrice < lowerBand ? 1 : -1;\n const superTrend = direction === -1 ? lowerBand : upperBand;\n this.next = [lowerBand, upperBand, superTrend, atr, highPrice, lowPrice];\n return [superTrend, direction];\n }\n\n commit(): void {\n if (!this.stepped) return;\n this.stepped = false;\n [this.lastLower, this.lastUpper, this.prevSuperTrend, this.prevAtr, this.prevHigh, this.prevLow] = this.next;\n this.bars++;\n this.atr.commit();\n }\n}\n\n// \u2500\u2500 Factories (PineScript names) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * One machine per ta.* call, by PineScript name (#196): `const ema = taStep.ema(14)`, then on each bar\n * `ema.step(close)` (again on the same bar for a live update of the forming bar) and `ema.commit()` when the bar is\n * final. Driven once per bar over an array, a machine gives the doubles of the `ta` / `taCore` function.\n * The window functions take their length on each step (a series length is allowed); the others at creation.\n */\nexport const taStep = {\n /** `math.sum(source, length)`: step(value, length) */\n sum: (): SumStep => new SumStep(),\n /** `ta.sma(source, length)`: step(value, length) */\n sma: (): SmaStep => new SmaStep(),\n /** `ta.variance(source, length, biased)`: step(value, length, biased?) */\n variance: (): VarianceStep => new VarianceStep(),\n /** `ta.stdev(source, length, biased)`: step(value, length, biased?) */\n stdev: (): StdevStep => new StdevStep(),\n /** `ta.ema(source, length)`: step(value) */\n ema: (length: number): EmaStep => new EmaStep(length),\n /** `ta.rma(source, length)`: step(value) */\n rma: (length: number): RmaStep => new RmaStep(length),\n /** `ta.wma(source, length)`: step(value, length) */\n wma: (): WmaStep => new WmaStep(),\n /** `ta.change(source, length)`: step(value) */\n change: (length = 1): ChangeStep => new ChangeStep(length),\n /** `ta.mom(source, length)`: step(value) */\n mom: (length: number): MomStep => new MomStep(length),\n /** `ta.roc(source, length)`: step(value) */\n roc: (length: number): RocStep => new RocStep(length),\n /** `ta.tr(handle_na)`: step(high, low, close) */\n tr: (handle_na = false): TrStep => new TrStep(handle_na),\n /** `ta.atr(length)`: step(high, low, close) */\n atr: (length: number): AtrStep => new AtrStep(length),\n /** `ta.rsi(source, length)`: step(value) */\n rsi: (length: number): RsiStep => new RsiStep(length),\n /** `ta.cum(source)`: step(value) */\n cum: (): CumStep => new CumStep(),\n /** `ta.crossover(a, b)`: step(a, b) */\n crossover: (): CrossoverStep => new CrossoverStep(),\n /** `ta.crossunder(a, b)`: step(a, b) */\n crossunder: (): CrossunderStep => new CrossunderStep(),\n /** `ta.cross(a, b)`: step(a, b) */\n cross: (): CrossStep => new CrossStep(),\n /** `ta.barssince(condition)`: step(condition) */\n barssince: (): BarssinceStep => new BarssinceStep(),\n /** `ta.valuewhen(condition, source, occurrence)`: step(condition, value) */\n valuewhen: (occurrence: number): ValuewhenStep => new ValuewhenStep(occurrence),\n /** `ta.obv`: step(close, volume) */\n obv: (): ObvStep => new ObvStep(),\n /** `ta.highest(source, length)`: step(value, length) */\n highest: (): HighestStep => new HighestStep(),\n /** `ta.lowest(source, length)`: step(value, length) */\n lowest: (): LowestStep => new LowestStep(),\n /** `ta.macd(source, fast, slow, signal)`: step(value) gives [macd, signal, histogram] */\n macd: (fastLength: number, slowLength: number, signalLength: number): MacdStep =>\n new MacdStep(fastLength, slowLength, signalLength),\n /** `ta.bb(source, length, mult)`: step(value) gives [basis, upper, lower] */\n bb: (length: number, mult: number): BbStep => new BbStep(length, mult),\n /** `ta.vwma(source, length)`: step(value, volume) */\n vwma: (length: number): VwmaStep => new VwmaStep(length),\n /** `ta.stoch(source, high, low, length)`: step(source, high, low) */\n stoch: (length: number): StochStep => new StochStep(length),\n /** `ta.hma(source, length)`: step(value) */\n hma: (length: number): HmaStep => new HmaStep(length),\n /** `ta.dev(source, length)`: step(value) */\n dev: (length: number): DevStep => new DevStep(length),\n /** `ta.cci(source, length)`: step(value) */\n cci: (length: number): CciStep => new CciStep(length),\n /** `ta.mfi(source, length)`: step(value, volume) */\n mfi: (length: number): MfiStep => new MfiStep(length),\n /** `ta.dmi(diLength, adxSmoothing)`: step(high, low, close) gives [plus, minus, adx] */\n dmi: (diLength: number, adxSmoothing: number): DmiStep => new DmiStep(diLength, adxSmoothing),\n /** `ta.linreg(source, length, offset)`: step(value), called on every bar (in an if block: callsite.linreg) */\n linreg: (length: number, offset = 0): LinregStep => new LinregStep(length, offset),\n /** `ta.percentrank(source, length)`: step(value) */\n percentrank: (length: number): PercentrankStep => new PercentrankStep(length),\n /** `ta.median(source, length)`: step(value) */\n median: (length: number): MedianStep => new MedianStep(length),\n /** `ta.correlation(source1, source2, length)`: step(a, b) */\n correlation: (length: number): CorrelationStep => new CorrelationStep(length),\n /** `ta.wpr(length)`: step(high, low, close) */\n wpr: (length = 14): WprStep => new WprStep(length),\n /** `ta.supertrend(factor, atrPeriod)`: step(high, low, close) gives [supertrend, direction] */\n supertrend: (factor: number, atrPeriod: number): SupertrendStep => new SupertrendStep(factor, atrPeriod),\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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,IAAI,gBAAgB,MAAM;AAAA;AAAA,EAE5E,KAAK,CAAC,SAAS,OAAgB,IAAI,QAAQ,MAAM;AAAA;AAAA,EAEjD,YAAY,CAAC,QAAgB,cAAsC,IAAI,eAAe,QAAQ,SAAS;AACzG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/ta-series.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare function macd(source: Series, fastLength: number, slowLength: num
|
|
|
54
54
|
* @param source - Source series
|
|
55
55
|
* @param length - Period length
|
|
56
56
|
* @param mult - Standard deviation multiplier
|
|
57
|
-
* @returns Tuple of [upper,
|
|
57
|
+
* @returns Tuple of [middle, upper, lower] Series, as PineScript `[middle, upper, lower] = ta.bb(...)`
|
|
58
58
|
*/
|
|
59
59
|
export declare function bb(source: Series, length: number, mult: number): [Series, Series, Series];
|
|
60
60
|
/**
|
package/dist/cjs/ta-series.js
CHANGED
|
@@ -144,11 +144,11 @@ function macd(source, fastLength, slowLength, signalLength) {
|
|
|
144
144
|
function bb(source, length, mult) {
|
|
145
145
|
const bars = source.bars;
|
|
146
146
|
const sourceValues = source.toArray();
|
|
147
|
-
const [
|
|
148
|
-
const upperSeries = import_series.Series.fromArray(bars, upperVals);
|
|
147
|
+
const [basisVals, upperVals, lowerVals] = taCore.bb(sourceValues, length, mult);
|
|
149
148
|
const basisSeries = import_series.Series.fromArray(bars, basisVals);
|
|
149
|
+
const upperSeries = import_series.Series.fromArray(bars, upperVals);
|
|
150
150
|
const lowerSeries = import_series.Series.fromArray(bars, lowerVals);
|
|
151
|
-
return [
|
|
151
|
+
return [basisSeries, upperSeries, lowerSeries];
|
|
152
152
|
}
|
|
153
153
|
function stdev(source, length, biased = true) {
|
|
154
154
|
const bars = source.bars;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ta-series.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Technical analysis functions that work with Series\n * Fixed wrappers around core ta.* functions with O(n) performance\n * @module ta-series\n */\n\nimport * as taCore from './ta/index.js';\nimport { Series } from './runtime/series.js';\nimport type { Bar } from './types/index.js';\n\n/**\n * Simple Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with SMA values\n */\nexport function sma(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.sma(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Exponential Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with EMA values\n */\nexport function ema(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.ema(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Weighted Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with WMA values\n */\nexport function wma(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.wma(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Relative Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with RMA values\n */\nexport function rma(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.rma(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Relative Strength Index\n * @param source - Source series\n * @param length - Period length\n * @returns Series with RSI values\n */\nexport function rsi(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n // a Series as second argument: PineScript v4 rsi(x, y) of two averages (#180)\n const result = length instanceof Series ? taCore.rsi(sourceValues, length.toArray()) : taCore.rsi(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Moving Average Convergence Divergence\n * @param source - Source series\n * @param fastLength - Fast EMA period\n * @param slowLength - Slow EMA period\n * @param signalLength - Signal line period\n * @returns Tuple of [macdLine, signalLine, histogram] Series\n */\nexport function macd(\n source: Series,\n fastLength: number,\n slowLength: number,\n signalLength: number\n): [Series, Series, Series] {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const [macdVals, signalVals, histVals] = taCore.macd(sourceValues, fastLength, slowLength, signalLength);\n\n const macdSeries = Series.fromArray(bars, macdVals);\n const signalSeries = Series.fromArray(bars, signalVals);\n const histSeries = Series.fromArray(bars, histVals);\n\n return [macdSeries, signalSeries, histSeries];\n}\n\n/**\n * Bollinger Bands\n * @param source - Source series\n * @param length - Period length\n * @param mult - Standard deviation multiplier\n * @returns Tuple of [upper, basis, lower] Series\n */\nexport function bb(source: Series, length: number, mult: number): [Series, Series, Series] {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const [upperVals, basisVals, lowerVals] = taCore.bb(sourceValues, length, mult);\n\n const upperSeries = Series.fromArray(bars, upperVals);\n const basisSeries = Series.fromArray(bars, basisVals);\n const lowerSeries = Series.fromArray(bars, lowerVals);\n\n return [upperSeries, basisSeries, lowerSeries];\n}\n\n /**\n * Standard deviation (PineScript ta.stdev; biased by default)\n * @param source - Source series\n * @param length - Period length\n * @param biased - true (default): divide by length; false: by length - 1\n * @returns Series with standard deviation values\n */\n export function stdev(source: Series, length: number | Series, biased: boolean = true): Series {\n const bars = source.bars as Bar[];\n const len = length instanceof Series ? length.toArray() : length;\n return Series.fromArray(bars, taCore.stdev(source.toArray(), len, biased));\n }\n \n\n/**\n * Average True Range\n * @param bars - Bar data\n * @param length - Period length\n * @returns Series with ATR values\n */\nexport function atr(bars: Bar[], length: number): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.atr(length, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n/**\n * True Range\n * @param bars - Bar data\n * @param handle_na - How NaN values are handled (default: false)\n * @returns Series with TR values\n */\nexport function tr(bars: Bar[], handle_na: boolean = false): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.tr(handle_na, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n// Volume built-in variables. PineScript exposes them as variables of the chart bars\n// (`ta.obv`); here they take the bars.\n\nconst col = (bars: Bar[], f: 'open' | 'high' | 'low' | 'close' | 'volume'): number[] =>\n bars.map((b) => b[f] ?? NaN);\n\n/** On Balance Volume (PineScript `ta.obv`) */\nexport function obv(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.obv(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Price-Volume Trend (PineScript `ta.pvt`) */\nexport function pvt(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.pvt(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Accumulation/Distribution index (PineScript `ta.accdist`) */\nexport function accdist(bars: Bar[]): Series {\n return Series.fromArray(\n bars,\n taCore.accdist(col(bars, 'high'), col(bars, 'low'), col(bars, 'close'), col(bars, 'volume'))\n );\n}\n\n/** Negative Volume Index (PineScript `ta.nvi`) */\nexport function nvi(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.nvi(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Positive Volume Index (PineScript `ta.pvi`) */\nexport function pvi(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.pvi(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Intraday Intensity Index (PineScript `ta.iii`) */\nexport function iii(bars: Bar[]): Series {\n return Series.fromArray(\n bars,\n taCore.iii(col(bars, 'high'), col(bars, 'low'), col(bars, 'close'), col(bars, 'volume'))\n );\n}\n\n/** Williams Accumulation/Distribution (PineScript `ta.wad`) */\nexport function wad(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.wad(col(bars, 'high'), col(bars, 'low'), col(bars, 'close')));\n}\n\n/** Williams Variable Accumulation/Distribution (PineScript `ta.wvad`) */\nexport function wvad(bars: Bar[]): Series {\n return Series.fromArray(\n bars,\n taCore.wvad(col(bars, 'open'), col(bars, 'high'), col(bars, 'low'), col(bars, 'close'), col(bars, 'volume'))\n );\n}\n\n/**\n * Stochastic %K\n * @param source - Source series (typically close)\n * @param high - High series\n * @param low - Low series\n * @param length - Period length\n * @returns Series with stochastic values\n */\nexport function stoch(source: Series, high: Series, low: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const highValues = high.toArray();\n const lowValues = low.toArray();\n const result = taCore.stoch(sourceValues, highValues, lowValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Crossover detection\n * @param source1 - First series\n * @param source2 - Second series or number\n * @returns Series with 1 where crossover, 0 otherwise\n */\nexport function crossover(source1: Series, source2: Series | number): Series {\n const bars = source1.bars as Bar[];\n const vals1 = source1.toArray();\n const vals2 = typeof source2 === 'number'\n ? Array(bars.length).fill(source2)\n : source2.toArray();\n\n const result = taCore.crossover(vals1, vals2);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Crossunder detection\n * @param source1 - First series\n * @param source2 - Second series or number\n * @returns Series with 1 where crossunder, 0 otherwise\n */\nexport function crossunder(source1: Series, source2: Series | number): Series {\n const bars = source1.bars as Bar[];\n const vals1 = source1.toArray();\n const vals2 = typeof source2 === 'number'\n ? Array(bars.length).fill(source2)\n : source2.toArray();\n\n const result = taCore.crossunder(vals1, vals2);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Cross detection\n * @param source1 - First series\n * @param source2 - Second series or number\n * @returns Series with 1 where cross, 0 otherwise\n */\nexport function cross(source1: Series, source2: Series | number): Series {\n const bars = source1.bars as Bar[];\n const vals1 = source1.toArray();\n const vals2 = typeof source2 === 'number'\n ? Array(bars.length).fill(source2)\n : source2.toArray();\n\n const result = taCore.cross(vals1, vals2);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Change (difference from previous value)\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with change values\n */\nexport function change(source: Series, length: number = 1): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.change(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Momentum\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with momentum values\n */\nexport function mom(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.mom(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Rate of Change\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with ROC values\n */\nexport function roc(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.roc(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Highest value in period\n * @param source - Source series\n * @param length - Period length\n * @returns Series with highest values\n */\nexport function highest(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.highest(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Lowest value in period\n * @param source - Source series\n * @param length - Period length\n * @returns Series with lowest values\n */\nexport function lowest(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.lowest(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Rising detection\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with 1 where rising, 0 otherwise\n */\nexport function rising(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.rising(sourceValues, length);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Falling detection\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with 1 where falling, 0 otherwise\n */\nexport function falling(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.falling(sourceValues, length);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Cumulative sum\n * @param source - Source series\n * @returns Series with cumulative sum values\n */\nexport function cum(source: Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.cum(sourceValues);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Supertrend indicator\n * @param bars - Bar data\n * @param factor - Multiplier factor\n * @param atrLength - ATR period length\n * @returns Tuple of [supertrend, direction] Series\n */\nexport function supertrend(bars: Bar[], factor: number, atrLength: number): [Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [trendVals, dirVals] = taCore.supertrend(factor, atrLength, high, low, close);\n\n const trendSeries = Series.fromArray(bars, trendVals);\n const dirSeries = Series.fromArray(bars, dirVals);\n\n return [trendSeries, dirSeries];\n}\n\n /**\n * Volume Weighted Average Price (PineScript ta.vwap)\n * @param source - Source series\n * @param volume - Volume series\n * @param anchor - Reset condition (non-zero = reset); without it the sums never restart\n * @returns Series with VWAP values\n */\n export function vwap(source: Series, volume: Series, anchor?: Series): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.vwap(source.toArray(), volume.toArray(), anchor?.toArray()));\n }\n\n /**\n * VWAP with standard deviation bands (PineScript `[vwap, upper, lower] = ta.vwap(source, anchor, stdev_mult)`)\n * @returns [vwap, upper, lower] Series\n */\n export function vwapBands(source: Series, volume: Series, anchor: Series | undefined, stdev_mult: number): [Series, Series, Series] {\n const bars = source.bars as Bar[];\n const [m, u, l] = taCore.vwap(source.toArray(), volume.toArray(), anchor?.toArray(), stdev_mult);\n return [Series.fromArray(bars, m), Series.fromArray(bars, u), Series.fromArray(bars, l)];\n }\n \n\n/**\n * Ichimoku Kinko Hyo (Ichimoku Cloud)\n * @param bars - Bar data\n * @param conversionPeriods - Period for Tenkan-sen (default: 9)\n * @param basePeriods - Period for Kijun-sen (default: 26)\n * @param laggingSpan2Periods - Period for Senkou Span B (default: 52)\n * @param displacement - Displacement for Senkou Spans and Chikou Span (default: 26)\n * @returns Tuple of [tenkanSen, kijunSen, senkouSpanA, senkouSpanB, chikouSpan] Series\n */\nexport function ichimoku(\n bars: Bar[],\n conversionPeriods: number,\n basePeriods: number,\n laggingSpan2Periods: number,\n displacement: number\n): [Series, Series, Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [tenkan, kijun, senkouA, senkouB, chikou] = taCore.ichimoku(\n conversionPeriods,\n basePeriods,\n laggingSpan2Periods,\n displacement,\n high,\n low,\n close\n );\n\n return [\n Series.fromArray(bars, tenkan),\n Series.fromArray(bars, kijun),\n Series.fromArray(bars, senkouA),\n Series.fromArray(bars, senkouB),\n Series.fromArray(bars, chikou),\n ];\n}\n\n/**\n * Volume Weighted Moving Average\n * @param source - Source series\n * @param length - Period length\n * @param volume - Volume series\n * @returns Series with VWMA values\n */\nexport function vwma(source: Series, length: number, volume: Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const volumeValues = volume.toArray();\n const result = taCore.vwma(sourceValues, length, volumeValues);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Linear Regression\n * @param source - Source series\n * @param length - Period length\n * @param offset - Offset (default: 0)\n * @returns Series with linear regression values\n */\nexport function linreg(source: Series, length: number, offset: number = 0): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.linreg(sourceValues, length, offset);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Arnaud Legoux Moving Average\n * @param source - Source series\n * @param length - Period length (default: 9)\n * @param offset - Controls tradeoff between smoothness and responsiveness (default: 0.85)\n * @param sigma - Standard deviation factor for sharpness (default: 6)\n * @param floor - Whether to floor the offset calculation (default: false)\n * @returns Series with ALMA values\n */\nexport function alma(source: Series, length: number = 9, offset: number = 0.85, sigma: number = 6, floor: boolean = false): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.alma(sourceValues, length, offset, sigma, floor);\n return Series.fromArray(bars, result);\n}\n\n/**\n * ZigZag indicator - identifies significant trend reversals\n * @param bars - Bar data\n * @param deviation - Minimum percentage price change to form a new pivot (default: 5.0)\n * @param depth - Minimum bars between pivots (default: 10)\n * @param backstep - Bars to look back for confirmation (default: 3)\n * @returns Tuple of [zigzag values, direction, isPivot flags] Series\n * @remarks\n * - The isPivot Series contains numeric values (1 for pivot, 0 for non-pivot)\n * converted from boolean for consistency with other Series-based functions\n * - The core ta.zigzag() function returns boolean isPivot values\n */\nexport function zigzag(\n bars: Bar[],\n deviation: number = 5,\n depth: number = 10,\n backstep: number = 3\n): [Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n\n const [zigzagVals, dirVals, pivotVals] = taCore.zigzag(\n deviation, depth, backstep, undefined, high, low\n );\n\n // Convert boolean pivot flags to numbers (1/0) for Series compatibility\n return [\n Series.fromArray(bars, zigzagVals),\n Series.fromArray(bars, dirVals),\n Series.fromArray(bars, pivotVals.map(b => b ? 1 : 0)),\n ];\n}\n\n/**\n * Commodity Channel Index\n * @param source - Source series (typically hlc3)\n * @param length - Period length\n * @returns Series with CCI values\n */\nexport function cci(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.cci(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Parabolic SAR (Stop and Reverse)\n * @param bars - Bar data\n * @param start - Initial acceleration factor (default: 0.02)\n * @param inc - Acceleration factor increment (default: 0.02)\n * @param max - Maximum acceleration factor (default: 0.2)\n * @returns Series with SAR values\n */\nexport function sar(bars: Bar[], start: number = 0.02, inc: number = 0.02, max: number = 0.2): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.sar(start, inc, max, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Deviation\n * @param source - Source series\n * @param length - Period length\n * @returns Series with deviation values\n */\nexport function dev(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.dev(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Variance\n * @param source - Source series\n * @param length - Period length\n * @param biased - Use biased estimation (default: true)\n * @returns Series with variance values\n */\nexport function variance(source: Series, length: number | Series, biased: boolean = true): Series {\n const bars = source.bars as Bar[];\n const result = taCore.variance(source.toArray(), length instanceof Series ? length.toArray() : length, biased);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Median\n * @param source - Source series\n * @param length - Period length\n * @returns Series with median values\n */\nexport function median(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.median(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Symmetrically Weighted Moving Average\n * @param source - Source series\n * @returns Series with SWMA values\n */\nexport function swma(source: Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.swma(source.toArray());\n return Series.fromArray(bars, result);\n}\n\n/**\n * Correlation\n * @param source1 - First source series\n * @param source2 - Second source series\n * @param length - Period length\n * @returns Series with correlation values\n */\nexport function correlation(source1: Series, source2: Series, length: number): Series {\n const bars = source1.bars as Bar[];\n const result = taCore.correlation(source1.toArray(), source2.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Percent Rank\n * @param source - Source series\n * @param length - Period length\n * @returns Series with percent rank values\n */\nexport function percentrank(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.percentrank(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Money Flow Index\n * @param source - Source series (typically hlc3)\n * @param length - Period length\n * @param volume - Volume series\n * @returns Series with MFI values\n */\nexport function mfi(source: Series, length: number, volume: Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.mfi(source.toArray(), length, volume.toArray());\n return Series.fromArray(bars, result);\n}\n\n/**\n * Hull Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with HMA values\n */\nexport function hma(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.hma(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Pivot High\n * @param source - Source series\n * @param leftbars - Number of bars to the left of the pivot\n * @param rightbars - Number of bars to the right of the pivot\n * @returns Series with the pivot high value on the bar where the pivot is confirmed,\n * `rightbars` bars after the pivot bar (as in PineScript), NaN elsewhere\n */\nexport function pivothigh(source: Series, leftbars: number | Series, rightbars: number | Series): Series {\n const bars = source.bars as Bar[];\n const arr = (v: number | Series) => (v instanceof Series ? v.toArray() : v);\n const result = taCore.pivothigh(source.toArray(), arr(leftbars), arr(rightbars));\n return Series.fromArray(bars, result);\n}\n\n/**\n * Pivot Low\n * @param source - Source series\n * @param leftbars - Number of bars to the left of the pivot\n * @param rightbars - Number of bars to the right of the pivot\n * @returns Series with the pivot low value on the bar where the pivot is confirmed,\n * `rightbars` bars after the pivot bar (as in PineScript), NaN elsewhere\n */\nexport function pivotlow(source: Series, leftbars: number | Series, rightbars: number | Series): Series {\n const bars = source.bars as Bar[];\n const arr = (v: number | Series) => (v instanceof Series ? v.toArray() : v);\n const result = taCore.pivotlow(source.toArray(), arr(leftbars), arr(rightbars));\n return Series.fromArray(bars, result);\n}\n\n/**\n * Bars Since condition was true\n * @param condition - Boolean series (1/0 values)\n * @returns Series with bar count since condition was last true\n */\nexport function barssince(condition: Series): Series {\n const bars = condition.bars as Bar[];\n const boolValues = condition.toArray().map(v => v === 1);\n const result = taCore.barssince(boolValues);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Value When condition was true\n * @param condition - Boolean series (1/0 values)\n * @param source - Source series to extract values from\n * @param occurrence - Which occurrence to use (0 = most recent)\n * @returns Series with values from source when condition was true\n */\nexport function valuewhen(condition: Series, source: Series, occurrence: number): Series {\n const bars = condition.bars as Bar[];\n const boolValues = condition.toArray().map(v => v === 1);\n const result = taCore.valuewhen(boolValues, source.toArray(), occurrence);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Directional Movement Index\n * @param bars - Bar data\n * @param diLength - DI period length\n * @param adxSmoothing - ADX smoothing period\n * @returns Tuple of [plusDI, minusDI, adx] Series\n */\nexport function dmi(bars: Bar[], diLength: number, adxSmoothing: number): [Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [plusDI, minusDI, adx] = taCore.dmi(diLength, adxSmoothing, high, low, close);\n return [\n Series.fromArray(bars, plusDI),\n Series.fromArray(bars, minusDI),\n Series.fromArray(bars, adx),\n ];\n}\n\n/**\n * True Strength Index\n * @param source - Source series\n * @param shortLength - Short smoothing period\n * @param longLength - Long smoothing period\n * @returns Series with TSI values, in [-1, 1] as PineScript\n */\nexport function tsi(source: Series, shortLength: number, longLength: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.tsi(source.toArray(), shortLength, longLength);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Chande Momentum Oscillator\n * @param source - Source series\n * @param length - Period length\n * @returns Series with CMO values\n */\nexport function cmo(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.cmo(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Keltner Channel\n * @param bars - Bar data\n * @param source - Source series\n * @param length - Period length\n * @param mult - Multiplier\n * @param useTrueRange - Use true range (default: true)\n * @returns Tuple of [middle, upper, lower] Series\n */\nexport function kc(bars: Bar[], source: Series, length: number, mult: number, useTrueRange: boolean = true): [Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [middle, upper, lower] = taCore.kc(source.toArray(), length, mult, useTrueRange, high, low, close);\n return [\n Series.fromArray(bars, middle),\n Series.fromArray(bars, upper),\n Series.fromArray(bars, lower),\n ];\n}\n\n/**\n * Bollinger Bands Width\n * @param source - Source series\n * @param length - Period length\n * @param mult - Standard deviation multiplier\n * @returns Series with BBW values\n */\nexport function bbw(source: Series, length: number, mult: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.bbw(source.toArray(), length, mult);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Williams %R\n * @param bars - Bar data\n * @param length - Period length (default: 14)\n * @returns Series with Williams %R values\n */\nexport function wpr(bars: Bar[], length: number = 14): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.wpr(high, low, close, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Keltner Channel Width\n * @param bars - Bar data\n * @param source - Source series\n * @param length - Period length (default: 20)\n * @param mult - Multiplier (default: 2)\n * @param useTrueRange - Use true range (default: true)\n * @returns Series with KCW values\n */\nexport function kcw(bars: Bar[], source: Series, length: number = 20, mult: number = 2, useTrueRange: boolean = true): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.kcw(source.toArray(), length, mult, useTrueRange, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n /**\n * Range: highest minus lowest value over the last `length` non-na values (PineScript ta.range)\n * @param source - Source series\n * @param length - Number of values\n * @returns Series with range values\n */\n export function range(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.range(source.toArray(), length));\n }\n \n\n/**\n * Highest Bars - offset to the highest value\n * @param source - Source series\n * @param length - Period length\n * @returns Series with bar offsets to highest value\n */\nexport function highestbars(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.highestbars(source.toArray(), length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Lowest Bars - offset to the lowest value\n * @param source - Source series\n * @param length - Period length\n * @returns Series with bar offsets to lowest value\n */\nexport function lowestbars(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.lowestbars(source.toArray(), length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n /**\n * All-time highest value (PineScript ta.max)\n * @param source - Source series\n * @returns Series with the highest value up to each bar\n */\n export function max(source: Series): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.max(source.toArray()));\n }\n \n\n /**\n * All-time lowest value (PineScript ta.min)\n * @param source - Source series\n * @returns Series with the lowest value up to each bar\n */\n export function min(source: Series): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.min(source.toArray()));\n }\n \n\n/**\n * Center of Gravity\n * @param source - Source series\n * @param length - Period length (default: 10)\n * @returns Series with COG values\n */\nexport function cog(source: Series, length: number = 10): Series {\n const bars = source.bars as Bar[];\n const result = taCore.cog(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Mode (most frequent value)\n * @param source - Source series\n * @param length - Period length\n * @returns Series with mode values\n */\nexport function mode(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.mode(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Percentile (linear interpolation)\n * @param source - Source series\n * @param length - Period length\n * @param percentage - Percentile percentage\n * @returns Series with percentile values\n */\nexport function percentile_linear_interpolation(source: Series, length: number, percentage: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.percentile_linear_interpolation(source.toArray(), length, percentage);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Percentile (nearest rank)\n * @param source - Source series\n * @param length - Period length\n * @param percentage - Percentile percentage\n * @returns Series with percentile values\n */\nexport function percentile_nearest_rank(source: Series, length: number, percentage: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.percentile_nearest_rank(source.toArray(), length, percentage);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Rank Correlation Index\n * @param source - Source series\n * @param length - Period length\n * @returns Series with RCI values\n */\nexport function rci(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.rci(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n// Export as namespace object to match PineScript ta.* syntax\nexport const ta = {\n sma,\n ema,\n wma,\n vwma,\n rma,\n rsi,\n macd,\n bb,\n stdev,\n atr,\n tr,\n stoch,\n crossover,\n crossunder,\n cross,\n change,\n mom,\n roc,\n highest,\n lowest,\n rising,\n falling,\n cum,\n supertrend,\n vwap,\n ichimoku,\n linreg,\n alma,\n zigzag,\n cci,\n sar,\n dev,\n variance,\n median,\n swma,\n correlation,\n percentrank,\n mfi,\n hma,\n pivothigh,\n pivotlow,\n barssince,\n valuewhen,\n dmi,\n tsi,\n cmo,\n kc,\n bbw,\n wpr,\n kcw,\n range,\n highestbars,\n lowestbars,\n max,\n min,\n vwapBands,\n obv,\n pvt,\n accdist,\n nvi,\n pvi,\n iii,\n wad,\n wvad,\n cog,\n mode,\n percentile_linear_interpolation,\n percentile_nearest_rank,\n rci,\n};\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Technical analysis functions that work with Series\n * Fixed wrappers around core ta.* functions with O(n) performance\n * @module ta-series\n */\n\nimport * as taCore from './ta/index.js';\nimport { Series } from './runtime/series.js';\nimport type { Bar } from './types/index.js';\n\n/**\n * Simple Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with SMA values\n */\nexport function sma(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.sma(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Exponential Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with EMA values\n */\nexport function ema(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.ema(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Weighted Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with WMA values\n */\nexport function wma(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.wma(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Relative Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with RMA values\n */\nexport function rma(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.rma(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Relative Strength Index\n * @param source - Source series\n * @param length - Period length\n * @returns Series with RSI values\n */\nexport function rsi(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n // a Series as second argument: PineScript v4 rsi(x, y) of two averages (#180)\n const result = length instanceof Series ? taCore.rsi(sourceValues, length.toArray()) : taCore.rsi(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Moving Average Convergence Divergence\n * @param source - Source series\n * @param fastLength - Fast EMA period\n * @param slowLength - Slow EMA period\n * @param signalLength - Signal line period\n * @returns Tuple of [macdLine, signalLine, histogram] Series\n */\nexport function macd(\n source: Series,\n fastLength: number,\n slowLength: number,\n signalLength: number\n): [Series, Series, Series] {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const [macdVals, signalVals, histVals] = taCore.macd(sourceValues, fastLength, slowLength, signalLength);\n\n const macdSeries = Series.fromArray(bars, macdVals);\n const signalSeries = Series.fromArray(bars, signalVals);\n const histSeries = Series.fromArray(bars, histVals);\n\n return [macdSeries, signalSeries, histSeries];\n}\n\n/**\n * Bollinger Bands\n * @param source - Source series\n * @param length - Period length\n * @param mult - Standard deviation multiplier\n * @returns Tuple of [middle, upper, lower] Series, as PineScript `[middle, upper, lower] = ta.bb(...)`\n */\nexport function bb(source: Series, length: number, mult: number): [Series, Series, Series] {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const [basisVals, upperVals, lowerVals] = taCore.bb(sourceValues, length, mult);\n\n const basisSeries = Series.fromArray(bars, basisVals);\n const upperSeries = Series.fromArray(bars, upperVals);\n const lowerSeries = Series.fromArray(bars, lowerVals);\n\n return [basisSeries, upperSeries, lowerSeries];\n}\n\n /**\n * Standard deviation (PineScript ta.stdev; biased by default)\n * @param source - Source series\n * @param length - Period length\n * @param biased - true (default): divide by length; false: by length - 1\n * @returns Series with standard deviation values\n */\n export function stdev(source: Series, length: number | Series, biased: boolean = true): Series {\n const bars = source.bars as Bar[];\n const len = length instanceof Series ? length.toArray() : length;\n return Series.fromArray(bars, taCore.stdev(source.toArray(), len, biased));\n }\n \n\n/**\n * Average True Range\n * @param bars - Bar data\n * @param length - Period length\n * @returns Series with ATR values\n */\nexport function atr(bars: Bar[], length: number): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.atr(length, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n/**\n * True Range\n * @param bars - Bar data\n * @param handle_na - How NaN values are handled (default: false)\n * @returns Series with TR values\n */\nexport function tr(bars: Bar[], handle_na: boolean = false): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.tr(handle_na, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n// Volume built-in variables. PineScript exposes them as variables of the chart bars\n// (`ta.obv`); here they take the bars.\n\nconst col = (bars: Bar[], f: 'open' | 'high' | 'low' | 'close' | 'volume'): number[] =>\n bars.map((b) => b[f] ?? NaN);\n\n/** On Balance Volume (PineScript `ta.obv`) */\nexport function obv(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.obv(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Price-Volume Trend (PineScript `ta.pvt`) */\nexport function pvt(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.pvt(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Accumulation/Distribution index (PineScript `ta.accdist`) */\nexport function accdist(bars: Bar[]): Series {\n return Series.fromArray(\n bars,\n taCore.accdist(col(bars, 'high'), col(bars, 'low'), col(bars, 'close'), col(bars, 'volume'))\n );\n}\n\n/** Negative Volume Index (PineScript `ta.nvi`) */\nexport function nvi(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.nvi(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Positive Volume Index (PineScript `ta.pvi`) */\nexport function pvi(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.pvi(col(bars, 'close'), col(bars, 'volume')));\n}\n\n/** Intraday Intensity Index (PineScript `ta.iii`) */\nexport function iii(bars: Bar[]): Series {\n return Series.fromArray(\n bars,\n taCore.iii(col(bars, 'high'), col(bars, 'low'), col(bars, 'close'), col(bars, 'volume'))\n );\n}\n\n/** Williams Accumulation/Distribution (PineScript `ta.wad`) */\nexport function wad(bars: Bar[]): Series {\n return Series.fromArray(bars, taCore.wad(col(bars, 'high'), col(bars, 'low'), col(bars, 'close')));\n}\n\n/** Williams Variable Accumulation/Distribution (PineScript `ta.wvad`) */\nexport function wvad(bars: Bar[]): Series {\n return Series.fromArray(\n bars,\n taCore.wvad(col(bars, 'open'), col(bars, 'high'), col(bars, 'low'), col(bars, 'close'), col(bars, 'volume'))\n );\n}\n\n/**\n * Stochastic %K\n * @param source - Source series (typically close)\n * @param high - High series\n * @param low - Low series\n * @param length - Period length\n * @returns Series with stochastic values\n */\nexport function stoch(source: Series, high: Series, low: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const highValues = high.toArray();\n const lowValues = low.toArray();\n const result = taCore.stoch(sourceValues, highValues, lowValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Crossover detection\n * @param source1 - First series\n * @param source2 - Second series or number\n * @returns Series with 1 where crossover, 0 otherwise\n */\nexport function crossover(source1: Series, source2: Series | number): Series {\n const bars = source1.bars as Bar[];\n const vals1 = source1.toArray();\n const vals2 = typeof source2 === 'number'\n ? Array(bars.length).fill(source2)\n : source2.toArray();\n\n const result = taCore.crossover(vals1, vals2);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Crossunder detection\n * @param source1 - First series\n * @param source2 - Second series or number\n * @returns Series with 1 where crossunder, 0 otherwise\n */\nexport function crossunder(source1: Series, source2: Series | number): Series {\n const bars = source1.bars as Bar[];\n const vals1 = source1.toArray();\n const vals2 = typeof source2 === 'number'\n ? Array(bars.length).fill(source2)\n : source2.toArray();\n\n const result = taCore.crossunder(vals1, vals2);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Cross detection\n * @param source1 - First series\n * @param source2 - Second series or number\n * @returns Series with 1 where cross, 0 otherwise\n */\nexport function cross(source1: Series, source2: Series | number): Series {\n const bars = source1.bars as Bar[];\n const vals1 = source1.toArray();\n const vals2 = typeof source2 === 'number'\n ? Array(bars.length).fill(source2)\n : source2.toArray();\n\n const result = taCore.cross(vals1, vals2);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Change (difference from previous value)\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with change values\n */\nexport function change(source: Series, length: number = 1): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.change(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Momentum\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with momentum values\n */\nexport function mom(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.mom(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Rate of Change\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with ROC values\n */\nexport function roc(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.roc(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Highest value in period\n * @param source - Source series\n * @param length - Period length\n * @returns Series with highest values\n */\nexport function highest(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.highest(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Lowest value in period\n * @param source - Source series\n * @param length - Period length\n * @returns Series with lowest values\n */\nexport function lowest(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.lowest(sourceValues, length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Rising detection\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with 1 where rising, 0 otherwise\n */\nexport function rising(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.rising(sourceValues, length);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Falling detection\n * @param source - Source series\n * @param length - Lookback period\n * @returns Series with 1 where falling, 0 otherwise\n */\nexport function falling(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.falling(sourceValues, length);\n // Convert boolean array to number array\n const numResult = result.map(b => b ? 1 : 0);\n return Series.fromArray(bars, numResult);\n}\n\n/**\n * Cumulative sum\n * @param source - Source series\n * @returns Series with cumulative sum values\n */\nexport function cum(source: Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.cum(sourceValues);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Supertrend indicator\n * @param bars - Bar data\n * @param factor - Multiplier factor\n * @param atrLength - ATR period length\n * @returns Tuple of [supertrend, direction] Series\n */\nexport function supertrend(bars: Bar[], factor: number, atrLength: number): [Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [trendVals, dirVals] = taCore.supertrend(factor, atrLength, high, low, close);\n\n const trendSeries = Series.fromArray(bars, trendVals);\n const dirSeries = Series.fromArray(bars, dirVals);\n\n return [trendSeries, dirSeries];\n}\n\n /**\n * Volume Weighted Average Price (PineScript ta.vwap)\n * @param source - Source series\n * @param volume - Volume series\n * @param anchor - Reset condition (non-zero = reset); without it the sums never restart\n * @returns Series with VWAP values\n */\n export function vwap(source: Series, volume: Series, anchor?: Series): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.vwap(source.toArray(), volume.toArray(), anchor?.toArray()));\n }\n\n /**\n * VWAP with standard deviation bands (PineScript `[vwap, upper, lower] = ta.vwap(source, anchor, stdev_mult)`)\n * @returns [vwap, upper, lower] Series\n */\n export function vwapBands(source: Series, volume: Series, anchor: Series | undefined, stdev_mult: number): [Series, Series, Series] {\n const bars = source.bars as Bar[];\n const [m, u, l] = taCore.vwap(source.toArray(), volume.toArray(), anchor?.toArray(), stdev_mult);\n return [Series.fromArray(bars, m), Series.fromArray(bars, u), Series.fromArray(bars, l)];\n }\n \n\n/**\n * Ichimoku Kinko Hyo (Ichimoku Cloud)\n * @param bars - Bar data\n * @param conversionPeriods - Period for Tenkan-sen (default: 9)\n * @param basePeriods - Period for Kijun-sen (default: 26)\n * @param laggingSpan2Periods - Period for Senkou Span B (default: 52)\n * @param displacement - Displacement for Senkou Spans and Chikou Span (default: 26)\n * @returns Tuple of [tenkanSen, kijunSen, senkouSpanA, senkouSpanB, chikouSpan] Series\n */\nexport function ichimoku(\n bars: Bar[],\n conversionPeriods: number,\n basePeriods: number,\n laggingSpan2Periods: number,\n displacement: number\n): [Series, Series, Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [tenkan, kijun, senkouA, senkouB, chikou] = taCore.ichimoku(\n conversionPeriods,\n basePeriods,\n laggingSpan2Periods,\n displacement,\n high,\n low,\n close\n );\n\n return [\n Series.fromArray(bars, tenkan),\n Series.fromArray(bars, kijun),\n Series.fromArray(bars, senkouA),\n Series.fromArray(bars, senkouB),\n Series.fromArray(bars, chikou),\n ];\n}\n\n/**\n * Volume Weighted Moving Average\n * @param source - Source series\n * @param length - Period length\n * @param volume - Volume series\n * @returns Series with VWMA values\n */\nexport function vwma(source: Series, length: number, volume: Series): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const volumeValues = volume.toArray();\n const result = taCore.vwma(sourceValues, length, volumeValues);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Linear Regression\n * @param source - Source series\n * @param length - Period length\n * @param offset - Offset (default: 0)\n * @returns Series with linear regression values\n */\nexport function linreg(source: Series, length: number, offset: number = 0): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.linreg(sourceValues, length, offset);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Arnaud Legoux Moving Average\n * @param source - Source series\n * @param length - Period length (default: 9)\n * @param offset - Controls tradeoff between smoothness and responsiveness (default: 0.85)\n * @param sigma - Standard deviation factor for sharpness (default: 6)\n * @param floor - Whether to floor the offset calculation (default: false)\n * @returns Series with ALMA values\n */\nexport function alma(source: Series, length: number = 9, offset: number = 0.85, sigma: number = 6, floor: boolean = false): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.alma(sourceValues, length, offset, sigma, floor);\n return Series.fromArray(bars, result);\n}\n\n/**\n * ZigZag indicator - identifies significant trend reversals\n * @param bars - Bar data\n * @param deviation - Minimum percentage price change to form a new pivot (default: 5.0)\n * @param depth - Minimum bars between pivots (default: 10)\n * @param backstep - Bars to look back for confirmation (default: 3)\n * @returns Tuple of [zigzag values, direction, isPivot flags] Series\n * @remarks\n * - The isPivot Series contains numeric values (1 for pivot, 0 for non-pivot)\n * converted from boolean for consistency with other Series-based functions\n * - The core ta.zigzag() function returns boolean isPivot values\n */\nexport function zigzag(\n bars: Bar[],\n deviation: number = 5,\n depth: number = 10,\n backstep: number = 3\n): [Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n\n const [zigzagVals, dirVals, pivotVals] = taCore.zigzag(\n deviation, depth, backstep, undefined, high, low\n );\n\n // Convert boolean pivot flags to numbers (1/0) for Series compatibility\n return [\n Series.fromArray(bars, zigzagVals),\n Series.fromArray(bars, dirVals),\n Series.fromArray(bars, pivotVals.map(b => b ? 1 : 0)),\n ];\n}\n\n/**\n * Commodity Channel Index\n * @param source - Source series (typically hlc3)\n * @param length - Period length\n * @returns Series with CCI values\n */\nexport function cci(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const sourceValues = source.toArray();\n const result = taCore.cci(sourceValues, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Parabolic SAR (Stop and Reverse)\n * @param bars - Bar data\n * @param start - Initial acceleration factor (default: 0.02)\n * @param inc - Acceleration factor increment (default: 0.02)\n * @param max - Maximum acceleration factor (default: 0.2)\n * @returns Series with SAR values\n */\nexport function sar(bars: Bar[], start: number = 0.02, inc: number = 0.02, max: number = 0.2): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.sar(start, inc, max, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Deviation\n * @param source - Source series\n * @param length - Period length\n * @returns Series with deviation values\n */\nexport function dev(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.dev(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Variance\n * @param source - Source series\n * @param length - Period length\n * @param biased - Use biased estimation (default: true)\n * @returns Series with variance values\n */\nexport function variance(source: Series, length: number | Series, biased: boolean = true): Series {\n const bars = source.bars as Bar[];\n const result = taCore.variance(source.toArray(), length instanceof Series ? length.toArray() : length, biased);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Median\n * @param source - Source series\n * @param length - Period length\n * @returns Series with median values\n */\nexport function median(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.median(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Symmetrically Weighted Moving Average\n * @param source - Source series\n * @returns Series with SWMA values\n */\nexport function swma(source: Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.swma(source.toArray());\n return Series.fromArray(bars, result);\n}\n\n/**\n * Correlation\n * @param source1 - First source series\n * @param source2 - Second source series\n * @param length - Period length\n * @returns Series with correlation values\n */\nexport function correlation(source1: Series, source2: Series, length: number): Series {\n const bars = source1.bars as Bar[];\n const result = taCore.correlation(source1.toArray(), source2.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Percent Rank\n * @param source - Source series\n * @param length - Period length\n * @returns Series with percent rank values\n */\nexport function percentrank(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.percentrank(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Money Flow Index\n * @param source - Source series (typically hlc3)\n * @param length - Period length\n * @param volume - Volume series\n * @returns Series with MFI values\n */\nexport function mfi(source: Series, length: number, volume: Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.mfi(source.toArray(), length, volume.toArray());\n return Series.fromArray(bars, result);\n}\n\n/**\n * Hull Moving Average\n * @param source - Source series\n * @param length - Period length\n * @returns Series with HMA values\n */\nexport function hma(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.hma(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Pivot High\n * @param source - Source series\n * @param leftbars - Number of bars to the left of the pivot\n * @param rightbars - Number of bars to the right of the pivot\n * @returns Series with the pivot high value on the bar where the pivot is confirmed,\n * `rightbars` bars after the pivot bar (as in PineScript), NaN elsewhere\n */\nexport function pivothigh(source: Series, leftbars: number | Series, rightbars: number | Series): Series {\n const bars = source.bars as Bar[];\n const arr = (v: number | Series) => (v instanceof Series ? v.toArray() : v);\n const result = taCore.pivothigh(source.toArray(), arr(leftbars), arr(rightbars));\n return Series.fromArray(bars, result);\n}\n\n/**\n * Pivot Low\n * @param source - Source series\n * @param leftbars - Number of bars to the left of the pivot\n * @param rightbars - Number of bars to the right of the pivot\n * @returns Series with the pivot low value on the bar where the pivot is confirmed,\n * `rightbars` bars after the pivot bar (as in PineScript), NaN elsewhere\n */\nexport function pivotlow(source: Series, leftbars: number | Series, rightbars: number | Series): Series {\n const bars = source.bars as Bar[];\n const arr = (v: number | Series) => (v instanceof Series ? v.toArray() : v);\n const result = taCore.pivotlow(source.toArray(), arr(leftbars), arr(rightbars));\n return Series.fromArray(bars, result);\n}\n\n/**\n * Bars Since condition was true\n * @param condition - Boolean series (1/0 values)\n * @returns Series with bar count since condition was last true\n */\nexport function barssince(condition: Series): Series {\n const bars = condition.bars as Bar[];\n const boolValues = condition.toArray().map(v => v === 1);\n const result = taCore.barssince(boolValues);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Value When condition was true\n * @param condition - Boolean series (1/0 values)\n * @param source - Source series to extract values from\n * @param occurrence - Which occurrence to use (0 = most recent)\n * @returns Series with values from source when condition was true\n */\nexport function valuewhen(condition: Series, source: Series, occurrence: number): Series {\n const bars = condition.bars as Bar[];\n const boolValues = condition.toArray().map(v => v === 1);\n const result = taCore.valuewhen(boolValues, source.toArray(), occurrence);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Directional Movement Index\n * @param bars - Bar data\n * @param diLength - DI period length\n * @param adxSmoothing - ADX smoothing period\n * @returns Tuple of [plusDI, minusDI, adx] Series\n */\nexport function dmi(bars: Bar[], diLength: number, adxSmoothing: number): [Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [plusDI, minusDI, adx] = taCore.dmi(diLength, adxSmoothing, high, low, close);\n return [\n Series.fromArray(bars, plusDI),\n Series.fromArray(bars, minusDI),\n Series.fromArray(bars, adx),\n ];\n}\n\n/**\n * True Strength Index\n * @param source - Source series\n * @param shortLength - Short smoothing period\n * @param longLength - Long smoothing period\n * @returns Series with TSI values, in [-1, 1] as PineScript\n */\nexport function tsi(source: Series, shortLength: number, longLength: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.tsi(source.toArray(), shortLength, longLength);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Chande Momentum Oscillator\n * @param source - Source series\n * @param length - Period length\n * @returns Series with CMO values\n */\nexport function cmo(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.cmo(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Keltner Channel\n * @param bars - Bar data\n * @param source - Source series\n * @param length - Period length\n * @param mult - Multiplier\n * @param useTrueRange - Use true range (default: true)\n * @returns Tuple of [middle, upper, lower] Series\n */\nexport function kc(bars: Bar[], source: Series, length: number, mult: number, useTrueRange: boolean = true): [Series, Series, Series] {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const [middle, upper, lower] = taCore.kc(source.toArray(), length, mult, useTrueRange, high, low, close);\n return [\n Series.fromArray(bars, middle),\n Series.fromArray(bars, upper),\n Series.fromArray(bars, lower),\n ];\n}\n\n/**\n * Bollinger Bands Width\n * @param source - Source series\n * @param length - Period length\n * @param mult - Standard deviation multiplier\n * @returns Series with BBW values\n */\nexport function bbw(source: Series, length: number, mult: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.bbw(source.toArray(), length, mult);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Williams %R\n * @param bars - Bar data\n * @param length - Period length (default: 14)\n * @returns Series with Williams %R values\n */\nexport function wpr(bars: Bar[], length: number = 14): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.wpr(high, low, close, length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Keltner Channel Width\n * @param bars - Bar data\n * @param source - Source series\n * @param length - Period length (default: 20)\n * @param mult - Multiplier (default: 2)\n * @param useTrueRange - Use true range (default: true)\n * @returns Series with KCW values\n */\nexport function kcw(bars: Bar[], source: Series, length: number = 20, mult: number = 2, useTrueRange: boolean = true): Series {\n const high = bars.map(b => b.high);\n const low = bars.map(b => b.low);\n const close = bars.map(b => b.close);\n const result = taCore.kcw(source.toArray(), length, mult, useTrueRange, high, low, close);\n return Series.fromArray(bars, result);\n}\n\n /**\n * Range: highest minus lowest value over the last `length` non-na values (PineScript ta.range)\n * @param source - Source series\n * @param length - Number of values\n * @returns Series with range values\n */\n export function range(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.range(source.toArray(), length));\n }\n \n\n/**\n * Highest Bars - offset to the highest value\n * @param source - Source series\n * @param length - Period length\n * @returns Series with bar offsets to highest value\n */\nexport function highestbars(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.highestbars(source.toArray(), length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Lowest Bars - offset to the lowest value\n * @param source - Source series\n * @param length - Period length\n * @returns Series with bar offsets to lowest value\n */\nexport function lowestbars(source: Series, length: number | Series): Series {\n const bars = source.bars as Bar[];\n const result = taCore.lowestbars(source.toArray(), length instanceof Series ? length.toArray() : length);\n return Series.fromArray(bars, result);\n}\n\n /**\n * All-time highest value (PineScript ta.max)\n * @param source - Source series\n * @returns Series with the highest value up to each bar\n */\n export function max(source: Series): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.max(source.toArray()));\n }\n \n\n /**\n * All-time lowest value (PineScript ta.min)\n * @param source - Source series\n * @returns Series with the lowest value up to each bar\n */\n export function min(source: Series): Series {\n const bars = source.bars as Bar[];\n return Series.fromArray(bars, taCore.min(source.toArray()));\n }\n \n\n/**\n * Center of Gravity\n * @param source - Source series\n * @param length - Period length (default: 10)\n * @returns Series with COG values\n */\nexport function cog(source: Series, length: number = 10): Series {\n const bars = source.bars as Bar[];\n const result = taCore.cog(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Mode (most frequent value)\n * @param source - Source series\n * @param length - Period length\n * @returns Series with mode values\n */\nexport function mode(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.mode(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Percentile (linear interpolation)\n * @param source - Source series\n * @param length - Period length\n * @param percentage - Percentile percentage\n * @returns Series with percentile values\n */\nexport function percentile_linear_interpolation(source: Series, length: number, percentage: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.percentile_linear_interpolation(source.toArray(), length, percentage);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Percentile (nearest rank)\n * @param source - Source series\n * @param length - Period length\n * @param percentage - Percentile percentage\n * @returns Series with percentile values\n */\nexport function percentile_nearest_rank(source: Series, length: number, percentage: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.percentile_nearest_rank(source.toArray(), length, percentage);\n return Series.fromArray(bars, result);\n}\n\n/**\n * Rank Correlation Index\n * @param source - Source series\n * @param length - Period length\n * @returns Series with RCI values\n */\nexport function rci(source: Series, length: number): Series {\n const bars = source.bars as Bar[];\n const result = taCore.rci(source.toArray(), length);\n return Series.fromArray(bars, result);\n}\n\n// Export as namespace object to match PineScript ta.* syntax\nexport const ta = {\n sma,\n ema,\n wma,\n vwma,\n rma,\n rsi,\n macd,\n bb,\n stdev,\n atr,\n tr,\n stoch,\n crossover,\n crossunder,\n cross,\n change,\n mom,\n roc,\n highest,\n lowest,\n rising,\n falling,\n cum,\n supertrend,\n vwap,\n ichimoku,\n linreg,\n alma,\n zigzag,\n cci,\n sar,\n dev,\n variance,\n median,\n swma,\n correlation,\n percentrank,\n mfi,\n hma,\n pivothigh,\n pivotlow,\n barssince,\n valuewhen,\n dmi,\n tsi,\n cmo,\n kc,\n bbw,\n wpr,\n kcw,\n range,\n highestbars,\n lowestbars,\n max,\n min,\n vwapBands,\n obv,\n pvt,\n accdist,\n nvi,\n pvi,\n iii,\n wad,\n wvad,\n cog,\n mode,\n percentile_linear_interpolation,\n percentile_nearest_rank,\n rci,\n};\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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A;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": ["max"]
|
|
7
7
|
}
|
|
@@ -26,7 +26,19 @@ export interface ZonedFields {
|
|
|
26
26
|
}
|
|
27
27
|
/** Offset of `timezone` from UTC at `time`, in milliseconds (local = UTC + offset). */
|
|
28
28
|
export declare function zoneOffset(time: number, timezone: string): number;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Year, month (1-12) and day of the month of a day count since 01/01/1970, in the proleptic Gregorian calendar as
|
|
31
|
+
* `Date` reads it, by integer arithmetic (years counted from March, the leap day last).
|
|
32
|
+
*/
|
|
33
|
+
export declare function civilFromDays(days: number): {
|
|
34
|
+
year: number;
|
|
35
|
+
month: number;
|
|
36
|
+
day: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Splits a UNIX time (ms) into calendar fields in `timezone`: the fields `Date` gives for the wall clock (whole ms,
|
|
40
|
+
* NaN outside its range), computed without one as every bar reads them.
|
|
41
|
+
*/
|
|
30
42
|
export declare function zonedFields(time: number, timezone: string): ZonedFields;
|
|
31
43
|
/**
|
|
32
44
|
* Converts a wall-clock date and time in `timezone` to a UNIX time (ms).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../../src/time/timezone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../../src/time/timezone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsJH,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjE;AAKD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAWxF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAmBvE;AAED;;;;;;;GAOG;AACH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,SAAI,EAAE,MAAM,SAAI,EAAE,MAAM,SAAI,GAAG,MAAM,CAiB9G;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAU,EAChB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAU,EAClB,OAAO,GAAE,OAAe,GACvB,MAAM,CAkBR"}
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var timezone_exports = {};
|
|
20
20
|
__export(timezone_exports, {
|
|
21
|
+
civilFromDays: () => civilFromDays,
|
|
21
22
|
civilToUnix: () => civilToUnix,
|
|
22
23
|
zoneOffset: () => zoneOffset,
|
|
23
24
|
zonedFields: () => zonedFields,
|
|
@@ -77,15 +78,27 @@ function resolveZone(timezone) {
|
|
|
77
78
|
zones.set(timezone, zone);
|
|
78
79
|
return zone;
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
const DAYS_PER_BLOCK = 3;
|
|
82
|
+
const LAST_BLOCK_DAY = 1e8 - DAYS_PER_BLOCK;
|
|
83
|
+
function formattedDayStart(zone, day) {
|
|
81
84
|
let offset = zone.dayStarts.get(day);
|
|
82
85
|
if (offset === void 0) {
|
|
83
86
|
offset = formattedOffset(zone.format, day * MS_PER_DAY);
|
|
84
|
-
if (zone.dayStarts.size >= MAX_CACHED_DAYS) zone.dayStarts.clear();
|
|
85
87
|
zone.dayStarts.set(day, offset);
|
|
86
88
|
}
|
|
87
89
|
return offset;
|
|
88
90
|
}
|
|
91
|
+
function dayStartOffset(zone, day) {
|
|
92
|
+
const cached = zone.dayStarts.get(day);
|
|
93
|
+
if (cached !== void 0) return cached;
|
|
94
|
+
if (zone.dayStarts.size >= MAX_CACHED_DAYS) zone.dayStarts.clear();
|
|
95
|
+
if (!(Math.abs(day) <= LAST_BLOCK_DAY)) return formattedDayStart(zone, day);
|
|
96
|
+
const first = Math.floor(day / DAYS_PER_BLOCK) * DAYS_PER_BLOCK;
|
|
97
|
+
const offset = formattedDayStart(zone, first);
|
|
98
|
+
if (offset !== formattedDayStart(zone, first + DAYS_PER_BLOCK)) return formattedDayStart(zone, day);
|
|
99
|
+
for (let d = first + 1; d < first + DAYS_PER_BLOCK; d++) zone.dayStarts.set(d, offset);
|
|
100
|
+
return offset;
|
|
101
|
+
}
|
|
89
102
|
function offsetAt(zone, time) {
|
|
90
103
|
if (zone.kind === "fixed") return zone.offsetMs;
|
|
91
104
|
const day = Math.floor(time / MS_PER_DAY);
|
|
@@ -114,20 +127,42 @@ function formattedOffset(format, time) {
|
|
|
114
127
|
function zoneOffset(time, timezone) {
|
|
115
128
|
return offsetAt(resolveZone(timezone), time);
|
|
116
129
|
}
|
|
130
|
+
const MAX_DATE_MS = 864e13;
|
|
131
|
+
function civilFromDays(days) {
|
|
132
|
+
const z = days + 719468;
|
|
133
|
+
const era = Math.floor(z / 146097);
|
|
134
|
+
const dayOfEra = z - era * 146097;
|
|
135
|
+
const yearOfEra = Math.floor(
|
|
136
|
+
(dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36524) - Math.floor(dayOfEra / 146096)) / 365
|
|
137
|
+
);
|
|
138
|
+
const dayOfYear = dayOfEra - (yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));
|
|
139
|
+
const mp = Math.floor((5 * dayOfYear + 2) / 153);
|
|
140
|
+
const month = mp < 10 ? mp + 3 : mp - 9;
|
|
141
|
+
return { year: yearOfEra + era * 400 + (month <= 2 ? 1 : 0), month, day: dayOfYear - Math.floor((153 * mp + 2) / 5) + 1 };
|
|
142
|
+
}
|
|
117
143
|
function zonedFields(time, timezone) {
|
|
118
|
-
const
|
|
144
|
+
const wall = time + offsetAt(resolveZone(timezone), time);
|
|
145
|
+
if (!(Math.abs(wall) <= MAX_DATE_MS)) {
|
|
146
|
+
return { year: NaN, month: NaN, day: NaN, hour: NaN, minute: NaN, second: NaN, dayOfWeek: NaN };
|
|
147
|
+
}
|
|
148
|
+
const ms = Math.trunc(wall);
|
|
149
|
+
const days = Math.floor(ms / MS_PER_DAY);
|
|
150
|
+
const inDay = ms - days * MS_PER_DAY;
|
|
151
|
+
const { year, month, day } = civilFromDays(days);
|
|
119
152
|
return {
|
|
120
|
-
year
|
|
121
|
-
month
|
|
122
|
-
day
|
|
123
|
-
hour:
|
|
124
|
-
minute:
|
|
125
|
-
second:
|
|
126
|
-
|
|
153
|
+
year,
|
|
154
|
+
month,
|
|
155
|
+
day,
|
|
156
|
+
hour: Math.floor(inDay / MS_PER_HOUR),
|
|
157
|
+
minute: Math.floor(inDay / 6e4) % 60,
|
|
158
|
+
second: Math.floor(inDay / MS_PER_SECOND) % 60,
|
|
159
|
+
// 01/01/1970 is a Thursday (5)
|
|
160
|
+
dayOfWeek: ((days + 4) % 7 + 7) % 7 + 1
|
|
127
161
|
};
|
|
128
162
|
}
|
|
129
163
|
function civilToUnix(year, month, day, hour = 0, minute = 0, second = 0) {
|
|
130
164
|
const gregorian = Date.UTC(year, month - 1, day, hour, minute, second);
|
|
165
|
+
if (year >= 1583 && year < 275760 && month >= 1 && month < 13) return gregorian;
|
|
131
166
|
const d = new Date(Date.UTC(year, month - 1, 1));
|
|
132
167
|
const y = d.getUTCFullYear();
|
|
133
168
|
const m = d.getUTCMonth() + 1;
|
|
@@ -145,8 +180,12 @@ function zonedToUnix(timezone, year, month, day, hour = 0, minute = 0, second =
|
|
|
145
180
|
if (zone.kind === "fixed") return local - zone.offsetMs;
|
|
146
181
|
const before = offsetAt(zone, local - MS_PER_DAY);
|
|
147
182
|
const after = offsetAt(zone, local + MS_PER_DAY);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
183
|
+
if (before === after) return local - before;
|
|
184
|
+
const withBefore = local - before;
|
|
185
|
+
const withAfter = local - after;
|
|
186
|
+
const beforeFits = local - offsetAt(zone, withBefore) === withBefore;
|
|
187
|
+
const afterFits = local - offsetAt(zone, withAfter) === withAfter;
|
|
188
|
+
if (beforeFits && afterFits) return earlier ? Math.min(withBefore, withAfter) : Math.max(withBefore, withAfter);
|
|
189
|
+
return afterFits ? withAfter : withBefore;
|
|
151
190
|
}
|
|
152
191
|
//# sourceMappingURL=timezone.js.map
|