lightweight-charts-indicators 0.13.1 → 0.13.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/candlestick-port/adapter.d.ts +10 -0
- package/dist/candlestick-port/adapter.d.ts.map +1 -1
- package/dist/index.cjs +29 -8
- package/dist/index.d.ts +16 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +29 -8
- package/dist/standard/auto-fib-extension.d.ts +11 -3
- package/dist/standard/auto-fib-extension.d.ts.map +1 -1
- package/dist/standard/auto-fib-retracement.d.ts +10 -3
- package/dist/standard/auto-fib-retracement.d.ts.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter: fits the oakscriptjs candlestick port (PatternDef + patternScript)
|
|
3
|
+
* to this repo's `calculate(bars, inputs, chart): IndicatorResult` registry convention.
|
|
4
|
+
*
|
|
5
|
+
* Each pattern runs through `executeScript(() => patternScript(def), bars, inputs)`, which returns the
|
|
6
|
+
* IndicatorResult shape of this package (markers, bgColors, barColors); the result is passed through.
|
|
7
|
+
*/
|
|
8
|
+
import { type AlertConditionConfig } from 'oakscriptjs/script';
|
|
1
9
|
import type { ChartContext } from '../chart-context';
|
|
2
10
|
import type { Bar, IndicatorResult, InputConfig, PlotConfig } from 'oakscriptjs';
|
|
3
11
|
import type { BarColorData, BgColorData, MarkerData } from '../types';
|
|
@@ -16,6 +24,8 @@ export interface PortIndicator {
|
|
|
16
24
|
inputConfig: InputConfig[];
|
|
17
25
|
plotConfig: PlotConfig[];
|
|
18
26
|
defaultInputs: Record<string, unknown>;
|
|
27
|
+
/** The script's alertcondition() declarations; the result's `alerts` gives the bars on which each one is true. */
|
|
28
|
+
alertConditions: AlertConditionConfig[];
|
|
19
29
|
calculate: (bars: Bar[], inputs?: Record<string, unknown>, chart?: ChartContext) => PortResult;
|
|
20
30
|
}
|
|
21
31
|
export interface PortEntry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/candlestick-port/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/candlestick-port/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAiB,KAAK,oBAAoB,EAAwB,MAAM,oBAAoB,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAKtE,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACzC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,YAAY,EAAE,CAAC;CAC3B,CAAC;AAQF,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAClE,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,kHAAkH;IAClH,eAAe,EAAE,oBAAoB,EAAE,CAAC;IACxC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,YAAY,KAAK,UAAU,CAAC;CAChG;AAkFD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,CAAC;AAE3E,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,EAAE,SAAS,EAK5C,CAAC;AAEH,gHAAgH;AAChH,eAAO,MAAM,0BAA0B,EAAE,SAIxC,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -48236,6 +48236,7 @@ function buildIndicator(body, shortName) {
|
|
|
48236
48236
|
inputConfig: probe.inputConfig,
|
|
48237
48237
|
plotConfig: probe.plotConfig,
|
|
48238
48238
|
defaultInputs: probe.defaultInputs,
|
|
48239
|
+
alertConditions: probe.alertConfig,
|
|
48239
48240
|
calculate: (bars, inputs = {}, chart) => convert((0, import_script30.executeScript)(body, bars, inputs, chart))
|
|
48240
48241
|
};
|
|
48241
48242
|
}
|
|
@@ -49536,7 +49537,8 @@ function calculate416(bars, inputs = {}, chart) {
|
|
|
49536
49537
|
plots: {},
|
|
49537
49538
|
lines: [],
|
|
49538
49539
|
labels: [],
|
|
49539
|
-
linefills: []
|
|
49540
|
+
linefills: [],
|
|
49541
|
+
alertCalls: []
|
|
49540
49542
|
};
|
|
49541
49543
|
if (n === 0)
|
|
49542
49544
|
return empty;
|
|
@@ -49661,6 +49663,10 @@ function calculate416(bars, inputs = {}, chart) {
|
|
|
49661
49663
|
const lastTime = bars[n - 1].time;
|
|
49662
49664
|
const labelTime = left ? lineLast.time1 : !cfg.extendRight ? lineLast.time2 : lastTime;
|
|
49663
49665
|
const fmt2 = (v) => import_oakscriptjs381.str.tostring(v, "mintick", tick);
|
|
49666
|
+
const alertCalls = [];
|
|
49667
|
+
const ticker = tickerOf(chart);
|
|
49668
|
+
const c0 = bars[n - 1].close;
|
|
49669
|
+
const c1 = n > 1 ? bars[n - 2].close : NaN;
|
|
49664
49670
|
let other = null;
|
|
49665
49671
|
for (const k of PROCESS_ORDER) {
|
|
49666
49672
|
if (!cfg[`show_${k}`])
|
|
@@ -49668,6 +49674,9 @@ function calculate416(bars, inputs = {}, chart) {
|
|
|
49668
49674
|
const m = cfg[`value_${k}`];
|
|
49669
49675
|
const css2 = cfg[`color_${k}`];
|
|
49670
49676
|
const r = base + (cfg.reverse ? -1 : 1) * diff * m;
|
|
49677
|
+
if (gt19(r, c0) && gt19(c1, r) || gt19(c0, r) && gt19(r, c1)) {
|
|
49678
|
+
alertCalls.push({ time: bars[n - 1].time, message: "Autofib: " + ticker + " crossing level " + import_oakscriptjs381.str.tostring(m), freq: "once_per_bar" });
|
|
49679
|
+
}
|
|
49671
49680
|
const id = {
|
|
49672
49681
|
time1: lineLast.time1,
|
|
49673
49682
|
price1: r,
|
|
@@ -49695,9 +49704,9 @@ function calculate416(bars, inputs = {}, chart) {
|
|
|
49695
49704
|
linefills.push({ line1: id, line2: other, color: import_oakscriptjs381.color.new(css2, cfg.backgroundTransparency) });
|
|
49696
49705
|
other = id;
|
|
49697
49706
|
}
|
|
49698
|
-
return { ...empty, lines, labels, linefills };
|
|
49707
|
+
return { ...empty, lines, labels, linefills, alertCalls };
|
|
49699
49708
|
}
|
|
49700
|
-
var AutoFibExtension = { calculate: calculate416, metadata: metadata416, defaultInputs: defaultInputs416, inputConfig: inputConfig416, plotConfig: plotConfig416 };
|
|
49709
|
+
var AutoFibExtension = { calculate: calculate416, metadata: metadata416, defaultInputs: defaultInputs416, inputConfig: inputConfig416, plotConfig: plotConfig416, hasAlertFunction: true };
|
|
49701
49710
|
|
|
49702
49711
|
// src/standard/auto-fib-retracement.ts
|
|
49703
49712
|
var import_oakscriptjs382 = require("oakscriptjs");
|
|
@@ -49872,7 +49881,7 @@ function calculate417(bars, inputs = {}, chart) {
|
|
|
49872
49881
|
const tick = mintickOf(chart);
|
|
49873
49882
|
const meta = { title: metadata417.title, shorttitle: metadata417.shortTitle, overlay: metadata417.overlay };
|
|
49874
49883
|
if (n === 0)
|
|
49875
|
-
return { metadata: meta, plots: {}, lines: [], labels: [], linefills: [] };
|
|
49884
|
+
return { metadata: meta, plots: {}, lines: [], labels: [], linefills: [], alertCalls: [] };
|
|
49876
49885
|
const toMs = chart?.timeUnit === "ms" ? 1 : 1e3;
|
|
49877
49886
|
const timeMs = (t) => t * toMs;
|
|
49878
49887
|
const extending = cfg.extendLeft && cfg.extendRight ? "both" : cfg.extendLeft ? "left" : cfg.extendRight ? "right" : "none";
|
|
@@ -49889,6 +49898,8 @@ function calculate417(bars, inputs = {}, chart) {
|
|
|
49889
49898
|
let height = NaN;
|
|
49890
49899
|
const levelLines = /* @__PURE__ */ new Map();
|
|
49891
49900
|
const levelLabels = /* @__PURE__ */ new Map();
|
|
49901
|
+
const alertCalls = [];
|
|
49902
|
+
const ticker = tickerOf(chart);
|
|
49892
49903
|
for (let i = 0; i < n; i++) {
|
|
49893
49904
|
(0, import_oakscriptjs382.setDrawingBar)(i, i === n - 1);
|
|
49894
49905
|
if (i === n - 1 && zigZag.pivots.length < 2) {
|
|
@@ -49939,6 +49950,11 @@ function calculate417(bars, inputs = {}, chart) {
|
|
|
49939
49950
|
const m = cfg[`value_${k}`];
|
|
49940
49951
|
const css2 = cfg[`color_${k}`];
|
|
49941
49952
|
const r = startPrice + height * m;
|
|
49953
|
+
const c0 = bars[i].close;
|
|
49954
|
+
const c1 = i > 0 ? bars[i - 1].close : NaN;
|
|
49955
|
+
if (gt20(r, c0) && gt20(c1, r) || gt20(c0, r) && gt20(r, c1)) {
|
|
49956
|
+
alertCalls.push({ time: bars[i].time, message: "Autofib: " + ticker + " crossing level " + import_oakscriptjs382.str.tostring(m), freq: "once_per_bar" });
|
|
49957
|
+
}
|
|
49942
49958
|
let id = levelLines.get(k);
|
|
49943
49959
|
if (!id) {
|
|
49944
49960
|
id = (0, import_oakscriptjs382.holdDrawing)(import_oakscriptjs382.line.new(timeMs(s.time), s.price, timeMs(bars[i].time), r, "bar_time", extending, css2, "solid", 1));
|
|
@@ -49972,10 +49988,11 @@ function calculate417(bars, inputs = {}, chart) {
|
|
|
49972
49988
|
plots: {},
|
|
49973
49989
|
lines: out.lines ?? [],
|
|
49974
49990
|
labels: out.labels ?? [],
|
|
49975
|
-
linefills: out.linefills ?? []
|
|
49991
|
+
linefills: out.linefills ?? [],
|
|
49992
|
+
alertCalls
|
|
49976
49993
|
};
|
|
49977
49994
|
}
|
|
49978
|
-
var AutoFibRetracement = { calculate: calculate417, metadata: metadata417, defaultInputs: defaultInputs417, inputConfig: inputConfig417, plotConfig: plotConfig417 };
|
|
49995
|
+
var AutoFibRetracement = { calculate: calculate417, metadata: metadata417, defaultInputs: defaultInputs417, inputConfig: inputConfig417, plotConfig: plotConfig417, hasAlertFunction: true };
|
|
49979
49996
|
|
|
49980
49997
|
// src/standard/auto-pitchfork.ts
|
|
49981
49998
|
var import_oakscriptjs383 = require("oakscriptjs");
|
|
@@ -153736,7 +153753,8 @@ function calculate1214(bars, inputs = {}) {
|
|
|
153736
153753
|
hl2: hl25,
|
|
153737
153754
|
hlc3: hlc32,
|
|
153738
153755
|
ohlc4,
|
|
153739
|
-
hlcc4
|
|
153756
|
+
hlcc4,
|
|
153757
|
+
volume: b.volume ?? NaN
|
|
153740
153758
|
};
|
|
153741
153759
|
const src = srcVals[cfg.trendSource] ?? b.close;
|
|
153742
153760
|
let rs;
|
|
@@ -303005,6 +303023,7 @@ function candlestickEntries(pairs) {
|
|
|
303005
303023
|
inputConfig: ind.inputConfig,
|
|
303006
303024
|
plotConfig: ind.plotConfig,
|
|
303007
303025
|
defaultInputs: { ...ind.defaultInputs },
|
|
303026
|
+
...ind.alertConditions?.length ? { alertConditions: ind.alertConditions } : {},
|
|
303008
303027
|
calculate: ind.calculate
|
|
303009
303028
|
}));
|
|
303010
303029
|
}
|
|
@@ -324811,6 +324830,7 @@ var registryPart11 = [
|
|
|
324811
324830
|
inputConfig: inputConfig416,
|
|
324812
324831
|
plotConfig: plotConfig416,
|
|
324813
324832
|
defaultInputs: { ...defaultInputs416 },
|
|
324833
|
+
hasAlertFunction: true,
|
|
324814
324834
|
calculate: calculate416
|
|
324815
324835
|
},
|
|
324816
324836
|
{
|
|
@@ -324825,6 +324845,7 @@ var registryPart11 = [
|
|
|
324825
324845
|
inputConfig: inputConfig417,
|
|
324826
324846
|
plotConfig: plotConfig417,
|
|
324827
324847
|
defaultInputs: { ...defaultInputs417 },
|
|
324848
|
+
hasAlertFunction: true,
|
|
324828
324849
|
calculate: calculate417
|
|
324829
324850
|
},
|
|
324830
324851
|
{
|
|
@@ -325095,4 +325116,4 @@ var registryPart11 = [
|
|
|
325095
325116
|
}
|
|
325096
325117
|
];
|
|
325097
325118
|
var indicatorRegistry = [...registryPart1, ...registryPart11, ...registryPart2, ...registryPart3, ...registryPart4, ...registryPart5, ...registryPart6, ...registryPart7, ...registryPart8, ...registryPart9, ...registryPart10];
|
|
325098
|
-
var version = "0.13.
|
|
325119
|
+
var version = "0.13.3";
|
package/dist/index.d.ts
CHANGED
|
@@ -775,7 +775,7 @@ export declare const UpsideTasukiGap: import("./candlestick-port/adapter").PortI
|
|
|
775
775
|
export declare const FallingThreeMethods: import("./candlestick-port/adapter").PortIndicator;
|
|
776
776
|
export declare const RisingThreeMethods: import("./candlestick-port/adapter").PortIndicator;
|
|
777
777
|
export declare const AllPatterns: import("./candlestick-port/adapter").PortIndicator;
|
|
778
|
-
export type { MarkerData, MarkerPosition, MarkerShape, PineSize, BarColorData, BgColorData, PlotCandleData, PlotBarData, LabelData, LabelStyle, LineDrawingData, BoxData, LinefillData, PolylineData, TableData, TableCell, TableCellData, TableMergeData, TablePosition, } from './types';
|
|
778
|
+
export type { MarkerData, MarkerPosition, MarkerShape, PineSize, BarColorData, BgColorData, PlotCandleData, PlotBarData, LabelData, LabelStyle, LineDrawingData, BoxData, LinefillData, PolylineData, TableData, TableCell, TableCellData, TableMergeData, TablePosition, AlertCall, } from './types';
|
|
779
779
|
export { barInterval, barTime } from './bar-time';
|
|
780
780
|
export { AroonOscillator, calculate as calculateAroonOscillator } from './standard/aroon-oscillator';
|
|
781
781
|
export type { AroonOscillatorInputs } from './standard/aroon-oscillator';
|
|
@@ -3348,6 +3348,20 @@ export interface IndicatorRegistryEntry {
|
|
|
3348
3348
|
* `MissingSymbolDataError` that lists the same requests.
|
|
3349
3349
|
*/
|
|
3350
3350
|
requiredSymbols?: (inputs: any, chart?: ChartContext) => SymbolRequest[];
|
|
3351
|
+
/**
|
|
3352
|
+
* The alert conditions the indicator declares (PineScript `alertcondition()`): id, title and default message. The
|
|
3353
|
+
* result of `calculate` has an `alerts` array with, per condition id, the times of the bars on which it is true.
|
|
3354
|
+
*/
|
|
3355
|
+
alertConditions?: {
|
|
3356
|
+
id: string;
|
|
3357
|
+
title: string;
|
|
3358
|
+
message?: string;
|
|
3359
|
+
}[];
|
|
3360
|
+
/**
|
|
3361
|
+
* True when the indicator calls PineScript `alert()`: an alert can watch "Any alert() function call". The result of
|
|
3362
|
+
* `calculate` then has an `alertCalls` array (bar time, message, frequency of each call).
|
|
3363
|
+
*/
|
|
3364
|
+
hasAlertFunction?: boolean;
|
|
3351
3365
|
/** `chart`: what the caller knows about the chart and its symbol (tick, time zone, ...), see ChartContext */
|
|
3352
3366
|
calculate: (bars: Bar[], inputs?: any, chart?: ChartContext) => any;
|
|
3353
3367
|
}
|
|
@@ -3356,5 +3370,5 @@ export type { ChartContext, VisibleRange, SymbolRequest, SymbolInfo } from './ch
|
|
|
3356
3370
|
export { MissingSymbolDataError, symbolBarsOf } from './chart-context';
|
|
3357
3371
|
export { mintickOf, timezoneOf, tickeridOf, tickerOf, symbolTypeOf, currencyOf, basecurrencyOf, rootOf, foregroundColorOf, backgroundColorOf, lastBarConfirmedOf, nowOf, visibleRangeOf, } from './chart-context';
|
|
3358
3372
|
export { securityOther, securityOtherValues, securityLowerTf, otherSymbolChart, spreadSymbols, spreadBars, spreadOptions, type OtherSymbolOptions, type OtherSymbolChart, type SymbolCalendar, } from './other-symbol';
|
|
3359
|
-
export declare const version = "0.13.
|
|
3373
|
+
export declare const version = "0.13.3";
|
|
3360
3374
|
//# sourceMappingURL=index.d.ts.map
|