lightweight-charts-indicators 0.16.2 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert-states.d.ts +24 -0
- package/dist/alert-states.d.ts.map +1 -0
- package/dist/helpers.d.ts +2 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.mjs +33 -0
- package/dist/index.cjs +5136 -4896
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +5142 -4896
- package/dist/sources.mjs +1 -1
- package/dist/standard/awesome-oscillator.d.ts +7 -1
- package/dist/standard/awesome-oscillator.d.ts.map +1 -1
- package/dist/standard/gaps.d.ts +6 -0
- package/dist/standard/gaps.d.ts.map +1 -1
- package/dist/standard/linreg-channel.d.ts +9 -0
- package/dist/standard/linreg-channel.d.ts.map +1 -1
- package/dist/standard/macd.d.ts +7 -1
- package/dist/standard/macd.d.ts.map +1 -1
- package/dist/standard/rsi-divergence-indicator.d.ts +5 -0
- package/dist/standard/rsi-divergence-indicator.d.ts.map +1 -1
- package/dist/standard/rsi.d.ts +5 -0
- package/dist/standard/rsi.d.ts.map +1 -1
- package/dist/standard/supertrend.d.ts +7 -1
- package/dist/standard/supertrend.d.ts.map +1 -1
- package/dist/standard/technicals.d.ts +5 -0
- package/dist/standard/technicals.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert conditions of the built-ins (PineScript `alertcondition()`): the declaration on the registry entry and the
|
|
3
|
+
* `alerts` of a result — per condition, the times of the bars on which it is true and whether it is true on the last
|
|
4
|
+
* bar (the shape the script runtime gives, oakscriptjs AlertState).
|
|
5
|
+
*/
|
|
6
|
+
import type { Bar } from 'oakscriptjs';
|
|
7
|
+
/** One `alertcondition()` of a built-in: id, title and default message, as the reference declares them */
|
|
8
|
+
export interface AlertConditionDecl {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
message?: string;
|
|
12
|
+
}
|
|
13
|
+
/** One condition of a result: the bars (times as given in the input bars) on which it is true */
|
|
14
|
+
export interface AlertConditionState extends AlertConditionDecl {
|
|
15
|
+
triggered: boolean;
|
|
16
|
+
times: number[];
|
|
17
|
+
}
|
|
18
|
+
/** The states of `decls` from one flag per bar for each of them (`flags[k][i]`: condition k is true on bar i) */
|
|
19
|
+
export declare function alertStates(decls: AlertConditionDecl[], bars: Bar[], flags: boolean[][]): AlertConditionState[];
|
|
20
|
+
/** PineScript `ta.crossover(a, b)` per bar (values: numbers, na = NaN / null): a > b now and a <= b on the bar before */
|
|
21
|
+
export declare function crossedOver(a: ArrayLike<number | null | undefined>, b: number | ArrayLike<number | null | undefined>): boolean[];
|
|
22
|
+
/** PineScript `ta.crossunder(a, b)` per bar: a < b now and a >= b on the bar before */
|
|
23
|
+
export declare function crossedUnder(a: ArrayLike<number | null | undefined>, b: number | ArrayLike<number | null | undefined>): boolean[];
|
|
24
|
+
//# sourceMappingURL=alert-states.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-states.d.ts","sourceRoot":"","sources":["../src/alert-states.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,0GAA0G;AAC1G,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,iGAAiG;AACjG,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,iHAAiH;AACjH,wBAAgB,WAAW,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,mBAAmB,EAAE,CAO/G;AAED,yHAAyH;AACzH,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,EAAE,CAQhI;AAED,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,EAAE,CAQjI"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Helpers the built-in indicator sources import (`lightweight-charts-indicators/helpers`): the chart context
|
|
3
|
-
* accessors, higher-timeframe periods, other-symbol requests, lower-timeframe volume and
|
|
3
|
+
* accessors, higher-timeframe periods, other-symbol requests, lower-timeframe volume, bar times and alert condition states. A source given by
|
|
4
4
|
* `lightweight-charts-indicators/sources` imports from here instead of the library's own relative paths, so a host
|
|
5
5
|
* that runs the source as a script provides this one module next to oakscriptjs.
|
|
6
6
|
*/
|
|
@@ -9,4 +9,5 @@ export * from './anchor-period';
|
|
|
9
9
|
export * from './other-symbol';
|
|
10
10
|
export * from './lower-tf-volume';
|
|
11
11
|
export * from './bar-time';
|
|
12
|
+
export * from './alert-states';
|
|
12
13
|
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
package/dist/helpers.mjs
CHANGED
|
@@ -580,14 +580,47 @@ function upDownVolumeOfChartBars(bars) {
|
|
|
580
580
|
|
|
581
581
|
// src/bar-time.ts
|
|
582
582
|
import { barInterval as barInterval2, barTime } from "oakscriptjs";
|
|
583
|
+
|
|
584
|
+
// src/alert-states.ts
|
|
585
|
+
function alertStates(decls, bars, flags) {
|
|
586
|
+
return decls.map((d, k) => {
|
|
587
|
+
const f = flags[k] ?? [];
|
|
588
|
+
const times = [];
|
|
589
|
+
for (let i = 0; i < bars.length; i++)
|
|
590
|
+
if (f[i])
|
|
591
|
+
times.push(bars[i].time);
|
|
592
|
+
return { ...d, triggered: !!f[bars.length - 1], times };
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
function crossedOver(a, b) {
|
|
596
|
+
const at = (x, i) => typeof x === "number" ? x : x[i] ?? NaN;
|
|
597
|
+
const out = [];
|
|
598
|
+
for (let i = 0; i < a.length; i++) {
|
|
599
|
+
const v = a[i] ?? NaN, w = at(b, i), pv = i > 0 ? a[i - 1] ?? NaN : NaN, pw = i > 0 ? at(b, i - 1) : NaN;
|
|
600
|
+
out.push(v > w && pv <= pw);
|
|
601
|
+
}
|
|
602
|
+
return out;
|
|
603
|
+
}
|
|
604
|
+
function crossedUnder(a, b) {
|
|
605
|
+
const at = (x, i) => typeof x === "number" ? x : x[i] ?? NaN;
|
|
606
|
+
const out = [];
|
|
607
|
+
for (let i = 0; i < a.length; i++) {
|
|
608
|
+
const v = a[i] ?? NaN, w = at(b, i), pv = i > 0 ? a[i - 1] ?? NaN : NaN, pw = i > 0 ? at(b, i - 1) : NaN;
|
|
609
|
+
out.push(v < w && pv >= pw);
|
|
610
|
+
}
|
|
611
|
+
return out;
|
|
612
|
+
}
|
|
583
613
|
export {
|
|
584
614
|
MissingSymbolDataError,
|
|
615
|
+
alertStates,
|
|
585
616
|
backgroundColorOf,
|
|
586
617
|
barInterval2 as barInterval,
|
|
587
618
|
barTime,
|
|
588
619
|
barsAfterLastBar,
|
|
589
620
|
basecurrencyOf,
|
|
590
621
|
chartTimeframe,
|
|
622
|
+
crossedOver,
|
|
623
|
+
crossedUnder,
|
|
591
624
|
currencyOf,
|
|
592
625
|
foregroundColorOf,
|
|
593
626
|
hasCalendar,
|