oakscriptjs 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -1
- package/bin/oakscript.mjs +10 -3
- package/dist/cjs/box/index.d.ts +348 -289
- package/dist/cjs/box/index.d.ts.map +1 -1
- package/dist/cjs/box/index.js.map +2 -2
- package/dist/cjs/check/node.d.ts.map +1 -1
- package/dist/cjs/check/node.js +1 -0
- package/dist/cjs/check/node.js.map +2 -2
- package/dist/cjs/check/preview.d.ts +31 -0
- package/dist/cjs/check/preview.d.ts.map +1 -0
- package/dist/cjs/check/preview.js +303 -0
- package/dist/cjs/check/preview.js.map +7 -0
- package/dist/cjs/color/index.d.ts +11 -11
- package/dist/cjs/color/index.js.map +1 -1
- package/dist/cjs/color/parse.d.ts +2 -0
- package/dist/cjs/color/parse.d.ts.map +1 -1
- package/dist/cjs/color/parse.js +6 -0
- package/dist/cjs/color/parse.js.map +2 -2
- package/dist/cjs/compare/index.d.ts +76 -12
- package/dist/cjs/compare/index.d.ts.map +1 -1
- package/dist/cjs/compare/index.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +28 -5
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +14 -0
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/label/index.d.ts +265 -187
- package/dist/cjs/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js +1 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/line/index.d.ts +247 -207
- package/dist/cjs/line/index.d.ts.map +1 -1
- package/dist/cjs/line/index.js.map +2 -2
- package/dist/cjs/linefill/index.d.ts +61 -89
- package/dist/cjs/linefill/index.d.ts.map +1 -1
- package/dist/cjs/linefill/index.js.map +2 -2
- package/dist/cjs/math/index.d.ts +49 -40
- package/dist/cjs/math/index.d.ts.map +1 -1
- package/dist/cjs/math/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +57 -78
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/runtime/input-active.d.ts +2 -2
- package/dist/cjs/runtime/input-active.js.map +1 -1
- package/dist/cjs/runtime/series.d.ts +241 -161
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +223 -127
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/api/alert.d.ts +37 -0
- package/dist/cjs/script/api/alert.d.ts.map +1 -0
- package/dist/cjs/script/api/alert.js +17 -0
- package/dist/cjs/script/api/alert.js.map +7 -0
- package/dist/cjs/script/api/calc.d.ts +232 -0
- package/dist/cjs/script/api/calc.d.ts.map +1 -0
- package/dist/cjs/script/api/calc.js +17 -0
- package/dist/cjs/script/api/calc.js.map +7 -0
- package/dist/cjs/script/api/color.d.ts +213 -0
- package/dist/cjs/script/api/color.d.ts.map +1 -0
- package/dist/cjs/script/api/color.js +17 -0
- package/dist/cjs/script/api/color.js.map +7 -0
- package/dist/cjs/script/api/context.d.ts +764 -0
- package/dist/cjs/script/api/context.d.ts.map +1 -0
- package/dist/cjs/script/api/context.js +17 -0
- package/dist/cjs/script/api/context.js.map +7 -0
- package/dist/cjs/script/api/log.d.ts +58 -0
- package/dist/cjs/script/api/log.d.ts.map +1 -0
- package/dist/cjs/script/api/log.js +17 -0
- package/dist/cjs/script/api/log.js.map +7 -0
- package/dist/cjs/script/api/strategy.d.ts +391 -0
- package/dist/cjs/script/api/strategy.d.ts.map +1 -0
- package/dist/cjs/script/api/strategy.js +17 -0
- package/dist/cjs/script/api/strategy.js.map +7 -0
- package/dist/cjs/script/api/ta.d.ts +1012 -0
- package/dist/cjs/script/api/ta.d.ts.map +1 -0
- package/dist/cjs/script/api/ta.js +17 -0
- package/dist/cjs/script/api/ta.js.map +7 -0
- package/dist/cjs/script/api/table.d.ts +479 -0
- package/dist/cjs/script/api/table.d.ts.map +1 -0
- package/dist/cjs/script/api/table.js +17 -0
- package/dist/cjs/script/api/table.js.map +7 -0
- package/dist/cjs/script/constants.d.ts +228 -83
- package/dist/cjs/script/constants.d.ts.map +1 -1
- package/dist/cjs/script/constants.js +87 -0
- package/dist/cjs/script/constants.js.map +2 -2
- package/dist/cjs/script/define.d.ts +94 -0
- package/dist/cjs/script/define.d.ts.map +1 -0
- package/dist/cjs/script/define.js +127 -0
- package/dist/cjs/script/define.js.map +7 -0
- package/dist/cjs/script/drawing-args.d.ts.map +1 -1
- package/dist/cjs/script/drawing-args.js +1 -1
- package/dist/cjs/script/drawing-args.js.map +2 -2
- package/dist/cjs/script/formula.d.ts +53 -0
- package/dist/cjs/script/formula.d.ts.map +1 -0
- package/dist/cjs/script/formula.js +402 -0
- package/dist/cjs/script/formula.js.map +7 -0
- package/dist/cjs/script/globals.d.ts +10 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/index.d.ts +1065 -1006
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +532 -61
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/script/json.d.ts +117 -0
- package/dist/cjs/script/json.d.ts.map +1 -0
- package/dist/cjs/script/json.js +321 -0
- package/dist/cjs/script/json.js.map +7 -0
- package/dist/cjs/security/other.d.ts +8 -3
- package/dist/cjs/security/other.d.ts.map +1 -1
- package/dist/cjs/security/other.js +23 -6
- package/dist/cjs/security/other.js.map +2 -2
- package/dist/cjs/str/index.d.ts +50 -75
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +2 -2
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/strategy/index.d.ts +102 -1
- package/dist/cjs/strategy/index.d.ts.map +1 -1
- package/dist/cjs/strategy/index.js.map +2 -2
- package/dist/cjs/table/index.d.ts +330 -49
- package/dist/cjs/table/index.d.ts.map +1 -1
- package/dist/cjs/table/index.js +55 -27
- package/dist/cjs/table/index.js.map +2 -2
- package/dist/cjs/text/index.d.ts +12 -14
- package/dist/cjs/text/index.d.ts.map +1 -1
- package/dist/cjs/text/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +15 -8
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +12 -3
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/esm/box/index.d.ts +348 -289
- package/dist/esm/box/index.d.ts.map +1 -1
- package/dist/esm/box/index.js +276 -276
- package/dist/esm/box/index.js.map +1 -1
- package/dist/esm/check/node.d.ts.map +1 -1
- package/dist/esm/check/node.js +1 -0
- package/dist/esm/check/node.js.map +1 -1
- package/dist/esm/check/preview.d.ts +31 -0
- package/dist/esm/check/preview.d.ts.map +1 -0
- package/dist/esm/check/preview.js +296 -0
- package/dist/esm/check/preview.js.map +1 -0
- package/dist/esm/color/index.d.ts +11 -11
- package/dist/esm/color/index.js +11 -11
- package/dist/esm/color/parse.d.ts +2 -0
- package/dist/esm/color/parse.d.ts.map +1 -1
- package/dist/esm/color/parse.js +7 -0
- package/dist/esm/color/parse.js.map +1 -1
- package/dist/esm/compare/index.d.ts +76 -12
- package/dist/esm/compare/index.d.ts.map +1 -1
- package/dist/esm/compare/index.js +76 -12
- package/dist/esm/compare/index.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +28 -5
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +39 -3
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/label/index.d.ts +265 -187
- package/dist/esm/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js +207 -177
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/line/index.d.ts +247 -207
- package/dist/esm/line/index.d.ts.map +1 -1
- package/dist/esm/line/index.js +202 -194
- package/dist/esm/line/index.js.map +1 -1
- package/dist/esm/linefill/index.d.ts +61 -89
- package/dist/esm/linefill/index.d.ts.map +1 -1
- package/dist/esm/linefill/index.js +61 -89
- package/dist/esm/linefill/index.js.map +1 -1
- package/dist/esm/math/index.d.ts +49 -40
- package/dist/esm/math/index.d.ts.map +1 -1
- package/dist/esm/math/index.js +22 -9
- package/dist/esm/math/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +57 -78
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +57 -78
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/runtime/input-active.d.ts +2 -2
- package/dist/esm/runtime/input-active.js +2 -2
- package/dist/esm/runtime/series.d.ts +241 -161
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +241 -161
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/api/alert.d.ts +37 -0
- package/dist/esm/script/api/alert.d.ts.map +1 -0
- package/dist/esm/script/api/alert.js +7 -0
- package/dist/esm/script/api/alert.js.map +1 -0
- package/dist/esm/script/api/calc.d.ts +232 -0
- package/dist/esm/script/api/calc.d.ts.map +1 -0
- package/dist/esm/script/api/calc.js +6 -0
- package/dist/esm/script/api/calc.js.map +1 -0
- package/dist/esm/script/api/color.d.ts +213 -0
- package/dist/esm/script/api/color.d.ts.map +1 -0
- package/dist/esm/script/api/color.js +6 -0
- package/dist/esm/script/api/color.js.map +1 -0
- package/dist/esm/script/api/context.d.ts +764 -0
- package/dist/esm/script/api/context.d.ts.map +1 -0
- package/dist/esm/script/api/context.js +7 -0
- package/dist/esm/script/api/context.js.map +1 -0
- package/dist/esm/script/api/log.d.ts +58 -0
- package/dist/esm/script/api/log.d.ts.map +1 -0
- package/dist/esm/script/api/log.js +6 -0
- package/dist/esm/script/api/log.js.map +1 -0
- package/dist/esm/script/api/strategy.d.ts +391 -0
- package/dist/esm/script/api/strategy.d.ts.map +1 -0
- package/dist/esm/script/api/strategy.js +7 -0
- package/dist/esm/script/api/strategy.js.map +1 -0
- package/dist/esm/script/api/ta.d.ts +1012 -0
- package/dist/esm/script/api/ta.d.ts.map +1 -0
- package/dist/esm/script/api/ta.js +6 -0
- package/dist/esm/script/api/ta.js.map +1 -0
- package/dist/esm/script/api/table.d.ts +479 -0
- package/dist/esm/script/api/table.d.ts.map +1 -0
- package/dist/esm/script/api/table.js +7 -0
- package/dist/esm/script/api/table.js.map +1 -0
- package/dist/esm/script/constants.d.ts +228 -83
- package/dist/esm/script/constants.d.ts.map +1 -1
- package/dist/esm/script/constants.js +110 -24
- package/dist/esm/script/constants.js.map +1 -1
- package/dist/esm/script/define.d.ts +94 -0
- package/dist/esm/script/define.d.ts.map +1 -0
- package/dist/esm/script/define.js +136 -0
- package/dist/esm/script/define.js.map +1 -0
- package/dist/esm/script/drawing-args.d.ts.map +1 -1
- package/dist/esm/script/drawing-args.js +2 -1
- package/dist/esm/script/drawing-args.js.map +1 -1
- package/dist/esm/script/formula.d.ts +53 -0
- package/dist/esm/script/formula.d.ts.map +1 -0
- package/dist/esm/script/formula.js +408 -0
- package/dist/esm/script/formula.js.map +1 -0
- package/dist/esm/script/globals.d.ts +10 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/index.d.ts +1065 -1006
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +1099 -153
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/script/json.d.ts +117 -0
- package/dist/esm/script/json.d.ts.map +1 -0
- package/dist/esm/script/json.js +375 -0
- package/dist/esm/script/json.js.map +1 -0
- package/dist/esm/security/other.d.ts +8 -3
- package/dist/esm/security/other.d.ts.map +1 -1
- package/dist/esm/security/other.js +45 -10
- package/dist/esm/security/other.js.map +1 -1
- package/dist/esm/str/index.d.ts +50 -75
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +51 -76
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/strategy/index.d.ts +102 -1
- package/dist/esm/strategy/index.d.ts.map +1 -1
- package/dist/esm/strategy/index.js +1 -1
- package/dist/esm/strategy/index.js.map +1 -1
- package/dist/esm/table/index.d.ts +330 -49
- package/dist/esm/table/index.d.ts.map +1 -1
- package/dist/esm/table/index.js +372 -61
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/text/index.d.ts +12 -14
- package/dist/esm/text/index.d.ts.map +1 -1
- package/dist/esm/text/index.js +12 -14
- package/dist/esm/text/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +15 -8
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +15 -8
- package/dist/esm/types/index.js.map +1 -1
- package/docs/first-indicator.md +152 -0
- package/docs/guide.md +1185 -0
- package/docs/inventory.md +772 -0
- package/docs/no-code.md +207 -0
- package/docs/recipes.md +202 -0
- package/package.json +2 -1
- package/skills/oakscript/SKILL.md +8 -0
- package/skills/oakscript/reference/errors.md +3 -2
- package/skills/oakscript/reference/timeframes-symbols.md +4 -0
- package/src/box/index.ts +348 -289
- package/src/check/node.ts +1 -0
- package/src/check/preview.ts +307 -0
- package/src/color/index.ts +11 -11
- package/src/color/parse.ts +7 -0
- package/src/compare/index.ts +76 -12
- package/src/drawing/registry.ts +44 -5
- package/src/index.ts +1 -1
- package/src/label/index.ts +267 -189
- package/src/line/index.ts +248 -208
- package/src/linefill/index.ts +61 -89
- package/src/math/index.ts +51 -42
- package/src/polyline/index.ts +57 -78
- package/src/runtime/input-active.ts +2 -2
- package/src/runtime/series.ts +243 -163
- package/src/script/api/alert.ts +43 -0
- package/src/script/api/calc.ts +250 -0
- package/src/script/api/color.ts +245 -0
- package/src/script/api/context.ts +944 -0
- package/src/script/api/log.ts +60 -0
- package/src/script/api/strategy.ts +410 -0
- package/src/script/api/ta.ts +1115 -0
- package/src/script/api/table.ts +538 -0
- package/src/script/constants.ts +229 -25
- package/src/script/define.ts +221 -0
- package/src/script/drawing-args.ts +2 -1
- package/src/script/formula.ts +438 -0
- package/src/script/globals.ts +10 -0
- package/src/script/index.ts +1520 -241
- package/src/script/json.ts +457 -0
- package/src/security/other.ts +43 -9
- package/src/str/index.ts +51 -76
- package/src/strategy/index.ts +102 -1
- package/src/table/index.ts +388 -62
- package/src/text/index.ts +12 -14
- package/src/types/index.ts +15 -8
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
# Function Inventory - OakScriptJS
|
|
2
|
+
|
|
3
|
+
This document tracks the implementation status of all PineScript v6 functions against the official PineScript v6 language reference.
|
|
4
|
+
|
|
5
|
+
**Last Updated:** 09/11/2026 (v0.17.1)
|
|
6
|
+
|
|
7
|
+
## Architecture Overview
|
|
8
|
+
|
|
9
|
+
OakScriptJS is a **simplified PineScript-like library** providing:
|
|
10
|
+
|
|
11
|
+
1. **Core Functions** (array-based): Pure calculation functions from `ta.*`, `math.*`, `array.*`, etc.
|
|
12
|
+
2. **Series Class**: Lazy evaluation with method chaining (`close.sub(open)`)
|
|
13
|
+
- **BarData**: Versioned wrapper for automatic cache invalidation
|
|
14
|
+
- **materialize()**: Breaks closure chains for memory efficiency
|
|
15
|
+
3. **TA-Series Wrappers**: Series-based wrappers around core TA functions
|
|
16
|
+
4. **Script API** (`oakscriptjs/script`): flat PineScript-style authoring —
|
|
17
|
+
`indicator()`, `input.*`, `plot`/`hline`/`fill`, the Tier 1 outputs
|
|
18
|
+
(`plotshape`/`plotchar`/`bgcolor`/`barcolor`), `plotcandle`/`plotbar`, `alertcondition`, and
|
|
19
|
+
`eachBar()` for per-bar stateful logic. See the [Script API section](#script-api-oakscriptjsscript).
|
|
20
|
+
5. **Metadata Types**: Type definitions for indicator results (plots, hlines, fills, markers, bar colors, candles,
|
|
21
|
+
labels, lines, boxes, linefills, polylines, tables)
|
|
22
|
+
|
|
23
|
+
**No DSL Layer**: This library focuses on the computational core. For ready-to-use indicators, see the [`lightweight-charts-indicators`](https://www.npmjs.com/package/lightweight-charts-indicators) package.
|
|
24
|
+
|
|
25
|
+
## Summary
|
|
26
|
+
|
|
27
|
+
**Official PineScript v6 reference:** 457 function doc files across ~20 namespaces.
|
|
28
|
+
|
|
29
|
+
### In-Scope Namespaces
|
|
30
|
+
|
|
31
|
+
| Namespace | Official Functions | Implemented | Not Implemented | Completion % |
|
|
32
|
+
|-----------|-------------------|-------------|-----------------|--------------|
|
|
33
|
+
| **ta** | 59 | 59 (+2 custom) | 0 | 100% |
|
|
34
|
+
| **math** | 24 | 24 | 0 | 100% |
|
|
35
|
+
| **array** | 55 | 55 (+1 custom) | 0 | 100% |
|
|
36
|
+
| **matrix** | 50 | 50 (+1 custom) | 0 | 100% |
|
|
37
|
+
| **str** | 18 | 18 (+4 custom) | 0 | 100% |
|
|
38
|
+
| **time + timeframe** | 5 | 5 (+2 custom) | 0 | 100% |
|
|
39
|
+
| **color** | 7 | 7 (+1 custom) | 0 | 100% |
|
|
40
|
+
| **line** | 21 | 21 | 0 | 100% |
|
|
41
|
+
| **box** | 29 | 28 | 1 | 96.6% |
|
|
42
|
+
| **label** | 21 | 21 | 0 | 100% |
|
|
43
|
+
| **linefill** | 5 | 5 | 0 | 100% |
|
|
44
|
+
| **chartPoint** | 5 | 5 | 0 | 100% |
|
|
45
|
+
| **polyline** | 2 | 2 (+1 custom) | 0 | 100% |
|
|
46
|
+
| **table** | 22 | 22 | 0 | 100% |
|
|
47
|
+
| **map** | 11 | 11 | 0 | 100% |
|
|
48
|
+
| **TOTAL** | **334** | **333** | **1** | **99.7%** |
|
|
49
|
+
|
|
50
|
+
### Out-of-Scope Namespaces (Platform/Rendering/Data)
|
|
51
|
+
|
|
52
|
+
These namespaces exist in the official PineScript v6 reference but are outside the library's computational scope:
|
|
53
|
+
|
|
54
|
+
| Namespace | Official Functions | Reason |
|
|
55
|
+
|-----------|-------------------|--------|
|
|
56
|
+
| **strategy** | 47 | Order execution engine: the script API has `strategy()` and the `strategy.*` API, forwarded to an engine the host supplies |
|
|
57
|
+
| **input** | 13 | UI/platform interaction — 9 provided by the script API (`input.int/float/bool/string/color/source/timeframe/session/time`) |
|
|
58
|
+
| **request** | 10 | External data fetching — `request.security` (chart symbol on higher timeframes, Heikin Ashi, and other symbols with bars given by the host), `request.security_lower_tf`, `request.seed` (a seed data series, as the symbol `ChartContext.seedSymbol(source, symbol)`, #205), `request.dividends`, `request.splits` and `request.earnings` (events given by the host, #211) are in the script API |
|
|
59
|
+
| **ticker** | 9 | Symbol/ticker construction |
|
|
60
|
+
| **log** | 3 | Runtime logging |
|
|
61
|
+
| **syminfo** | 2 | Platform symbol metadata: the 40 `syminfo.*` variables read the chart context in the script API (#211) |
|
|
62
|
+
| **Standalone** | ~34 | Mixed: `na`, `nz`, time helpers, type constructors, etc. The script API provides `indicator`, `plot`, `hline`, `fill`, `plotshape`, `plotchar`, `plotarrow`, `plotcandle`, `plotbar`, `bgcolor`, `barcolor`, `alertcondition`, `alert` |
|
|
63
|
+
| **TOTAL** | **~118** | -- |
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## ta (Technical Analysis)
|
|
68
|
+
|
|
69
|
+
### Implemented (59 official + 2 custom = 61 functions)
|
|
70
|
+
|
|
71
|
+
1. `alma()` - Arnaud Legoux Moving Average
|
|
72
|
+
2. `atr()` - Average True Range
|
|
73
|
+
3. `barssince()` - Number of bars since condition was true
|
|
74
|
+
4. `bb()` - Bollinger Bands
|
|
75
|
+
5. `bbw()` - Bollinger Bands Width
|
|
76
|
+
6. `cci()` - Commodity Channel Index
|
|
77
|
+
7. `change()` - Difference between current and previous value
|
|
78
|
+
8. `cmo()` - Chande Momentum Oscillator
|
|
79
|
+
9. `cog()` - Center of Gravity
|
|
80
|
+
10. `correlation()` - Correlation coefficient between two series
|
|
81
|
+
11. `cross()` - Detects when two series cross
|
|
82
|
+
12. `crossover()` - Detects when series1 crosses over series2
|
|
83
|
+
13. `crossunder()` - Detects when series1 crosses under series2
|
|
84
|
+
14. `cum()` - Cumulative sum
|
|
85
|
+
15. `dev()` - Mean absolute deviation
|
|
86
|
+
16. `dmi()` - Directional Movement Index
|
|
87
|
+
17. `ema()` - Exponential Moving Average
|
|
88
|
+
18. `falling()` - Tests if series is falling
|
|
89
|
+
19. `highest()` - Highest value over a period
|
|
90
|
+
20. `highestbars()` - Offset to the highest value
|
|
91
|
+
21. `hma()` - Hull Moving Average
|
|
92
|
+
22. `ichimoku()` - Ichimoku Kinko Hyo (custom, not in official PineScript v6)
|
|
93
|
+
23. `kc()` - Keltner Channels
|
|
94
|
+
24. `kcw()` - Keltner Channels Width
|
|
95
|
+
25. `linreg()` - Linear regression
|
|
96
|
+
26. `lowest()` - Lowest value over a period
|
|
97
|
+
27. `lowestbars()` - Offset to the lowest value
|
|
98
|
+
28. `macd()` - Moving Average Convergence Divergence
|
|
99
|
+
29. `max()` - Maximum of two values
|
|
100
|
+
30. `median()` - Median value over a period
|
|
101
|
+
31. `mfi()` - Money Flow Index
|
|
102
|
+
32. `min()` - Minimum of two values
|
|
103
|
+
33. `mode()` - Mode (most frequently occurring value)
|
|
104
|
+
34. `mom()` - Momentum
|
|
105
|
+
35. `percentile_linear_interpolation()` - Percentile using linear interpolation
|
|
106
|
+
36. `percentile_nearest_rank()` - Percentile using nearest rank
|
|
107
|
+
37. `percentrank()` - Percent rank over a period
|
|
108
|
+
38. `pivot_point_levels()` - Pivot point levels (Traditional, Fibonacci, Woodie, Classic, DM, Camarilla); array API only (`taCore.pivot_point_levels`)
|
|
109
|
+
39. `pivothigh()` - Detects pivot high points
|
|
110
|
+
40. `pivotlow()` - Detects pivot low points
|
|
111
|
+
41. `range()` - High-Low Range
|
|
112
|
+
42. `rci()` - Rank Correlation Index (Spearman's rank correlation)
|
|
113
|
+
43. `rising()` - Tests if series is rising
|
|
114
|
+
44. `rma()` - Relative Moving Average (exponential moving average with alpha = 1 / length)
|
|
115
|
+
45. `roc()` - Rate of Change
|
|
116
|
+
46. `rsi()` - Relative Strength Index; `rsi(x, y)` with two series (PineScript v4) too
|
|
117
|
+
47. `sar()` - Parabolic SAR
|
|
118
|
+
48. `sma()` - Simple Moving Average (also with a series length)
|
|
119
|
+
49. `stdev()` - Standard deviation (also with a series length)
|
|
120
|
+
50. `stoch()` - Stochastic oscillator
|
|
121
|
+
51. `supertrend()` - SuperTrend indicator
|
|
122
|
+
52. `swma()` - Symmetrically Weighted Moving Average
|
|
123
|
+
53. `tr()` - True Range
|
|
124
|
+
54. `tsi()` - True Strength Index (in [-1, 1])
|
|
125
|
+
55. `valuewhen()` - Returns value when condition was true
|
|
126
|
+
56. `variance()` - Variance (also with a series length)
|
|
127
|
+
57. `vwap()` - Volume Weighted Average Price
|
|
128
|
+
58. `vwma()` - Volume Weighted Moving Average
|
|
129
|
+
59. `wma()` - Weighted Moving Average
|
|
130
|
+
60. `wpr()` - Williams %R
|
|
131
|
+
61. `zigzag()` - ZigZag indicator (custom, not in official PineScript v6)
|
|
132
|
+
|
|
133
|
+
### Built-in variables
|
|
134
|
+
|
|
135
|
+
`ta.obv`, `ta.pvt`, `ta.accdist`, `ta.nvi`, `ta.pvi`, `ta.iii`, `ta.wad`, `ta.wvad`: context-bound Series in
|
|
136
|
+
the script API (`ta.obv`), functions of the bars in `ta` (`ta.obv(bars)`) and of the columns in `taCore`
|
|
137
|
+
(`taCore.obv(close, volume)`). `ta.tr` is a function (`ta.tr(handle_na)`). `fixnan()` is a top-level function. In the script API `na(x)` and
|
|
138
|
+
`nz(x, replacement)` take a Series too (`na` gives a Series of 1 / 0; the replacement is a number or a Series).
|
|
139
|
+
|
|
140
|
+
### Not Implemented (0 official functions)
|
|
141
|
+
|
|
142
|
+
All 59 official ta functions are implemented. `ichimoku()` and `zigzag()` are custom additions beyond the official API.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## math (Mathematics)
|
|
147
|
+
|
|
148
|
+
### Implemented (24 functions)
|
|
149
|
+
|
|
150
|
+
1. `abs()` - Absolute value
|
|
151
|
+
2. `acos()` - Arc cosine (inverse cosine)
|
|
152
|
+
3. `asin()` - Arc sine (inverse sine)
|
|
153
|
+
4. `atan()` - Arc tangent (inverse tangent)
|
|
154
|
+
5. `avg()` - Average of arguments
|
|
155
|
+
6. `ceil()` - Ceiling (round up)
|
|
156
|
+
7. `cos()` - Cosine
|
|
157
|
+
8. `exp()` - Exponential (e^x)
|
|
158
|
+
9. `floor()` - Floor (round down)
|
|
159
|
+
10. `log()` - Natural logarithm (ln)
|
|
160
|
+
11. `log10()` - Base-10 logarithm
|
|
161
|
+
12. `max()` - Maximum of arguments
|
|
162
|
+
13. `min()` - Minimum of arguments
|
|
163
|
+
14. `pow()` - Power (x^y)
|
|
164
|
+
15. `random()` - Random number (with a seed: the PineScript sequence)
|
|
165
|
+
16. `round()` - Round to nearest integer or precision
|
|
166
|
+
17. `round_to_mintick()` - Round to nearest tick size
|
|
167
|
+
18. `sign()` - Sign of number (-1, 0, 1)
|
|
168
|
+
19. `sin()` - Sine
|
|
169
|
+
20. `sqrt()` - Square root
|
|
170
|
+
21. `sum()` - Sum over a series/window (also with a series length)
|
|
171
|
+
22. `tan()` - Tangent
|
|
172
|
+
23. `todegrees()` - Convert radians to degrees
|
|
173
|
+
24. `toradians()` - Convert degrees to radians
|
|
174
|
+
|
|
175
|
+
**Constants:** `pi`, `e`, `phi`, `rphi`
|
|
176
|
+
|
|
177
|
+
### Not Implemented (0 functions)
|
|
178
|
+
|
|
179
|
+
All 24 official math functions are implemented. `constant()` is a custom addition: the value PineScript gives to a
|
|
180
|
+
constant expression (16 decimals from 0.001 up).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## array (Array Operations)
|
|
185
|
+
|
|
186
|
+
### Implemented (55 official + 1 custom = 56 functions)
|
|
187
|
+
|
|
188
|
+
1. `abs()` - Absolute values of elements
|
|
189
|
+
2. `avg()` - Average of array elements
|
|
190
|
+
3. `binary_search()` - Binary search for value
|
|
191
|
+
4. `binary_search_leftmost()` - Binary search returning leftmost index
|
|
192
|
+
5. `binary_search_rightmost()` - Binary search returning rightmost index
|
|
193
|
+
6. `clear()` - Remove all elements
|
|
194
|
+
7. `concat()` - Concatenate two arrays
|
|
195
|
+
8. `copy()` - Create a shallow copy
|
|
196
|
+
9. `covariance()` - Covariance of two arrays
|
|
197
|
+
10. `every()` - Test if all elements satisfy condition
|
|
198
|
+
11. `fill()` - Fill array with value
|
|
199
|
+
12. `first()` - Get first element
|
|
200
|
+
13. `from()` - Create array from existing one
|
|
201
|
+
14. `get()` - Get element at index
|
|
202
|
+
15. `includes()` - Check if array contains value
|
|
203
|
+
16. `indexof()` - Find first index of value
|
|
204
|
+
17. `insert()` - Insert value at index
|
|
205
|
+
18. `join()` - Join elements into string
|
|
206
|
+
19. `last()` - Get last element
|
|
207
|
+
20. `lastindexof()` - Find last index of value
|
|
208
|
+
21. `max()` - Maximum value in array
|
|
209
|
+
22. `median()` - Median value in array
|
|
210
|
+
23. `min()` - Minimum value in array
|
|
211
|
+
24. `mode()` - Most frequent value in array
|
|
212
|
+
25. `new_array()` - Create new array (custom generic wrapper, not in official API)
|
|
213
|
+
26. `new_bool()` - Create new boolean array
|
|
214
|
+
27. `new_box()` - Create new box array
|
|
215
|
+
28. `new_color()` - Create new color array
|
|
216
|
+
29. `new_float()` - Create new float array
|
|
217
|
+
30. `new_int()` - Create new int array
|
|
218
|
+
31. `new_label()` - Create new label array
|
|
219
|
+
32. `new_line()` - Create new line array
|
|
220
|
+
33. `new_linefill()` - Create new linefill array
|
|
221
|
+
34. `new_table()` - Create new table array
|
|
222
|
+
35. `new_string()` - Create new string array
|
|
223
|
+
36. `newtype()` - Create array of user-defined type (placeholder)
|
|
224
|
+
37. `percentile_linear_interpolation()` - Percentile using linear interpolation
|
|
225
|
+
38. `percentile_nearest_rank()` - Percentile using nearest rank
|
|
226
|
+
39. `percentrank()` - Percent rank of value in array
|
|
227
|
+
40. `pop()` - Remove and return last element
|
|
228
|
+
41. `push()` - Add element to end
|
|
229
|
+
42. `range()` - Difference between max and min
|
|
230
|
+
43. `remove()` - Remove element at index
|
|
231
|
+
44. `reverse()` - Reverse array in place
|
|
232
|
+
45. `set()` - Set element at index
|
|
233
|
+
46. `shift()` - Remove and return first element
|
|
234
|
+
47. `size()` - Get array length
|
|
235
|
+
48. `slice()` - Get sub-array
|
|
236
|
+
49. `some()` - Test if any element satisfies condition
|
|
237
|
+
50. `sort()` - Sort array in place
|
|
238
|
+
51. `sort_indices()` - Get indices that would sort the array
|
|
239
|
+
52. `standardize()` - Standardize array (z-score normalization)
|
|
240
|
+
53. `stdev()` - Standard deviation of array
|
|
241
|
+
54. `sum()` - Sum of array elements (skips na)
|
|
242
|
+
55. `unshift()` - Add element to beginning
|
|
243
|
+
56. `variance()` - Variance of array
|
|
244
|
+
|
|
245
|
+
### Not Implemented (0 functions)
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## matrix (Matrix Operations)
|
|
250
|
+
|
|
251
|
+
### Implemented (50 official + 1 custom = 51 functions)
|
|
252
|
+
|
|
253
|
+
**Phase 1 - Foundation:**
|
|
254
|
+
1. `new_matrix()` - Create new matrix (custom wrapper, official API uses `matrix.newtype`)
|
|
255
|
+
2. `get()` - Get element at position
|
|
256
|
+
3. `set()` - Set element at position
|
|
257
|
+
4. `rows()` - Get number of rows
|
|
258
|
+
5. `columns()` - Get number of columns
|
|
259
|
+
6. `elements_count()` - Total number of elements
|
|
260
|
+
7. `row()` - Get row as array
|
|
261
|
+
8. `col()` - Get column as array
|
|
262
|
+
9. `copy()` - Create a deep copy
|
|
263
|
+
10. `fill()` - Fill matrix with value
|
|
264
|
+
11. `is_square()` - Test if square
|
|
265
|
+
12. `is_zero()` - Test if zero matrix
|
|
266
|
+
13. `is_binary()` - Test if binary
|
|
267
|
+
|
|
268
|
+
**Phase 2 - Manipulation (Row/Column Operations):**
|
|
269
|
+
14. `add_row()` - Add row to matrix
|
|
270
|
+
15. `add_col()` - Add column to matrix
|
|
271
|
+
16. `remove_row()` - Remove row from matrix
|
|
272
|
+
17. `remove_col()` - Remove column from matrix
|
|
273
|
+
18. `swap_rows()` - Swap two rows
|
|
274
|
+
19. `swap_columns()` - Swap two columns
|
|
275
|
+
|
|
276
|
+
**Phase 2 - Manipulation (Matrix Transformations):**
|
|
277
|
+
20. `transpose()` - Matrix transpose
|
|
278
|
+
21. `concat()` - Concatenate matrices
|
|
279
|
+
22. `submatrix()` - Extract submatrix
|
|
280
|
+
23. `reshape()` - Reshape matrix
|
|
281
|
+
24. `reverse()` - Reverse matrix
|
|
282
|
+
25. `sort()` - Sort matrix by column
|
|
283
|
+
|
|
284
|
+
**Phase 2 - Manipulation (Element-wise Arithmetic):**
|
|
285
|
+
26. `sum()` - Matrix addition (matrix or scalar)
|
|
286
|
+
27. `diff()` - Matrix subtraction (matrix or scalar)
|
|
287
|
+
|
|
288
|
+
**Phase 2 - Manipulation (Statistical Functions):**
|
|
289
|
+
28. `avg()` - Average of all elements
|
|
290
|
+
29. `min()` - Minimum element
|
|
291
|
+
30. `max()` - Maximum element
|
|
292
|
+
31. `median()` - Median element
|
|
293
|
+
32. `mode()` - Mode (most frequent element)
|
|
294
|
+
33. `trace()` - Matrix trace (sum of diagonal)
|
|
295
|
+
|
|
296
|
+
**Phase 2 - Manipulation (Boolean Checks):**
|
|
297
|
+
34. `is_diagonal()` - Test if diagonal matrix
|
|
298
|
+
35. `is_identity()` - Test if identity matrix
|
|
299
|
+
36. `is_symmetric()` - Test if symmetric
|
|
300
|
+
37. `is_antisymmetric()` - Test if antisymmetric (skew-symmetric)
|
|
301
|
+
38. `is_triangular()` - Test if triangular
|
|
302
|
+
39. `is_antidiagonal()` - Test if antidiagonal
|
|
303
|
+
40. `is_stochastic()` - Test if stochastic
|
|
304
|
+
|
|
305
|
+
**Phase 3 - Linear Algebra:**
|
|
306
|
+
41. `mult()` - Matrix multiplication (matrix x matrix, matrix x scalar, matrix x vector)
|
|
307
|
+
42. `pow()` - Matrix power using repeated squaring
|
|
308
|
+
43. `det()` - Determinant using LU decomposition with partial pivoting
|
|
309
|
+
44. `inv()` - Matrix inverse using Gauss-Jordan elimination
|
|
310
|
+
45. `pinv()` - Moore-Penrose pseudo-inverse for any matrix shape
|
|
311
|
+
46. `rank()` - Matrix rank via row echelon form
|
|
312
|
+
47. `eigenvalues()` - Eigenvalues using QR algorithm
|
|
313
|
+
48. `eigenvectors()` - Eigenvectors using inverse iteration
|
|
314
|
+
49. `kron()` - Kronecker (tensor) product
|
|
315
|
+
50. `newtype()` - Create matrix of user-defined type
|
|
316
|
+
|
|
317
|
+
### Not Implemented (0 official functions)
|
|
318
|
+
|
|
319
|
+
All 50 official matrix functions are implemented. `new_matrix()` is a custom convenience wrapper.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## str (String Operations)
|
|
324
|
+
|
|
325
|
+
### Implemented (18 official + 4 custom = 22 functions)
|
|
326
|
+
|
|
327
|
+
1. `charAt()` - Get character at index (custom addition)
|
|
328
|
+
2. `concat()` - Concatenate strings (custom addition)
|
|
329
|
+
3. `contains()` - Check if string contains substring
|
|
330
|
+
4. `endswith()` - Check if string ends with suffix
|
|
331
|
+
5. `format()` - Format string with arguments
|
|
332
|
+
6. `format_time()` - Format timestamp with PineScript format specifiers
|
|
333
|
+
7. `length()` - Get string length
|
|
334
|
+
8. `lower()` - Convert to lowercase
|
|
335
|
+
9. `match()` - Match regular expression
|
|
336
|
+
10. `pos()` - Find position of substring
|
|
337
|
+
11. `repeat()` - Repeat string N times with optional separator
|
|
338
|
+
12. `replace()` - Replace first occurrence
|
|
339
|
+
13. `replace_all()` - Replace all occurrences
|
|
340
|
+
14. `split()` - Split string into array
|
|
341
|
+
15. `startswith()` - Check if string starts with prefix
|
|
342
|
+
16. `substring()` - Extract substring
|
|
343
|
+
17. `tonumber()` - Convert string to number
|
|
344
|
+
18. `tostring()` - Convert value to string
|
|
345
|
+
19. `trim()` - Remove whitespace from both ends
|
|
346
|
+
20. `trimLeft()` - Remove whitespace from left (custom addition)
|
|
347
|
+
21. `trimRight()` - Remove whitespace from right (custom addition)
|
|
348
|
+
22. `upper()` - Convert to uppercase
|
|
349
|
+
|
|
350
|
+
### Not Implemented (0 functions)
|
|
351
|
+
|
|
352
|
+
All 18 official str functions are implemented.
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## time + timeframe (Time Operations)
|
|
357
|
+
|
|
358
|
+
All calendar functions take an explicit `timezone`: UTC/GMT offset notation (`"UTC-5"`, `"GMT+0530"`)
|
|
359
|
+
or an IANA name (`"America/New_York"`). The PineScript default (exchange time zone) is not available.
|
|
360
|
+
|
|
361
|
+
### Implemented
|
|
362
|
+
|
|
363
|
+
1. `timestamp(dateString)` - RFC 2822 / ISO 8601 date string, GMT+0 when no time zone is given
|
|
364
|
+
2. `timestamp(timezone, year, month, day, hour?, minute?, second?)` - calendar fields in a time zone
|
|
365
|
+
3. `timestamp(year, month, day, hour?, minute?, second?)` - calendar fields in the host time zone (PineScript: exchange time zone)
|
|
366
|
+
4. `year()`, `month()`, `dayofmonth()`, `dayofweek()`, `weekofyear()`, `hour()`, `minute()`, `second()` - `(time, timezone)`;
|
|
367
|
+
an na time gives the fields of time 0 in the time zone (`year(na)` is 1970 in UTC, 1969 in America/New_York)
|
|
368
|
+
5. `timeframe.in_seconds(timeframe)` - timeframe string to seconds (1M = 2,628,003 s)
|
|
369
|
+
6. `timeframe.from_seconds(seconds)` - seconds to timeframe string
|
|
370
|
+
7. `inSession(time, session, timezone)` - custom: the session test of `time(timeframe, session, timezone)`
|
|
371
|
+
8. `now()` - custom addition for convenience
|
|
372
|
+
|
|
373
|
+
`weekofyear()` uses ISO 8601 weeks (Monday start, week 1 contains the first Thursday). The PineScript
|
|
374
|
+
reference does not define the rule.
|
|
375
|
+
|
|
376
|
+
9. `time(timeframe, session, timezone)`, `time_close(...)`, `timeframe.change(tf)`, `time_tradingday`, `session.*`,
|
|
377
|
+
`timeframe.*` variables, every `syminfo.*` variable (#211) - script API, with the chart
|
|
378
|
+
context of `executeScript` (chart timeframe, exchange time zone, session in the symbol session format, symbol
|
|
379
|
+
properties)
|
|
380
|
+
|
|
381
|
+
### Not Implemented
|
|
382
|
+
|
|
383
|
+
None.
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## color (Color Operations)
|
|
388
|
+
|
|
389
|
+
### Implemented (7 official + 1 custom = 8 functions)
|
|
390
|
+
|
|
391
|
+
1. `b()` - Extract blue component
|
|
392
|
+
2. `from_gradient()` - Create color from gradient between two colors (script API: Series arguments give one colour per bar)
|
|
393
|
+
3. `from_hex()` - Create color from hex string (custom addition, not in official API)
|
|
394
|
+
4. `g()` - Extract green component
|
|
395
|
+
5. `new()` - Create new color with transparency (aliased as `new_color`)
|
|
396
|
+
6. `r()` - Extract red component
|
|
397
|
+
7. `rgb()` - Create RGB color
|
|
398
|
+
8. `t()` - Extract transparency component
|
|
399
|
+
|
|
400
|
+
**Constants:** All standard PineScript color constants are implemented (red, green, blue, yellow, etc.)
|
|
401
|
+
|
|
402
|
+
### Not Implemented (0 official functions)
|
|
403
|
+
|
|
404
|
+
All 7 official color functions are implemented.
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## line (Line Drawing Objects)
|
|
409
|
+
|
|
410
|
+
### Implemented (21 official + `all()`)
|
|
411
|
+
|
|
412
|
+
**Core Functions:**
|
|
413
|
+
1. `new()` - Create new line with coordinates
|
|
414
|
+
2. `get_price()` - Price at a bar index, the line extended on both sides (as PineScript, whatever `extend`)
|
|
415
|
+
3. `get_x1()` - Get first x coordinate
|
|
416
|
+
4. `get_y1()` - Get first y coordinate
|
|
417
|
+
5. `get_x2()` - Get second x coordinate
|
|
418
|
+
6. `get_y2()` - Get second y coordinate
|
|
419
|
+
7. `copy()` - Create copy of line
|
|
420
|
+
8. `delete()` - Delete line (no-op in JS)
|
|
421
|
+
|
|
422
|
+
**Setters:**
|
|
423
|
+
9. `set_x1()` - Set first x coordinate
|
|
424
|
+
10. `set_y1()` - Set first y coordinate
|
|
425
|
+
11. `set_x2()` - Set second x coordinate
|
|
426
|
+
12. `set_y2()` - Set second y coordinate
|
|
427
|
+
13. `set_xy1()` - Set first point coordinates
|
|
428
|
+
14. `set_xy2()` - Set second point coordinates
|
|
429
|
+
15. `set_xloc()` - Set x location mode and coordinate
|
|
430
|
+
16. `set_extend()` - Set line extension mode
|
|
431
|
+
17. `set_color()` - Set line color
|
|
432
|
+
18. `set_style()` - Set line style
|
|
433
|
+
19. `set_width()` - Set line width
|
|
434
|
+
20. `set_first_point()` - Set first point via chart.point object
|
|
435
|
+
21. `set_second_point()` - Set second point via chart.point object
|
|
436
|
+
22. `all()` - Live lines in creation order (PineScript `line.all`)
|
|
437
|
+
|
|
438
|
+
All drawing namespaces keep a registry of live objects (`all()`; `line.all` in the script API):
|
|
439
|
+
creation order, a working `delete`, and automatic deletion of the oldest objects above `max_*_count + 5`,
|
|
440
|
+
as in PineScript.
|
|
441
|
+
|
|
442
|
+
### Not Implemented (0 functions)
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## box (Box Drawing Objects)
|
|
447
|
+
|
|
448
|
+
### Implemented (28 official + `all()`)
|
|
449
|
+
|
|
450
|
+
**Core Functions:**
|
|
451
|
+
1. `new()` - Create new box with coordinates
|
|
452
|
+
2. `get_left()` - Get left border coordinate
|
|
453
|
+
3. `get_top()` - Get top border price
|
|
454
|
+
4. `get_right()` - Get right border coordinate
|
|
455
|
+
5. `get_bottom()` - Get bottom border price
|
|
456
|
+
6. `copy()` - Create copy of box
|
|
457
|
+
7. `delete()` - Delete box (no-op in JS)
|
|
458
|
+
|
|
459
|
+
**Coordinate Setters:**
|
|
460
|
+
8. `set_left()` - Set left border
|
|
461
|
+
9. `set_top()` - Set top border
|
|
462
|
+
10. `set_right()` - Set right border
|
|
463
|
+
11. `set_bottom()` - Set bottom border
|
|
464
|
+
12. `set_lefttop()` - Set left-top corner
|
|
465
|
+
13. `set_rightbottom()` - Set right-bottom corner
|
|
466
|
+
14. `set_top_left_point()` - Set top-left point
|
|
467
|
+
15. `set_bottom_right_point()` - Set bottom-right point
|
|
468
|
+
16. `set_extend()` - Set extension mode
|
|
469
|
+
|
|
470
|
+
**Styling Setters:**
|
|
471
|
+
17. `set_border_color()` - Set border color
|
|
472
|
+
18. `set_border_width()` - Set border width
|
|
473
|
+
19. `set_border_style()` - Set border style
|
|
474
|
+
20. `set_bgcolor()` - Set background color
|
|
475
|
+
|
|
476
|
+
**Text Setters:**
|
|
477
|
+
21. `set_text()` - Set box text content
|
|
478
|
+
22. `set_text_size()` - Set text size
|
|
479
|
+
23. `set_text_color()` - Set text color
|
|
480
|
+
24. `set_text_halign()` - Set horizontal alignment
|
|
481
|
+
25. `set_text_valign()` - Set vertical alignment
|
|
482
|
+
26. `set_text_wrap()` - Set text wrapping
|
|
483
|
+
27. `set_text_font_family()` - Set text font
|
|
484
|
+
28. `set_text_formatting()` - Set text formatting (`text.format_bold`, `text.format_italic`)
|
|
485
|
+
29. `set_top_left_point()` / `set_bottom_right_point()` - Set corners via chart.point objects
|
|
486
|
+
30. `all()` - Live boxes in creation order (PineScript `box.all`)
|
|
487
|
+
|
|
488
|
+
### Not Implemented (1 function)
|
|
489
|
+
|
|
490
|
+
1. `set_xloc()` - Set x-location mode and update left/right borders
|
|
491
|
+
|
|
492
|
+
---
|
|
493
|
+
|
|
494
|
+
## label (Label Drawing Objects)
|
|
495
|
+
|
|
496
|
+
### Implemented (21 official + `all()`)
|
|
497
|
+
|
|
498
|
+
**Core Functions:**
|
|
499
|
+
1. `new()` - Create new label
|
|
500
|
+
2. `get_x()` - Get x coordinate
|
|
501
|
+
3. `get_y()` - Get y coordinate
|
|
502
|
+
4. `get_text()` - Get text content
|
|
503
|
+
5. `copy()` - Create copy of label
|
|
504
|
+
6. `delete()` - Delete label (no-op in JS)
|
|
505
|
+
|
|
506
|
+
**Position Setters:**
|
|
507
|
+
7. `set_x()` - Set x coordinate
|
|
508
|
+
8. `set_y()` - Set y coordinate
|
|
509
|
+
9. `set_xy()` - Set both coordinates
|
|
510
|
+
10. `set_xloc()` - Set x location mode
|
|
511
|
+
11. `set_yloc()` - Set y location mode
|
|
512
|
+
|
|
513
|
+
**Content Setters:**
|
|
514
|
+
12. `set_text()` - Set text content
|
|
515
|
+
13. `set_tooltip()` - Set tooltip text
|
|
516
|
+
|
|
517
|
+
**Styling Setters:**
|
|
518
|
+
14. `set_color()` - Set label color
|
|
519
|
+
15. `set_textcolor()` - Set text color
|
|
520
|
+
16. `set_style()` - Set label style
|
|
521
|
+
17. `set_size()` - Set label size
|
|
522
|
+
18. `set_textalign()` - Set text alignment
|
|
523
|
+
19. `set_text_font_family()` - Set text font
|
|
524
|
+
20. `set_point()` - Set label position via chart.point object
|
|
525
|
+
21. `set_text_formatting()` - Set text formatting (`text.format_bold`, `text.format_italic`)
|
|
526
|
+
22. `all()` - Live labels in creation order (PineScript `label.all`)
|
|
527
|
+
|
|
528
|
+
### Not Implemented (0 functions)
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
## linefill (Linefill Drawing Objects)
|
|
533
|
+
|
|
534
|
+
### Implemented (5 functions)
|
|
535
|
+
|
|
536
|
+
1. `new()` - Create new linefill between two lines
|
|
537
|
+
2. `get_line1()` - Get first line reference
|
|
538
|
+
3. `get_line2()` - Get second line reference
|
|
539
|
+
4. `set_color()` - Set fill color
|
|
540
|
+
5. `delete()` - Delete linefill
|
|
541
|
+
6. `all()` - Live linefills in creation order (PineScript `linefill.all`); a linefill is also deleted by `line.delete` of one of its lines
|
|
542
|
+
|
|
543
|
+
### Not Implemented (0 functions)
|
|
544
|
+
|
|
545
|
+
All 5 official linefill functions are implemented.
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## chartPoint (Chart Point Objects)
|
|
550
|
+
|
|
551
|
+
### Implemented (5 functions)
|
|
552
|
+
|
|
553
|
+
1. `new()` - Create a new chart point with time, index, and price coordinates
|
|
554
|
+
2. `from_time()` - Create a chart point from timestamp and price
|
|
555
|
+
3. `from_index()` - Create a chart point from bar index and price
|
|
556
|
+
4. `copy()` - Create a copy of a chart point
|
|
557
|
+
5. `now()` - Chart point of the current bar (script API `chart.point.now(price?)`, inside `eachBar()`; price defaults to `close`)
|
|
558
|
+
|
|
559
|
+
### Not Implemented (0 functions)
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
## polyline (Polyline Drawing Objects)
|
|
564
|
+
|
|
565
|
+
### Implemented (2 official + 1 custom = 3 functions)
|
|
566
|
+
|
|
567
|
+
1. `new()` - Create a new polyline connecting multiple chart points
|
|
568
|
+
2. `delete()` - Delete a polyline
|
|
569
|
+
3. `get_all()` - Get all active polylines (custom addition, not in official API)
|
|
570
|
+
4. `all()` - Live polylines in creation order (PineScript `polyline.all`)
|
|
571
|
+
|
|
572
|
+
### Not Implemented (0 official functions)
|
|
573
|
+
|
|
574
|
+
All 2 official polyline functions are implemented.
|
|
575
|
+
|
|
576
|
+
**Note:** `curved` is passed to the renderer in `result.polylines` (`curved: true`).
|
|
577
|
+
|
|
578
|
+
---
|
|
579
|
+
|
|
580
|
+
## table (Table Drawing Objects)
|
|
581
|
+
|
|
582
|
+
### Implemented (22 official + `all`)
|
|
583
|
+
|
|
584
|
+
1. `new()` - Create a table at a `position.*` (columns, rows, bgcolor, frame and border colour / width, force_overlay)
|
|
585
|
+
2. `cell()` - Define a cell (text, width, height, text colour / alignment / size, bgcolor, tooltip, font, formatting)
|
|
586
|
+
3. `cell_set_text()`, `cell_set_width()`, `cell_set_height()`, `cell_set_text_color()`, `cell_set_text_halign()`,
|
|
587
|
+
`cell_set_text_valign()`, `cell_set_text_size()`, `cell_set_bgcolor()`, `cell_set_tooltip()`,
|
|
588
|
+
`cell_set_text_font_family()`, `cell_set_text_formatting()` - Change one property of a cell (11 functions)
|
|
589
|
+
4. `merge_cells()` - Merge a range of cells
|
|
590
|
+
5. `clear()` - Remove a range of cells
|
|
591
|
+
6. `set_position()`, `set_bgcolor()`, `set_frame_color()`, `set_frame_width()`, `set_border_color()`,
|
|
592
|
+
`set_border_width()` - Change the table (6 functions)
|
|
593
|
+
7. `delete()` - Delete the table
|
|
594
|
+
8. `all()` - Live tables in creation order (PineScript `table.all`)
|
|
595
|
+
|
|
596
|
+
A column or row outside the table throws, as PineScript stops the script. Tables have no getters; the script API
|
|
597
|
+
returns the live tables in `result.tables`. `position.*` and `text.align_*` / `text.wrap_*` constants are provided.
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
## map (Map/Dictionary Operations)
|
|
602
|
+
|
|
603
|
+
### Implemented (11 functions)
|
|
604
|
+
|
|
605
|
+
1. `new_map()` - Create a new map (PineScript `map.new<keyType, valueType>()`)
|
|
606
|
+
2. `put()` - Add or update a key-value pair; returns the previous value or `undefined` (`na`)
|
|
607
|
+
3. `put_all()` - Add all key-value pairs from another map
|
|
608
|
+
4. `get()` - Get value by key (`undefined` when missing)
|
|
609
|
+
5. `contains()` - Check if map contains a key
|
|
610
|
+
6. `remove()` - Remove a key-value pair; returns the removed value or `undefined`
|
|
611
|
+
7. `size()` - Get number of entries
|
|
612
|
+
8. `clear()` - Remove all key-value pairs
|
|
613
|
+
9. `keys()` - Get array of all keys (insertion order)
|
|
614
|
+
10. `values()` - Get array of all values (insertion order)
|
|
615
|
+
11. `copy()` - Create a shallow copy
|
|
616
|
+
|
|
617
|
+
A map is a JS `Map`: insertion order, exact key equality, the return values and the 50,000-pair limit
|
|
618
|
+
follow PineScript.
|
|
619
|
+
|
|
620
|
+
### Not Implemented (0 functions)
|
|
621
|
+
|
|
622
|
+
**Note:** Maps are a core data structure in PineScript v6, useful for key-value lookups in computational contexts (e.g., symbol-to-weight mappings, level tracking).
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|
|
626
|
+
## Script API (`oakscriptjs/script`)
|
|
627
|
+
|
|
628
|
+
The script entry provides the PineScript-style authoring surface. These are not
|
|
629
|
+
`ta.*`-style calculation functions; they are declarations collected by
|
|
630
|
+
`executeScript(body, bars, inputs)`.
|
|
631
|
+
|
|
632
|
+
### Declarations
|
|
633
|
+
|
|
634
|
+
| Function | Status | Notes |
|
|
635
|
+
|----------|--------|-------|
|
|
636
|
+
| `indicator()` | Implemented | title, shorttitle, overlay (default false, as Pine), precision, format, scale, max_*_count |
|
|
637
|
+
| `input.int/float/bool/string/color/source/price` | Implemented | declares AND returns the current value; `input.source` returns a Series (default `close` or `"close"`); `input.price` declares `InputConfig.type` `'price'` (a number) |
|
|
638
|
+
| `input.timeframe/session/time` | Implemented | timeframe and session strings, time in UNIX ms; the default is returned as written (`""` is the chart timeframe) |
|
|
639
|
+
| `input.text_area` | Implemented | multi-line string (`InputConfig.type` `'text_area'`, display `none` by default) |
|
|
640
|
+
| `enum`, `input.enum` | Implemented | `defineEnum({ name: title })` makes the enum (fields compare with `===`, `String()` is the title); `input.enum` declares `InputConfig.type` `'enum'` with the field names as `options` and their `optionsTitles`, stores the name and returns the field |
|
|
641
|
+
| `input.int/float` `options` | Implemented | a list of numbers (`InputConfig.options`) |
|
|
642
|
+
| input options | Implemented | every `input.*` kind: `group`, `inline`, `tooltip`, `confirm`, `display`, `active`, copied to `InputConfig`; `isInputActive()` evaluates `active`; the title in the options object or every argument named (`{ defval, title, ... }`); an unknown name throws |
|
|
643
|
+
| `plot()` | Implemented | static or per-bar color, style, linestyle, linewidth, histbase, offset, force_overlay; `plot.style_*`, `plot.linestyle_*` constants; a number plots a flat line (`plot(50)`) |
|
|
644
|
+
| `hline()` | Implemented | static level, color, linestyle (default dashed), linewidth; `hline.style_*` constants |
|
|
645
|
+
| `fill()` | Implemented | plot-to-plot or hline-to-hline |
|
|
646
|
+
| `plotshape()` | Implemented | per-bar marker; style, location, color, text, size, offset, tooltip, force_overlay |
|
|
647
|
+
| `plotchar()` | Implemented | per-bar character marker; force_overlay |
|
|
648
|
+
| `plotarrow()` | Implemented | up / down arrow per bar by the sign of the value; colorup, colordown, minheight, maxheight, offset, force_overlay; `arrowConfig` + `result.arrows` |
|
|
649
|
+
| `bgcolor()` | Implemented | per-bar background color (static or `color.when` array), offset, force_overlay |
|
|
650
|
+
| `barcolor()` | Implemented | per-bar candle color override |
|
|
651
|
+
| `plotcandle()` | Implemented | candles from open / high / low / close (no candle on a bar with an na value); static or per-bar color, wickcolor, bordercolor, display, force_overlay; `candleConfig` + `result.plotCandles` |
|
|
652
|
+
| `plotbar()` | Implemented | OHLC bars; static or per-bar color, display, force_overlay; `candleConfig` + `result.plotBars` |
|
|
653
|
+
| `alertcondition()` | Implemented | collected for the host alert engine |
|
|
654
|
+
| `alert()` | Implemented | calls per bar (message, `alert.freq_*`) collected for the host alert engine |
|
|
655
|
+
| `log.info()` / `log.warning()` / `log.error()` | Implemented | messages per bar (level, text, script line) in `result.logs` for the host's logs panel |
|
|
656
|
+
| constants | Implemented | `shape.*`, `location.*`, `size.*`, `xloc.*`, `yloc.*`, `extend.*`, `display.*`, `format.*`, `font.family_*`, `scale.*`, `order.*`, `currency.*`, `adjustment.*`, `label.style_*`, `line.style_*`, `dayofweek.*` (the strings / numbers the functions take) |
|
|
657
|
+
| `bar_index`, `last_bar_index` | Implemented | Series (in a bar loop: `c.i`, `c.n - 1`) |
|
|
658
|
+
| `calc.*`, `color.fade` | Added | not in Pine: plain-English names (`calc.average`, `calc.crossesAbove`, `calc.percentChange`...) beside `ta.*`; `color.fade(c, 0..1)` |
|
|
659
|
+
| `formula()`, `evaluateFormula()` | Added | not in Pine: a calculation as text, parsed (not run as code), with the functions of `FORMULA_FUNCTIONS` |
|
|
660
|
+
| `indicator(pane)`, input `id`, palette, plot ids | Added | not in Pine: `pane: 'price' \| 'separate' \| 'auto'`; `input.*(..., { id })`; `ScriptOptions.palette` / `plotIds: 'title'` |
|
|
661
|
+
| `defineIndicatorFromJson()` | Added | not in Pine: an indicator in JSON (`checkIndicatorJson`, `indicatorBodyFromJson`) |
|
|
662
|
+
| `defineIndicator()` | Added | not in Pine: a script body as a ready-to-use indicator (`metadata`, `inputConfig`, `defaultInputs`, `plotConfig`, `hlineConfig`..., `calculate`, `createRun`, `run`); strict mode on by default |
|
|
663
|
+
| strict mode | Added | not in Pine: `executeScript(..., { strict: true })` throws a `ScriptError` with a plain message for an unknown input name, an input value of the wrong type / range / options, an unknown option of `plot`, `hline`, `plotshape`, `plotchar`, `bgcolor`, `barcolor`, a text that is not a colour; `ScriptRunResult.warnings` lists the drawings deleted over their maximum count |
|
|
664
|
+
| `xloc.pane` | Added | not in Pine: the x coordinates of a line, box, label or polyline are percents of the pane's width (0 left edge, 100 right edge): the drawing stays in place while the user scrolls and zooms |
|
|
665
|
+
| drawing arguments | Implemented | named arguments (an object after the positional ones, Pine names) for `label.new`, `line.new`, `box.new`, `table.new`, `table.cell`, `polyline.new`, `linefill.new`; a Series argument in a bar loop is its value on the current bar |
|
|
666
|
+
| `strategy.opentrades.*(i)` / `strategy.closedtrades.*(i)` | Different | `strategy.opentrades` / `strategy.closedtrades` are the counts; the trades are `strategy.opentrade(i)` / `strategy.closedtrade(i)` |
|
|
667
|
+
|
|
668
|
+
### Per-bar execution
|
|
669
|
+
|
|
670
|
+
| Function | Status | Notes |
|
|
671
|
+
|----------|--------|-------|
|
|
672
|
+
| `eachBar(fn)` | Implemented | runs `fn(c)` once per bar; native JS operators, closure `var`-state, `c.get(src, k)` history, `c.prev(k)` self-reference, `c.i` bar_index |
|
|
673
|
+
| `persist(initial)` | Implemented | PineScript `var` kept by the runtime (`.value`), put back by incremental runs (#196) |
|
|
674
|
+
| `createScriptRun(body, inputs, chart, options)` | Implemented | host side: `update(bars)` calculates the newest bars only on a live update (same results as a full run, #196); drawings of one `eachBar` block and strategies whose engine has `save()` / `restore()` resumed; full runs for `request.security`, `varip`, `timenow`, `last_bar_index`, `math.random`, state outside `persist()` (`fullRunReason`) |
|
|
675
|
+
| `executeIntrabar(body, bars, inputs, chart, options)` | Implemented | host side: a strategy run again inside a history bar (ticks, order fills), variables rolled back, `varip` kept; resumed from the previous intrabar run of the backtest, same order calls as the full replay (#206); `IntrabarUpdate` / `recorder.intrabarFullRunReason`, `resume: false` |
|
|
676
|
+
| `seriesOf(values)` | Implemented | wraps a side-output array as a Series |
|
|
677
|
+
| `chart.left_visible_bar_time`, `chart.right_visible_bar_time` | Implemented | ms, from `ChartContext.leftVisibleBarTime / rightVisibleBarTime` (default: the first / last bar); `ScriptRunResult.usesVisibleRange` tells the host that the script read them |
|
|
678
|
+
| `chart.is_standard`, `is_heikinashi`, `is_renko`, `is_kagi`, `is_linebreak`, `is_pnf`, `is_range` | Implemented | from `ChartContext.chartType` (default: standard) |
|
|
679
|
+
| `barstate.*` | Implemented | isfirst, islast, ishistory, isrealtime, isnew, isconfirmed, islastconfirmedhistory (1 / 0 Series); the last bar state comes from `ChartContext.lastBarConfirmed / realtime / lastBarNew` |
|
|
680
|
+
| `callsite.*` | Implemented | per-call history of `ta.*` calls in `if` blocks and lazy `and` / `or` operands: `whenCalled`, `crossover`, `crossunder`, `crossoverByBar` / `crossunderByBar` (several calls on one bar, as in a `for` loop), `cross`, `barssince`, `lowest`, `highest` (also for a series length), `lowestByBar`, `highestByBar`, `linreg` (history kept by bar), `sum`, `sma`, `stdev` (calls in a loop, one or several lengths) |
|
|
681
|
+
| `taStep.*` | Implemented | `ta.*` one bar at a time, `step` / `commit` (live updates of the forming bar, #196): `sum`, `sma`, `variance`, `stdev`, `ema`, `rma`, `wma`, `change`, `mom`, `roc`, `rsi`, `cum`, `barssince`, `valuewhen`, `crossover`, `crossunder`, `cross`, `tr`, `atr`, `obv`, `highest`, `lowest`, `macd`, `bb`, `vwma`, `stoch`, `hma`, `dev`, `cci`, `mfi`, `dmi`, `linreg`, `percentrank`, `median`, `correlation`, `wpr`, `supertrend`; the same doubles as `taCore` |
|
|
682
|
+
|
|
683
|
+
### Run result (`IndicatorResult`)
|
|
684
|
+
|
|
685
|
+
`plots` (keyed by id), optional `hlines`, `fills`, and the output data:
|
|
686
|
+
`markers` (`MarkerData[]`), `arrows` (`ArrowData[]`), `bgColors` (`BgColorData[]`), `barColors` (`BarColorData[]`),
|
|
687
|
+
`plotCandles` / `plotBars` (keyed by id), and the drawings alive after the last bar: `labels`, `lines`, `boxes`,
|
|
688
|
+
`linefills`, `polylines`, `tables` (x coordinates as bar times, future bars extrapolated).
|
|
689
|
+
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
## All Not-Implemented Functions (Summary)
|
|
693
|
+
|
|
694
|
+
| # | Namespace | Function | Description |
|
|
695
|
+
|---|-----------|----------|-------------|
|
|
696
|
+
| ~~1~~ | ~~array~~ | ~~`new_table()`~~ | ~~Implemented~~ |
|
|
697
|
+
| ~~2~~ | ~~str~~ | ~~`repeat()`~~ | ~~Implemented~~ |
|
|
698
|
+
| ~~3~~ | ~~time~~ | ~~`time_close()`~~ | ~~Implemented (script API)~~ |
|
|
699
|
+
| ~~4~~ | ~~timeframe~~ | ~~`change()`~~ | ~~Implemented (script API)~~ |
|
|
700
|
+
| ~~5~~ | ~~timeframe~~ | ~~`from_seconds()`~~ | ~~Implemented~~ |
|
|
701
|
+
| ~~6~~ | ~~timeframe~~ | ~~`in_seconds()`~~ | ~~Implemented~~ |
|
|
702
|
+
| ~~7~~ | ~~line~~ | ~~`set_first_point()`~~ | ~~Implemented~~ |
|
|
703
|
+
| ~~8~~ | ~~line~~ | ~~`set_second_point()`~~ | ~~Implemented~~ |
|
|
704
|
+
| ~~9~~ | ~~box~~ | ~~`set_text_formatting()`~~ | ~~Implemented~~ |
|
|
705
|
+
| ~~10~~ | ~~box~~ | ~~`set_xloc()`~~ | ~~Implemented~~ |
|
|
706
|
+
| ~~11~~ | ~~label~~ | ~~`set_point()`~~ | ~~Implemented~~ |
|
|
707
|
+
| ~~12~~ | ~~label~~ | ~~`set_text_formatting()`~~ | ~~Implemented~~ |
|
|
708
|
+
| ~~13~~ | ~~chartPoint~~ | ~~`now()`~~ | ~~Implemented~~ |
|
|
709
|
+
| ~~14~~ | ~~map~~ | ~~`clear()`~~ | ~~Implemented~~ |
|
|
710
|
+
| ~~15~~ | ~~map~~ | ~~`contains()`~~ | ~~Implemented~~ |
|
|
711
|
+
| ~~16~~ | ~~map~~ | ~~`copy()`~~ | ~~Implemented~~ |
|
|
712
|
+
| ~~17~~ | ~~map~~ | ~~`get()`~~ | ~~Implemented~~ |
|
|
713
|
+
| ~~18~~ | ~~map~~ | ~~`keys()`~~ | ~~Implemented~~ |
|
|
714
|
+
| ~~19~~ | ~~map~~ | ~~`new()`~~ | ~~Implemented~~ |
|
|
715
|
+
| ~~20~~ | ~~map~~ | ~~`put()`~~ | ~~Implemented~~ |
|
|
716
|
+
| ~~21~~ | ~~map~~ | ~~`put_all()`~~ | ~~Implemented~~ |
|
|
717
|
+
| ~~22~~ | ~~map~~ | ~~`remove()`~~ | ~~Implemented~~ |
|
|
718
|
+
| ~~23~~ | ~~map~~ | ~~`size()`~~ | ~~Implemented~~ |
|
|
719
|
+
| ~~24~~ | ~~map~~ | ~~`values()`~~ | ~~Implemented~~ |
|
|
720
|
+
|
|
721
|
+
**Total: 1 official function not yet implemented across in-scope namespaces.**
|
|
722
|
+
|
|
723
|
+
---
|
|
724
|
+
|
|
725
|
+
## Custom Additions (Not in Official PineScript v6 API)
|
|
726
|
+
|
|
727
|
+
These functions are implemented in OakScriptJS but do not exist in the official PineScript v6 reference:
|
|
728
|
+
|
|
729
|
+
| Namespace | Function | Purpose |
|
|
730
|
+
|-----------|----------|---------|
|
|
731
|
+
| ta | `ichimoku()` | Ichimoku Kinko Hyo indicator |
|
|
732
|
+
| ta | `zigzag()` | ZigZag trend reversal indicator |
|
|
733
|
+
| array | `new_array()` | Generic array constructor |
|
|
734
|
+
| str | `charAt()` | Get character at index |
|
|
735
|
+
| str | `concat()` | Concatenate strings |
|
|
736
|
+
| str | `trimLeft()` | Trim left whitespace |
|
|
737
|
+
| str | `trimRight()` | Trim right whitespace |
|
|
738
|
+
| color | `from_hex()` | Create color from hex string |
|
|
739
|
+
| matrix | `new_matrix()` | Generic matrix constructor |
|
|
740
|
+
| polyline | `get_all()` | Get all active polylines |
|
|
741
|
+
| time | `inSession()` | Session test of `time(timeframe, session, timezone)` |
|
|
742
|
+
| time | `now()` | Current time helper |
|
|
743
|
+
|
|
744
|
+
---
|
|
745
|
+
|
|
746
|
+
## Notes
|
|
747
|
+
|
|
748
|
+
1. **Two API Levels**:
|
|
749
|
+
- **Core TA** (`taCore`): Array-based functions like `taCore.sma(priceArray, 14)`
|
|
750
|
+
- **TA-Series** (`ta`): Series-based wrappers like `ta.sma(closeSeries, 14)`
|
|
751
|
+
|
|
752
|
+
2. **Series Class**: The `Series` class provides lazy evaluation and method chaining. JavaScript has no operator overloading, so `(close - open) / (high - low)` is written `close.sub(open).div(high.sub(low))`; inside `eachBar()` the values are plain numbers and native operators work.
|
|
753
|
+
|
|
754
|
+
3. **Deterministic Random**: `math.random(min, max, seed)` gives the PineScript sequence of the seed, one number per call; two call sites with the same seed use `callsite.random(seed)`.
|
|
755
|
+
|
|
756
|
+
4. **Type-Specific Arrays**: `new_bool()`, `new_int()`, `new_float()`, `new_string()`, and drawing object arrays are type-specific wrappers around `new_array()`.
|
|
757
|
+
|
|
758
|
+
---
|
|
759
|
+
|
|
760
|
+
## Contributing
|
|
761
|
+
|
|
762
|
+
When implementing new functions:
|
|
763
|
+
|
|
764
|
+
1. Match PineScript v6 API signatures exactly
|
|
765
|
+
2. Add comprehensive JSDoc comments
|
|
766
|
+
3. Include examples in documentation
|
|
767
|
+
4. Add unit tests with expected outputs from PineScript
|
|
768
|
+
5. Update this inventory file
|
|
769
|
+
6. If the function accepts arrays, implement it in the core namespace (e.g., `src/ta/`)
|
|
770
|
+
7. Add a Series-based wrapper in `src/ta-series.ts` if the function is commonly used with Series
|
|
771
|
+
|
|
772
|
+
For questions about priorities or implementation details, see the PineScript v6 reference documentation.
|