@orangecharts/wrun-chart-host 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
- package/dist/host-env.d.ts +8 -6
- package/dist/host-ports.types.d.ts +7 -22
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -0
- package/dist/utility/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +43 -15
- package/dist/utility/wrun/sources/lanes/option_daily.js +78 -20
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +14 -10
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +5 -4
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +22 -3
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +38 -7
- package/dist/utility/wrun/sources/registry.js +31 -1
- package/dist/utility/wrun/sources/row-lane-registry.js +5 -5
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +49 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +74 -18
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +49 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +57 -47
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +36 -4
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +6 -12
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +37 -3
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +128 -2
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +233 -51
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +0 -8
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +26 -24
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +85 -104
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +29 -10
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +29 -10
- package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
- package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
- package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ import { WRUN_FRAME_MAX_SLOTS } from '@orangecharts/wrun-chart-host/utility/wrun
|
|
|
25
25
|
At 0.3.0, 26 modules are reachable by subpath only (an export name of theirs resolves to another declaration in the
|
|
26
26
|
entry): the lane files (each exports `lane`, `lanes` or `rowLane`), `utility/chart/om-widget.util`,
|
|
27
27
|
`utility/wrun/wrun-frames`, `utility/wrun/wrun-pane-format.util` and `utility/wrun/wrun-style-words.util` among them.
|
|
28
|
-
`
|
|
28
|
+
At 0.4.0, 27: the panel mount `utility/wrun/wrun-panel-mount.util` joins them (its `retranslateWrunChildOverlays` and
|
|
29
|
+
`cutWrunBatchedChildRecords` are its door's names too; the entry serves the door's). `src/index.ts` names the modules
|
|
30
|
+
it joins.
|
|
29
31
|
|
|
30
32
|
## The host env (ports)
|
|
31
33
|
|
|
@@ -54,13 +56,16 @@ setWrunChartHostEnv({
|
|
|
54
56
|
| `loadSharedHost()` | the hosted wire reader | the kit's host module, loaded once (a failed load is not cached) |
|
|
55
57
|
| `sharedHost()` | the pack, frames, box segments, render select, the run result's strategy bytes | the loaded host module; before the load it throws `wrunChartHostUnloadedError()` (`wrun_chart_host_unloaded`) |
|
|
56
58
|
| `diagnostics.publishCapNotice(batch)` | the cells cap notice | write each `batch.take()` notice as the Indicator's "Cells capped" row when ready, or `batch.drop()` |
|
|
57
|
-
| `t`, `te` |
|
|
59
|
+
| `t`, `te` | the panel mount's legend words (`t`, from 0.4.0) | a user-facing string by its locale key, and whether the key exists |
|
|
58
60
|
| `poolDexName(exchange, symbol)` | reserved | the pool's DEX name, if any |
|
|
59
|
-
| `diagnostics.debug
|
|
61
|
+
| `diagnostics.debug` | the panel mount and its door (from 0.4.0) | the debug ring |
|
|
62
|
+
| `diagnostics.publishCanvasCostNotice` | reserved | the canvas cost row |
|
|
60
63
|
|
|
61
64
|
0.3.0 adds the phase 1 contract: six namespaces (`chart`, `user`, `market`, `transport`, `run`, `clock`) and three
|
|
62
|
-
`diagnostics` members, 42 in all, 22 of them read by 0.3.0 modules;
|
|
63
|
-
|
|
65
|
+
`diagnostics` members, 42 in all, 22 of them read by 0.3.0 modules; 0.4.0's panel mount reads the 12 reserved until
|
|
66
|
+
0.4.0 (the chart group and paint, the titan adapter's three, the paused paint, the packs, the plot gate notice, the
|
|
67
|
+
theme name, the display timezone and the door's `chart.loadPanelMountPorts`); a member a host has not adopted yet may
|
|
68
|
+
throw by name. Their payload types and loader views are `host-ports.types`. The guide lists every member, what reads it and
|
|
64
69
|
what web binds it.
|
|
65
70
|
|
|
66
71
|
A read before the set throws `wrun_chart_host_env_unset`. The env lives on the realm's global object under
|
|
@@ -84,6 +89,7 @@ What each published version holds. A host installs a version with the peers of i
|
|
|
84
89
|
|
|
85
90
|
| Version | Peers | What changed |
|
|
86
91
|
| --- | --- | --- |
|
|
92
|
+
| 0.4.0 | `@orangecharts/indicator-kit` 0.86.3, `@orangecharts/orange-v2-pb-common` 12.69.0, `dayjs` 1.11.23, `lodash-es` 4.18.1 | Phase 1b: the panel mount (`utility/wrun/wrun-panel-mount.util`, by subpath) and its door (`utility/wrun/wrun-panel-mount.lazy`), the run interval rules (`utility/chart/indicator-run-interval.util`) with the builtin script snippets they type against, the pause dim and six leaves (the window owner and window geometry rules, the date-labelled interval rule, the HTML escape, the run interval projection and plot gate types): 11 modules, 262 in all. The mount reads the host through the env: the 12 members reserved until 0.4.0, `t` and `diagnostics.debug`. Peers unchanged. |
|
|
87
93
|
| 0.3.0 | `@orangecharts/indicator-kit` 0.86.3, `@orangecharts/orange-v2-pb-common` 12.69.0, `dayjs` 1.11.23, `lodash-es` 4.18.1 | Three programs ship together. The settings templates: the nested entry `@orangecharts/wrun-chart-host/settings-templates`, one declared settings schema for every template (`TEMPLATE_SCHEMA_VERSION` 2). The phase 1 host contract: 42 env members (`host-env`) with their payload types and loader views (`host-ports.types`), 22 read by 0.3.0 modules, the rest reserved. Phase 1a's move: the lane layer (both lane registries, read through generated indexes, the lane files and planners), the row builder, legs and pins, the cloud row source and the main-grid stages, with what they read: 142 modules, 250 in all. The kit peer moves from 0.80.0 to 0.86.3 (leg streams and per-span levels) and the protocol enums package joins the peers. |
|
|
88
94
|
| 0.2.0 | `@orangecharts/indicator-kit` 0.80.0, `dayjs` 1.11.23, `lodash-es` 4.18.1 | The kit peer moves from 0.78.1 to 0.80.0. Three modules join, 101 in all: `utility/wrun/wrun-symbol-code.util` (the symbol codec of the options source classes), `utility/wrun/wrun-row-market.util` (the market a table row or feed line is about) and `utility/wrun/wrun-failure-cause` (why a run failed, as one closed word). The 12 package commits since 0.1.0, listed below. Lodash by subpath: the color settings import `lodash-es/isEqual`, never the `lodash-es` root, so a bundler that does not shake trees keeps one lodash module, not the library (`tests/packages/wrun-chart-host/lodash-subpath.spec.ts` refuses a root import in the package). |
|
|
89
95
|
| 0.1.0 | `@orangecharts/indicator-kit` 0.78.1, `dayjs` 1.11.23, `lodash-es` 4.18.1 | The first cut, packed from web 89fadab981: 98 modules, the wrun result reader and painter model with the host env. |
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kScript snippet helpers shared by every built-in template: the classic input set (source,
|
|
3
|
+
* timeframe, waitForClose), the candle and price series they read, the colour slot reader and the
|
|
4
|
+
* oscillator level / smoothing blocks. `technicalIndicatorScripts.constants.ts` (the classic
|
|
5
|
+
* built-ins) and `staples/*.constants.ts` (the TradingView staples) assemble their templates from
|
|
6
|
+
* these, so every built-in reads its inputs, candles and levels the same way. This module is
|
|
7
|
+
* i18n-free on purpose: the staple modules import it while the catalog module imports them, and a
|
|
8
|
+
* template module must never import the catalog.
|
|
9
|
+
*/
|
|
10
|
+
/** A built-in's compute input values as an alert bakes them: the overlay's value, else the template default. */
|
|
11
|
+
export interface BuiltinInputReader {
|
|
12
|
+
num(name: string): number;
|
|
13
|
+
str(name: string): string;
|
|
14
|
+
}
|
|
15
|
+
/** Shape of a `BUILTIN_ALERT_CONTRACTS` entry (see the catalog module for the contract rules). */
|
|
16
|
+
export interface BuiltinAlertContract {
|
|
17
|
+
/**
|
|
18
|
+
* Rule-addressable output labels in DECLARATION ORDER, measured against the real alerts
|
|
19
|
+
* engine (compile + plot-series extraction). These are the identity anchors the server
|
|
20
|
+
* re-anchors rules to: they must match the engine's labels VERBATIM (including the
|
|
21
|
+
* double-space in 'Lower Band'), never a display guess.
|
|
22
|
+
*/
|
|
23
|
+
outputs: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* Input names that change the COMPUTED series (feed the math). Only these bake into the
|
|
26
|
+
* armable source: renderer-only inputs (colors, width, smooth) must not alter the alert's
|
|
27
|
+
* identity, or a cosmetic edit would orphan the armed badge and duplicate alerts on re-arm.
|
|
28
|
+
*/
|
|
29
|
+
computeInputs: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Templates with a `timeframe` input: the CLOSED selected-timeframe bars the slowest output needs
|
|
32
|
+
* before it has a value, from the compute inputs. The alert engine keeps a fixed window of chart
|
|
33
|
+
* bars and recomputes it from scratch on every bar, so an alert on a selected timeframe declares
|
|
34
|
+
* this depth when it is baked (bakeBuiltinAlertSource); the parity specs pin each formula.
|
|
35
|
+
*/
|
|
36
|
+
htfWarmup?: (inputs: BuiltinInputReader) => number;
|
|
37
|
+
}
|
|
38
|
+
/** Extra closed bars the oscillator smoothing (OSCILLATOR_SMOOTHING_INPUTS) adds to its oscillator's warm-up. */
|
|
39
|
+
export declare function oscillatorSmoothingWarmup(inputs: BuiltinInputReader): number;
|
|
40
|
+
export declare const CLASSIC_TIMEFRAME_INPUTS = "var timeframe = input(name=\"timeframe\", type=\"select\", defaultValue=\"chart\", options=[\"chart\", \"5m\", \"15m\", \"30m\", \"1h\", \"4h\", \"1D\", \"1W\"]);\nvar waitForClose = input(name=\"waitForClose\", type=\"boolean\", defaultValue=true);";
|
|
41
|
+
export declare const CLASSIC_PRICE_INPUTS = "var source = input(name=\"source\", type=\"select\", defaultValue=\"close\", options=[\"close\", \"open\", \"high\", \"low\"]);\nvar timeframe = input(name=\"timeframe\", type=\"select\", defaultValue=\"chart\", options=[\"chart\", \"5m\", \"15m\", \"30m\", \"1h\", \"4h\", \"1D\", \"1W\"]);\nvar waitForClose = input(name=\"waitForClose\", type=\"boolean\", defaultValue=true);";
|
|
42
|
+
export declare const CLASSIC_PRICE_SERIES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = timeframe == \"chart\" ? field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source) : htf(field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source), timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"});";
|
|
43
|
+
export declare const CLASSIC_CANDLE_ROW = "func candleValues(bars) {\n return [bars.open, bars.high, bars.low, bars.close, bars.volume];\n}";
|
|
44
|
+
export declare const CLASSIC_CANDLE_SERIES = "func candleValues(bars) {\n return [bars.open, bars.high, bars.low, bars.close, bars.volume];\n}\ntimeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries data = timeframe == \"chart\" ? [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume] : candleValues(htf(chartData, timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"}));";
|
|
45
|
+
export declare const CLASSIC_SELECTED_CANDLES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = timeframe == \"chart\" ? field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source) : htf(field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source), timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"});\nfunc candleValues(bars) {\n return [bars.open, bars.high, bars.low, bars.close, bars.volume];\n}\ntimeseries candles = timeframe == \"chart\" ? [data.open, data.high, data.low, data.close, data.volume] : candleValues(htf(data, timeframe, {mode: waitForClose ? \"confirmed\" : \"developing\"}));\ntimeseries selectedCandles = [candles.open, candles.high, candles.low, price, candles.volume];";
|
|
46
|
+
/**
|
|
47
|
+
* Reads slot `index` of a script's `colors` input as saved, alpha included. The chart completes
|
|
48
|
+
* every saved palette to the built-in's full slot list before a run (completeBuiltinPalette in
|
|
49
|
+
* builtin-script-theme-palette.util), so the first-slot fallback only covers a caller that hands a
|
|
50
|
+
* shorter one. Both branches read the input, so they share its colour type, which plot colour
|
|
51
|
+
* arrays require (a string-literal fallback needed an opacity() wrap, and opacity() forced full
|
|
52
|
+
* alpha and read most colour names as grey).
|
|
53
|
+
*/
|
|
54
|
+
export declare function colorSlot(index: number): string;
|
|
55
|
+
/** Level inputs shared by the bounded oscillators. */
|
|
56
|
+
export declare function oscillatorLevelInputs(overbought: number, oversold: number): string;
|
|
57
|
+
/** Colour slot of the oscillator line on a bar: 0 inside the levels, 1 overbought, 2 oversold. */
|
|
58
|
+
export declare function oscillatorExtremeIndex(value: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Dashed overbought / oversold levels, a dotted midline, and the zone between them shaded in the
|
|
61
|
+
* oscillator's own colour. The zone is a box drawn on the last bar from the first bar to well past
|
|
62
|
+
* the last one: drawings carry no alert output and no legend entry, and the last-bar box rolls back
|
|
63
|
+
* and redraws on live ticks.
|
|
64
|
+
*/
|
|
65
|
+
export declare function oscillatorLevelsScript(zoneColor: string, midline: number): string;
|
|
66
|
+
export declare const OSCILLATOR_SMOOTHING_INPUTS = "var smoothingType = input(name=\"smoothingType\", type=\"select\", defaultValue=\"None\", options=[\"None\", \"SMA\", \"SMA + Bollinger Bands\", \"EMA\", \"RMA\", \"WMA\", \"VWMA\"], group=\"Smoothing\");\nvar smoothingLength = input(name=\"smoothingLength\", type=\"number\", defaultValue=14, constraints={min: 1, step: 1}, group=\"Smoothing\");\nvar bbStdDev = input(name=\"bbStdDev\", type=\"number\", defaultValue=2, constraints={min: 0, step: 0.1}, group=\"Smoothing\");";
|
|
67
|
+
export declare function oscillatorSmoothingScript(value: string, label: string, width: string, color: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Window and step functions over a history array (oldest first). The window functions read the
|
|
70
|
+
* LAST `p` entries and return na unless all of them are finite, like the strict builtins (sma, wma,
|
|
71
|
+
* stdev, highest, lowest); htfSum skips na and accepts a short window, like sum(). The step
|
|
72
|
+
* functions mirror the engine's seeding (the plain average of the first `p` finite values) and its
|
|
73
|
+
* exact update arithmetic, so a converted template matches the builtin bit for bit.
|
|
74
|
+
*/
|
|
75
|
+
export declare const HTF_WINDOW_FUNCS = "func htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}";
|
|
76
|
+
/**
|
|
77
|
+
* The selected timeframe's closed and forming candles, materialized ONCE at init (a direct htf()
|
|
78
|
+
* of the source runs in init; the "1Y" placeholder only keeps the calls valid in chart mode, which
|
|
79
|
+
* never reads them), and `htfClosed`: true on the chart bar right after a selected-timeframe bar
|
|
80
|
+
* closed. Rolling tokens compare the engine's own epoch-floor bucket of consecutive chart bars;
|
|
81
|
+
* calendar tokens (1D / 1W) fall back to "the closed candle changed". Requires the `timeframe`
|
|
82
|
+
* input (CLASSIC_TIMEFRAME_INPUTS).
|
|
83
|
+
*/
|
|
84
|
+
export declare const HTF_SELECTED_TIMEFRAME = "func htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);";
|
|
85
|
+
/**
|
|
86
|
+
* Candle templates: `data` is the chart's own candles in every mode (chart mode reads it exactly as
|
|
87
|
+
* CLASSIC_CANDLE_SERIES did), and the selected timeframe is read from htfClosedCandle /
|
|
88
|
+
* htfFormingCandle (`.high[0]`, `.volume[0]`, ...). Replaces CLASSIC_CANDLE_SERIES.
|
|
89
|
+
*/
|
|
90
|
+
export declare const HTF_CANDLE_SERIES = "timeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries data = [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume];\nfunc htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);";
|
|
91
|
+
/**
|
|
92
|
+
* Price templates: `data` and `price` as CLASSIC_PRICE_SERIES declares them in chart mode, plus
|
|
93
|
+
* the selected price read from the SELECTED candle (open / high / low / close of the closed and of
|
|
94
|
+
* the forming selected-timeframe bar). Requires CLASSIC_PRICE_INPUTS. Replaces CLASSIC_PRICE_SERIES.
|
|
95
|
+
*/
|
|
96
|
+
export declare const HTF_PRICE_SERIES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source);\nfunc htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);\nvar htfClosedPrice = source == \"open\" ? htfClosedCandle.open[0] : source == \"high\" ? htfClosedCandle.high[0] : source == \"low\" ? htfClosedCandle.low[0] : htfClosedCandle.close[0];\nvar htfFormingPrice = source == \"open\" ? htfFormingCandle.open[0] : source == \"high\" ? htfFormingCandle.high[0] : source == \"low\" ? htfFormingCandle.low[0] : htfFormingCandle.close[0];";
|
|
97
|
+
/**
|
|
98
|
+
* OHLCV templates that use the selected price as close: `selectedCandles` as CLASSIC_SELECTED_CANDLES
|
|
99
|
+
* declares it in chart mode; the selected timeframe reads htfClosedCandle / htfFormingCandle with
|
|
100
|
+
* htfClosedPrice / htfFormingPrice as the close. Replaces CLASSIC_SELECTED_CANDLES.
|
|
101
|
+
*/
|
|
102
|
+
export declare const HTF_SELECTED_CANDLES = "timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries price = field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source);\nfunc htfAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n total = total + values[k];\n }\n return total / p;\n}\nfunc htfWeightedAverage(values, p) {\n if (values.length < p) {\n return na;\n }\n var total = 0;\n var start = values.length - p;\n for (var k = 0; k < p; k = k + 1) {\n if (isna(values[start + k])) {\n return na;\n }\n total = total + values[start + k] * (k + 1);\n }\n return total / (p * (p + 1) / 2);\n}\nfunc htfVolumeWeightedAverage(values, volumes, p) {\n if (values.length < p || volumes.length < p) {\n return na;\n }\n var numerator = 0;\n var denominator = 0;\n for (var k = 0; k < p; k = k + 1) {\n var value = values[values.length - p + k];\n var volume = volumes[volumes.length - p + k];\n if (isna(value) || isna(volume)) {\n return na;\n }\n numerator = numerator + value * volume;\n denominator = denominator + volume;\n }\n return denominator == 0 ? na : numerator / denominator;\n}\nfunc htfStdev(values, p) {\n var mean = htfAverage(values, p);\n if (isna(mean)) {\n return na;\n }\n var squares = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n var diff = values[k] - mean;\n squares = squares + diff * diff;\n }\n return sqrt(squares / p);\n}\nfunc htfHighest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] > best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfLowest(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] < best) {\n best = values[k];\n }\n }\n return best;\n}\nfunc htfHighestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] >= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfLowestOffset(values, p) {\n if (values.length < p) {\n return na;\n }\n var best = na;\n var at = 0;\n for (var k = values.length - p; k < values.length; k = k + 1) {\n if (isna(values[k])) {\n return na;\n }\n if (isna(best) || values[k] <= best) {\n best = values[k];\n at = k;\n }\n }\n return at - (values.length - 1);\n}\nfunc htfSum(values, p) {\n var total = 0;\n for (var k = max(0, values.length - p); k < values.length; k = k + 1) {\n if (!isna(values[k])) {\n total = total + values[k];\n }\n }\n return total;\n}\nfunc htfValueBack(values, n) {\n return values.length > n ? values[values.length - 1 - n] : na;\n}\nfunc htfEmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n var alpha = 2 / (p + 1);\n return value * alpha + previous * (1 - alpha);\n}\nfunc htfRmaNext(previous, count, seedSum, value, p) {\n if (isna(value) || count + 1 < p) {\n return na;\n }\n if (count + 1 == p) {\n return (seedSum + value) / p;\n }\n return (previous * (p - 1) + value) / p;\n}\nfunc htfRsiOf(gain, loss) {\n if (isna(gain) || isna(loss)) {\n return na;\n }\n return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);\n}\ntimeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);\ntimeseries htfClosedCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe);\ntimeseries htfFormingCandle = htf(htfBars, timeframe == \"chart\" ? \"1Y\" : timeframe, {mode: \"developing\"});\nvar htfMs = timeframe == \"1m\" ? 60000 : timeframe == \"3m\" ? 180000 : timeframe == \"5m\" ? 300000 : timeframe == \"15m\" ? 900000 : timeframe == \"30m\" ? 1800000 : timeframe == \"1h\" ? 3600000 : timeframe == \"2h\" ? 7200000 : timeframe == \"4h\" ? 14400000 : timeframe == \"6h\" ? 21600000 : timeframe == \"8h\" ? 28800000 : timeframe == \"12h\" ? 43200000 : 0;\nvar htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);\nvar htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];\nvar htfClosed = timeframe != \"chart\" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);\nvar htfClosedPrice = source == \"open\" ? htfClosedCandle.open[0] : source == \"high\" ? htfClosedCandle.high[0] : source == \"low\" ? htfClosedCandle.low[0] : htfClosedCandle.close[0];\nvar htfFormingPrice = source == \"open\" ? htfFormingCandle.open[0] : source == \"high\" ? htfFormingCandle.high[0] : source == \"low\" ? htfFormingCandle.low[0] : htfFormingCandle.close[0];\ntimeseries selectedCandles = [data.open, data.high, data.low, price, data.volume];";
|
|
103
|
+
/**
|
|
104
|
+
* A persist history of `closedValue`, appended once per closed selected-timeframe bar (na values
|
|
105
|
+
* are skipped, so a derived value's warm-up leaves no hole) and capped at `cap` entries, oldest
|
|
106
|
+
* first. `cap` is a kScript expression (`period`, `period + 1`, `slowPeriod`). An offset history
|
|
107
|
+
* passes `keepNa`: one entry per closed bar, na included, so `htfValueBack(history, offset)` counts
|
|
108
|
+
* selected-timeframe bars like `series[offset]` and an undefined value stays undefined instead of
|
|
109
|
+
* repeating the bar before it.
|
|
110
|
+
*/
|
|
111
|
+
export declare function htfHistory(name: string, closedValue: string, cap: string | number, keepNa?: boolean): string;
|
|
112
|
+
/**
|
|
113
|
+
* The values a window reads: the closed history alone when waitForClose is on, the history plus
|
|
114
|
+
* `formingValue` (the forming selected-timeframe bar) when it is off.
|
|
115
|
+
*/
|
|
116
|
+
export declare function htfWindow(history: string, formingValue: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Recursive smoothing (EMA or RMA / Wilder) over closed selected-timeframe values. Declares the
|
|
119
|
+
* persist state (`<name>Closed`, `<name>Count`, `<name>Seed`), steps it once per closed bar with
|
|
120
|
+
* `closedValue`, and declares `var <name>`: the committed value when waitForClose is on, otherwise
|
|
121
|
+
* a provisional step with `formingValue` that is never committed. `closedValue` must be finite once
|
|
122
|
+
* it starts (leading na only), like the builtins' own seeding. Chain them by feeding one state's
|
|
123
|
+
* `<name>Closed` / `<name>` into the next (MACD's signal line, ATR from a true range).
|
|
124
|
+
*/
|
|
125
|
+
export declare function htfSmoothedState(name: string, kind: 'ema' | 'rma', closedValue: string, formingValue: string, period: string | number): string;
|
|
126
|
+
/**
|
|
127
|
+
* oscillatorSmoothingScript for a converted oscillator: chart mode smooths `value` with the
|
|
128
|
+
* builtins exactly as before; the selected timeframe smooths the oscillator's own closed values
|
|
129
|
+
* (`closedValue`, read on the bar a selected-timeframe bar closed) plus `formingValue` when
|
|
130
|
+
* waitForClose is off, weighted by the selected timeframe's volume for VWMA. Requires
|
|
131
|
+
* OSCILLATOR_SMOOTHING_INPUTS and one of the HTF_*_SERIES blocks.
|
|
132
|
+
*/
|
|
133
|
+
export declare function htfOscillatorSmoothingScript(value: string, closedValue: string, formingValue: string, label: string, width: string, color: string): string;
|