lightweight-charts-indicators 0.13.2 → 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/index.cjs CHANGED
@@ -49537,7 +49537,8 @@ function calculate416(bars, inputs = {}, chart) {
49537
49537
  plots: {},
49538
49538
  lines: [],
49539
49539
  labels: [],
49540
- linefills: []
49540
+ linefills: [],
49541
+ alertCalls: []
49541
49542
  };
49542
49543
  if (n === 0)
49543
49544
  return empty;
@@ -49662,6 +49663,10 @@ function calculate416(bars, inputs = {}, chart) {
49662
49663
  const lastTime = bars[n - 1].time;
49663
49664
  const labelTime = left ? lineLast.time1 : !cfg.extendRight ? lineLast.time2 : lastTime;
49664
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;
49665
49670
  let other = null;
49666
49671
  for (const k of PROCESS_ORDER) {
49667
49672
  if (!cfg[`show_${k}`])
@@ -49669,6 +49674,9 @@ function calculate416(bars, inputs = {}, chart) {
49669
49674
  const m = cfg[`value_${k}`];
49670
49675
  const css2 = cfg[`color_${k}`];
49671
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
+ }
49672
49680
  const id = {
49673
49681
  time1: lineLast.time1,
49674
49682
  price1: r,
@@ -49696,9 +49704,9 @@ function calculate416(bars, inputs = {}, chart) {
49696
49704
  linefills.push({ line1: id, line2: other, color: import_oakscriptjs381.color.new(css2, cfg.backgroundTransparency) });
49697
49705
  other = id;
49698
49706
  }
49699
- return { ...empty, lines, labels, linefills };
49707
+ return { ...empty, lines, labels, linefills, alertCalls };
49700
49708
  }
49701
- 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 };
49702
49710
 
49703
49711
  // src/standard/auto-fib-retracement.ts
49704
49712
  var import_oakscriptjs382 = require("oakscriptjs");
@@ -49873,7 +49881,7 @@ function calculate417(bars, inputs = {}, chart) {
49873
49881
  const tick = mintickOf(chart);
49874
49882
  const meta = { title: metadata417.title, shorttitle: metadata417.shortTitle, overlay: metadata417.overlay };
49875
49883
  if (n === 0)
49876
- return { metadata: meta, plots: {}, lines: [], labels: [], linefills: [] };
49884
+ return { metadata: meta, plots: {}, lines: [], labels: [], linefills: [], alertCalls: [] };
49877
49885
  const toMs = chart?.timeUnit === "ms" ? 1 : 1e3;
49878
49886
  const timeMs = (t) => t * toMs;
49879
49887
  const extending = cfg.extendLeft && cfg.extendRight ? "both" : cfg.extendLeft ? "left" : cfg.extendRight ? "right" : "none";
@@ -49890,6 +49898,8 @@ function calculate417(bars, inputs = {}, chart) {
49890
49898
  let height = NaN;
49891
49899
  const levelLines = /* @__PURE__ */ new Map();
49892
49900
  const levelLabels = /* @__PURE__ */ new Map();
49901
+ const alertCalls = [];
49902
+ const ticker = tickerOf(chart);
49893
49903
  for (let i = 0; i < n; i++) {
49894
49904
  (0, import_oakscriptjs382.setDrawingBar)(i, i === n - 1);
49895
49905
  if (i === n - 1 && zigZag.pivots.length < 2) {
@@ -49940,6 +49950,11 @@ function calculate417(bars, inputs = {}, chart) {
49940
49950
  const m = cfg[`value_${k}`];
49941
49951
  const css2 = cfg[`color_${k}`];
49942
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
+ }
49943
49958
  let id = levelLines.get(k);
49944
49959
  if (!id) {
49945
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));
@@ -49973,10 +49988,11 @@ function calculate417(bars, inputs = {}, chart) {
49973
49988
  plots: {},
49974
49989
  lines: out.lines ?? [],
49975
49990
  labels: out.labels ?? [],
49976
- linefills: out.linefills ?? []
49991
+ linefills: out.linefills ?? [],
49992
+ alertCalls
49977
49993
  };
49978
49994
  }
49979
- 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 };
49980
49996
 
49981
49997
  // src/standard/auto-pitchfork.ts
49982
49998
  var import_oakscriptjs383 = require("oakscriptjs");
@@ -153737,7 +153753,8 @@ function calculate1214(bars, inputs = {}) {
153737
153753
  hl2: hl25,
153738
153754
  hlc3: hlc32,
153739
153755
  ohlc4,
153740
- hlcc4
153756
+ hlcc4,
153757
+ volume: b.volume ?? NaN
153741
153758
  };
153742
153759
  const src = srcVals[cfg.trendSource] ?? b.close;
153743
153760
  let rs;
@@ -324813,6 +324830,7 @@ var registryPart11 = [
324813
324830
  inputConfig: inputConfig416,
324814
324831
  plotConfig: plotConfig416,
324815
324832
  defaultInputs: { ...defaultInputs416 },
324833
+ hasAlertFunction: true,
324816
324834
  calculate: calculate416
324817
324835
  },
324818
324836
  {
@@ -324827,6 +324845,7 @@ var registryPart11 = [
324827
324845
  inputConfig: inputConfig417,
324828
324846
  plotConfig: plotConfig417,
324829
324847
  defaultInputs: { ...defaultInputs417 },
324848
+ hasAlertFunction: true,
324830
324849
  calculate: calculate417
324831
324850
  },
324832
324851
  {
@@ -325097,4 +325116,4 @@ var registryPart11 = [
325097
325116
  }
325098
325117
  ];
325099
325118
  var indicatorRegistry = [...registryPart1, ...registryPart11, ...registryPart2, ...registryPart3, ...registryPart4, ...registryPart5, ...registryPart6, ...registryPart7, ...registryPart8, ...registryPart9, ...registryPart10];
325100
- var version = "0.13.2";
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';
@@ -3357,6 +3357,11 @@ export interface IndicatorRegistryEntry {
3357
3357
  title: string;
3358
3358
  message?: string;
3359
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;
3360
3365
  /** `chart`: what the caller knows about the chart and its symbol (tick, time zone, ...), see ChartContext */
3361
3366
  calculate: (bars: Bar[], inputs?: any, chart?: ChartContext) => any;
3362
3367
  }
@@ -3365,5 +3370,5 @@ export type { ChartContext, VisibleRange, SymbolRequest, SymbolInfo } from './ch
3365
3370
  export { MissingSymbolDataError, symbolBarsOf } from './chart-context';
3366
3371
  export { mintickOf, timezoneOf, tickeridOf, tickerOf, symbolTypeOf, currencyOf, basecurrencyOf, rootOf, foregroundColorOf, backgroundColorOf, lastBarConfirmedOf, nowOf, visibleRangeOf, } from './chart-context';
3367
3372
  export { securityOther, securityOtherValues, securityLowerTf, otherSymbolChart, spreadSymbols, spreadBars, spreadOptions, type OtherSymbolOptions, type OtherSymbolChart, type SymbolCalendar, } from './other-symbol';
3368
- export declare const version = "0.13.2";
3373
+ export declare const version = "0.13.3";
3369
3374
  //# sourceMappingURL=index.d.ts.map