lightweight-charts-indicators 0.15.0 → 0.15.1

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
@@ -4674,7 +4674,20 @@ var plotConfig23 = [
4674
4674
  { id: "plot1", title: "RSI-based MA", color: "#E2CC00", lineWidth: 1 },
4675
4675
  { id: "plot2", title: "Upper Bollinger Band", color: "#089981", lineWidth: 1 },
4676
4676
  { id: "plot3", title: "Lower Bollinger Band", color: "#089981", lineWidth: 1 },
4677
- { id: "plot6", title: "Middle Line", color: "transparent", lineWidth: 0, display: "none" }
4677
+ { id: "plot6", title: "Plot", color: "transparent", lineWidth: 0, display: "none" },
4678
+ { id: "plot4", title: "Regular Bullish", color: "#4CAF50", lineWidth: 2, display: "pane" },
4679
+ { id: "plot5", title: "Regular Bearish", color: "#FF5252", lineWidth: 2, display: "pane" }
4680
+ ];
4681
+ var outputs = [
4682
+ { kind: "plot", id: "plot0" },
4683
+ { kind: "plot", id: "plot6" },
4684
+ { kind: "plot", id: "plot1" },
4685
+ { kind: "plot", id: "plot2" },
4686
+ { kind: "plot", id: "plot3" },
4687
+ { kind: "plot", id: "plot4" },
4688
+ { kind: "shape", id: "bullLabel", title: "Regular Bullish Label" },
4689
+ { kind: "plot", id: "plot5" },
4690
+ { kind: "shape", id: "bearLabel", title: "Regular Bearish Label" }
4678
4691
  ];
4679
4692
  var hlineConfig4 = [
4680
4693
  { id: "hline_upper", price: 70, color: "#787B86", linestyle: "solid", title: "RSI Upper Band" },
@@ -4750,6 +4763,9 @@ function calculate23(bars, inputs = {}) {
4750
4763
  }
4751
4764
  );
4752
4765
  const markers = [];
4766
+ const bullLine = bars.map((b) => ({ time: b.time, value: NaN }));
4767
+ const bearLine = bars.map((b) => ({ time: b.time, value: NaN }));
4768
+ const labels = { bullLabel: [], bearLabel: [] };
4753
4769
  if (calculateDivergence) {
4754
4770
  let valueWhen2 = function(cond, source2, occurrence) {
4755
4771
  const result = [];
@@ -4797,6 +4813,14 @@ function calculate23(bars, inputs = {}) {
4797
4813
  plCalls++;
4798
4814
  rsiHL = plCalls >= rangeLower && plCalls <= rangeUpper;
4799
4815
  }
4816
+ {
4817
+ const prevLow = plLowVW[i];
4818
+ const bull = plFound[i] && rsiHL && prevLow != null && lowLBR[i] < prevLow;
4819
+ if (plFound[i] && rsiVal != null)
4820
+ bullLine[i - lookbackRight] = { time: bars[i - lookbackRight].time, value: rsiVal, color: bull ? "#4CAF50" : "transparent" };
4821
+ if (bull && rsiVal != null)
4822
+ labels.bullLabel.push({ time: bars[i].time, value: rsiVal });
4823
+ }
4800
4824
  if (plFound[i] && rsiHL) {
4801
4825
  const prevLow = plLowVW[i];
4802
4826
  const priceLL = prevLow != null && lowLBR[i] < prevLow;
@@ -4821,6 +4845,14 @@ function calculate23(bars, inputs = {}) {
4821
4845
  phCalls++;
4822
4846
  rsiLH = phCalls >= rangeLower && phCalls <= rangeUpper;
4823
4847
  }
4848
+ {
4849
+ const prevHigh = phHighVW[i];
4850
+ const bear = phFound[i] && rsiLH && prevHigh != null && highLBR[i] > prevHigh;
4851
+ if (phFound[i] && rsiVal != null)
4852
+ bearLine[i - lookbackRight] = { time: bars[i - lookbackRight].time, value: rsiVal, color: bear ? "#FF5252" : "transparent" };
4853
+ if (bear && rsiVal != null)
4854
+ labels.bearLabel.push({ time: bars[i].time, value: rsiVal });
4855
+ }
4824
4856
  if (phFound[i] && rsiLH) {
4825
4857
  const prevHigh = phHighVW[i];
4826
4858
  const priceHH = prevHigh != null && highLBR[i] > prevHigh;
@@ -4845,13 +4877,16 @@ function calculate23(bars, inputs = {}) {
4845
4877
  "plot1": maData,
4846
4878
  "plot2": bbUpperData,
4847
4879
  "plot3": bbLowerData,
4848
- "plot6": midlineData
4880
+ "plot6": midlineData,
4881
+ "plot4": bullLine,
4882
+ "plot5": bearLine
4849
4883
  },
4850
4884
  fills,
4851
- markers: markers.length > 0 ? markers : void 0
4885
+ markers: markers.length > 0 ? markers : void 0,
4886
+ outputValues: labels
4852
4887
  };
4853
4888
  }
4854
- var RSI = { calculate: calculate23, metadata: metadata23, defaultInputs: defaultInputs23, inputConfig: inputConfig23, plotConfig: plotConfig23, hlineConfig: hlineConfig4, fillConfig: fillConfig2 };
4889
+ var RSI = { calculate: calculate23, metadata: metadata23, defaultInputs: defaultInputs23, inputConfig: inputConfig23, plotConfig: plotConfig23, hlineConfig: hlineConfig4, fillConfig: fillConfig2, outputs };
4855
4890
 
4856
4891
  // src/standard/stoch.ts
4857
4892
  var import_oakscriptjs25 = require("oakscriptjs");
@@ -9248,6 +9283,10 @@ var inputConfig81 = [
9248
9283
  { id: "n", type: "int", title: "Periods", defval: 2, min: 2 }
9249
9284
  ];
9250
9285
  var plotConfig81 = [];
9286
+ var outputs2 = [
9287
+ { kind: "shape", id: "downFractal", title: "Shapes" },
9288
+ { kind: "shape", id: "upFractal", title: "Shapes" }
9289
+ ];
9251
9290
  var metadata81 = {
9252
9291
  title: "Williams Fractals",
9253
9292
  shortTitle: "Fractals",
@@ -9395,13 +9434,15 @@ function calculate81(bars, inputs = {}) {
9395
9434
  });
9396
9435
  }
9397
9436
  }
9437
+ const condition = (values) => bars.map((b, t) => ({ time: b.time, value: t >= n && !isNaN(values[t - n]) ? 1 : 0 }));
9398
9438
  return {
9399
9439
  metadata: { title: metadata81.title, shorttitle: metadata81.shortTitle, overlay: metadata81.overlay },
9400
9440
  plots: {},
9401
- markers
9441
+ markers,
9442
+ outputValues: { downFractal: condition(downFractalValues), upFractal: condition(upFractalValues) }
9402
9443
  };
9403
9444
  }
9404
- var WilliamsFractals = { calculate: calculate81, metadata: metadata81, defaultInputs: defaultInputs81, inputConfig: inputConfig81, plotConfig: plotConfig81 };
9445
+ var WilliamsFractals = { calculate: calculate81, metadata: metadata81, defaultInputs: defaultInputs81, inputConfig: inputConfig81, plotConfig: plotConfig81, outputs: outputs2 };
9405
9446
 
9406
9447
  // src/standard/twap.ts
9407
9448
  var import_oakscriptjs77 = require("oakscriptjs");
@@ -9507,6 +9548,10 @@ var inputConfig84 = [
9507
9548
  { id: "waningMoonColor", type: "color", title: "Waning Moon", defval: "#FFFFFF" }
9508
9549
  ];
9509
9550
  var plotConfig84 = [];
9551
+ var outputs3 = [
9552
+ { kind: "shape", id: "newMoon", title: "New Moon" },
9553
+ { kind: "shape", id: "fullMoon", title: "Full Moon" }
9554
+ ];
9510
9555
  var metadata84 = {
9511
9556
  title: "Moon Phases",
9512
9557
  shortTitle: "Moon",
@@ -9599,6 +9644,8 @@ function hexToRgba(hex, alpha) {
9599
9644
  function calculate84(bars, inputs = {}, chart) {
9600
9645
  const { waxingMoonColor, waningMoonColor } = { ...defaultInputs84, ...inputs };
9601
9646
  const markers = [];
9647
+ const newMoon = [];
9648
+ const fullMoon = [];
9602
9649
  const bgColors = [];
9603
9650
  const closes = closeTimes(bars, chart);
9604
9651
  const timezone = closes && chart?.timezone !== void 0 ? chart.timezone : "Etc/UTC";
@@ -9641,6 +9688,8 @@ function calculate84(bars, inputs = {}, chart) {
9641
9688
  } else {
9642
9689
  moonType = NaN;
9643
9690
  }
9691
+ newMoon.push({ time: bar.time, value: moonType === 1 ? 1 : 0 });
9692
+ fullMoon.push({ time: bar.time, value: moonType === -1 ? 1 : 0 });
9644
9693
  if (moonType === 1) {
9645
9694
  markers.push({
9646
9695
  time: bar.time,
@@ -9665,10 +9714,11 @@ function calculate84(bars, inputs = {}, chart) {
9665
9714
  metadata: { title: metadata84.title, shorttitle: metadata84.shortTitle, overlay: metadata84.overlay },
9666
9715
  plots: {},
9667
9716
  markers,
9668
- bgColors
9717
+ bgColors,
9718
+ outputValues: { newMoon, fullMoon }
9669
9719
  };
9670
9720
  }
9671
- var MoonPhases = { calculate: calculate84, metadata: metadata84, defaultInputs: defaultInputs84, inputConfig: inputConfig84, plotConfig: plotConfig84 };
9721
+ var MoonPhases = { calculate: calculate84, metadata: metadata84, defaultInputs: defaultInputs84, inputConfig: inputConfig84, plotConfig: plotConfig84, outputs: outputs3 };
9672
9722
 
9673
9723
  // src/community/zlsma.ts
9674
9724
  var import_oakscriptjs79 = require("oakscriptjs");
@@ -49011,6 +49061,7 @@ function calculate410(bars, inputs = {}, chart) {
49011
49061
  const up = [];
49012
49062
  const down = [];
49013
49063
  const markers = [];
49064
+ const deltaValues = [];
49014
49065
  for (let i = 0; i < bars.length; i++) {
49015
49066
  let upVol;
49016
49067
  let downVol;
@@ -49027,6 +49078,7 @@ function calculate410(bars, inputs = {}, chart) {
49027
49078
  const delta = upVol - downVol;
49028
49079
  up.push({ time: bars[i].time, value: upVol });
49029
49080
  down.push({ time: bars[i].time, value: -downVol });
49081
+ deltaValues.push({ time: bars[i].time, value: delta });
49030
49082
  markers.push({
49031
49083
  time: bars[i].time,
49032
49084
  position: "atPriceMiddle",
@@ -49048,15 +49100,22 @@ function calculate410(bars, inputs = {}, chart) {
49048
49100
  "plot0": up,
49049
49101
  "plot1": down
49050
49102
  },
49051
- markers
49103
+ markers,
49104
+ outputValues: { delta: deltaValues }
49052
49105
  };
49053
49106
  }
49107
+ var outputs4 = [
49108
+ { kind: "plot", id: "plot0" },
49109
+ { kind: "plot", id: "plot1" },
49110
+ { kind: "char", id: "delta", title: "Chars" }
49111
+ ];
49054
49112
  var UpDownVolume = {
49055
49113
  calculate: calculate410,
49056
49114
  metadata: metadata410,
49057
49115
  defaultInputs: defaultInputs410,
49058
49116
  inputConfig: inputConfig410,
49059
- plotConfig: plotConfig410
49117
+ plotConfig: plotConfig410,
49118
+ outputs: outputs4
49060
49119
  };
49061
49120
 
49062
49121
  // src/standard/auto-key-levels.ts
@@ -51744,10 +51803,12 @@ function calculate429(bars, inputs = {}, chart) {
51744
51803
  return (0, import_oakscriptjs394.mapToChart)(htf.htf.map(hlc3), htf.group, htf.latest, true, false);
51745
51804
  };
51746
51805
  const markers = [];
51806
+ const outputValues = {};
51747
51807
  for (const p of PIVOTS) {
51748
51808
  if (!cfg[p.show])
51749
51809
  continue;
51750
51810
  const values = security2(p.tf);
51811
+ outputValues[`pivot${p.tf}`] = bars.flatMap((b, i) => Number.isFinite(values[i]) ? [{ time: b.time, value: values[i] }] : []);
51751
51812
  bars.forEach((b, i) => {
51752
51813
  const v = values[i];
51753
51814
  if (!Number.isFinite(v))
@@ -51761,10 +51822,16 @@ function calculate429(bars, inputs = {}, chart) {
51761
51822
  // plot(close, "Close Price", color = #00BCD4)
51762
51823
  plot0: bars.map((b) => ({ time: b.time, value: b.close }))
51763
51824
  },
51764
- markers
51825
+ markers,
51826
+ outputValues
51765
51827
  };
51766
51828
  }
51829
+ var outputs5 = [
51830
+ { kind: "plot", id: "plot0" },
51831
+ ...PIVOTS.map((p) => ({ kind: "char", id: `pivot${p.tf}`, title: "Chars" }))
51832
+ ];
51767
51833
  var RobBookerZivGhostPivots = {
51834
+ outputs: outputs5,
51768
51835
  calculate: calculate429,
51769
51836
  metadata: metadata429,
51770
51837
  defaultInputs: defaultInputs429,
@@ -51853,6 +51920,7 @@ function calculate430(bars, inputs = {}) {
51853
51920
  const bearPlot = na7();
51854
51921
  const hiddenBearPlot = na7();
51855
51922
  const markers = [];
51923
+ const labels = { bullLabel: [], hiddenBullLabel: [], bearLabel: [], hiddenBearLabel: [] };
51856
51924
  for (let i = 0; i < n; i++) {
51857
51925
  const oscHL = import_oakscriptjs395.compare.gt(oscR[i], prevOscPl[i]) && inRangePl[i];
51858
51926
  const priceLL = import_oakscriptjs395.compare.lt(lowR[i], prevLowPl[i]);
@@ -51866,6 +51934,18 @@ function calculate430(bars, inputs = {}) {
51866
51934
  const oscHH = import_oakscriptjs395.compare.gt(oscR[i], prevOscPh[i]) && inRangePh[i];
51867
51935
  const priceLH = import_oakscriptjs395.compare.lt(highR[i], prevHighPh[i]);
51868
51936
  const hiddenBearCond = cfg.plotHiddenBear && priceLH && oscHH && phFound[i];
51937
+ const at2 = bars[i].time;
51938
+ const lv = oscR[i];
51939
+ if (Number.isFinite(lv)) {
51940
+ if (bullCond)
51941
+ labels.bullLabel.push({ time: at2, value: lv });
51942
+ if (hiddenBullCond)
51943
+ labels.hiddenBullLabel.push({ time: at2, value: lv });
51944
+ if (bearCond)
51945
+ labels.bearLabel.push({ time: at2, value: lv });
51946
+ if (hiddenBearCond)
51947
+ labels.hiddenBearLabel.push({ time: at2, value: lv });
51948
+ }
51869
51949
  const j = i - lbR;
51870
51950
  if (j < 0 || j >= n)
51871
51951
  continue;
@@ -51901,10 +51981,22 @@ function calculate430(bars, inputs = {}) {
51901
51981
  plot3: bearPlot,
51902
51982
  plot4: hiddenBearPlot
51903
51983
  },
51904
- markers
51984
+ markers,
51985
+ outputValues: labels
51905
51986
  };
51906
51987
  }
51907
- var RsiDivergenceIndicator = { calculate: calculate430, metadata: metadata430, defaultInputs: defaultInputs430, inputConfig: inputConfig430, plotConfig: plotConfig430, hlineConfig: hlineConfig51, fillConfig: fillConfig16 };
51988
+ var outputs6 = [
51989
+ { kind: "plot", id: "plot0" },
51990
+ { kind: "plot", id: "plot1" },
51991
+ { kind: "shape", id: "bullLabel", title: "Regular Bullish Label" },
51992
+ { kind: "plot", id: "plot2" },
51993
+ { kind: "shape", id: "hiddenBullLabel", title: "Hidden Bullish Label" },
51994
+ { kind: "plot", id: "plot3" },
51995
+ { kind: "shape", id: "bearLabel", title: "Regular Bearish Label" },
51996
+ { kind: "plot", id: "plot4" },
51997
+ { kind: "shape", id: "hiddenBearLabel", title: "Hidden Bearish Label" }
51998
+ ];
51999
+ var RsiDivergenceIndicator = { calculate: calculate430, metadata: metadata430, defaultInputs: defaultInputs430, inputConfig: inputConfig430, plotConfig: plotConfig430, hlineConfig: hlineConfig51, fillConfig: fillConfig16, outputs: outputs6 };
51908
52000
 
51909
52001
  // src/standard/seasonality.ts
51910
52002
  var import_oakscriptjs396 = require("oakscriptjs");
@@ -303485,7 +303577,8 @@ var registryPart1 = [
303485
303577
  hlineConfig: hlineConfig4,
303486
303578
  fillConfig: fillConfig2,
303487
303579
  defaultInputs: { ...defaultInputs23 },
303488
- calculate: calculate23
303580
+ calculate: calculate23,
303581
+ outputs
303489
303582
  },
303490
303583
  {
303491
303584
  id: "stoch",
@@ -304379,7 +304472,8 @@ var registryPart1 = [
304379
304472
  inputConfig: inputConfig81,
304380
304473
  plotConfig: plotConfig81,
304381
304474
  defaultInputs: { ...defaultInputs81 },
304382
- calculate: calculate81
304475
+ calculate: calculate81,
304476
+ outputs: outputs2
304383
304477
  },
304384
304478
  {
304385
304479
  id: "twap",
@@ -304422,7 +304516,8 @@ var registryPart1 = [
304422
304516
  inputConfig: inputConfig84,
304423
304517
  plotConfig: plotConfig84,
304424
304518
  defaultInputs: { ...defaultInputs84 },
304425
- calculate: calculate84
304519
+ calculate: calculate84,
304520
+ outputs: outputs3
304426
304521
  },
304427
304522
  // --- Wave 1 Community Indicators ---
304428
304523
  {
@@ -319627,7 +319722,8 @@ var registryPart5 = [
319627
319722
  inputConfig: inputConfig410,
319628
319723
  plotConfig: plotConfig410,
319629
319724
  defaultInputs: { ...defaultInputs410 },
319630
- calculate: calculate410
319725
+ calculate: calculate410,
319726
+ outputs: outputs4
319631
319727
  },
319632
319728
  {
319633
319729
  id: "auto-key-levels",
@@ -325193,7 +325289,8 @@ var registryPart11 = [
325193
325289
  plotConfig: plotConfig429,
325194
325290
  requiredSymbols: requiredSymbols5,
325195
325291
  defaultInputs: { ...defaultInputs429 },
325196
- calculate: calculate429
325292
+ calculate: calculate429,
325293
+ outputs: outputs5
325197
325294
  },
325198
325295
  {
325199
325296
  id: "rsi-divergence-indicator",
@@ -325209,7 +325306,8 @@ var registryPart11 = [
325209
325306
  hlineConfig: hlineConfig51,
325210
325307
  fillConfig: fillConfig16,
325211
325308
  defaultInputs: { ...defaultInputs430 },
325212
- calculate: calculate430
325309
+ calculate: calculate430,
325310
+ outputs: outputs6
325213
325311
  },
325214
325312
  {
325215
325313
  id: "seasonality",
@@ -325289,4 +325387,4 @@ var registryPart11 = [
325289
325387
  }
325290
325388
  ];
325291
325389
  var indicatorRegistry = [...registryPart1, ...registryPart11, ...registryPart2, ...registryPart3, ...registryPart4, ...registryPart5, ...registryPart6, ...registryPart7, ...registryPart8, ...registryPart9, ...registryPart10].map(withReferenceNames);
325292
- var version = "0.15.0";
325390
+ var version = "0.15.1";
package/dist/index.d.ts CHANGED
@@ -776,7 +776,7 @@ export declare const UpsideTasukiGap: import("./candlestick-port/adapter").PortI
776
776
  export declare const FallingThreeMethods: import("./candlestick-port/adapter").PortIndicator;
777
777
  export declare const RisingThreeMethods: import("./candlestick-port/adapter").PortIndicator;
778
778
  export declare const AllPatterns: import("./candlestick-port/adapter").PortIndicator;
779
- 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
+ export type { MarkerData, MarkerPosition, MarkerShape, PineSize, BarColorData, BgColorData, PlotCandleData, PlotBarData, LabelData, LabelStyle, LineDrawingData, BoxData, LinefillData, PolylineData, TableData, TableCell, TableCellData, TableMergeData, TablePosition, AlertCall, OutputDecl, OutputValues, } from './types';
780
780
  export { barInterval, barTime } from './bar-time';
781
781
  export { AroonOscillator, calculate as calculateAroonOscillator } from './standard/aroon-oscillator';
782
782
  export type { AroonOscillatorInputs } from './standard/aroon-oscillator';
@@ -3337,6 +3337,12 @@ export interface IndicatorRegistryEntry {
3337
3337
  }[];
3338
3338
  /** plotarrow settings by arrow id (minheight / maxheight / forceOverlay) of the `arrows` of the result */
3339
3339
  arrowConfig?: ArrowConfig[];
3340
+ /**
3341
+ * Its outputs in the order PineScript numbers them for alert messages ({{plot_<n>}}): line plots, shapes,
3342
+ * characters and arrows as the reference script declares them; the values of the shapes / characters / arrows are in
3343
+ * the result's `outputValues`. Unset: its line plots in plotConfig order.
3344
+ */
3345
+ outputs?: import('./types').OutputDecl[];
3340
3346
  defaultInputs: Record<string, unknown>;
3341
3347
  /**
3342
3348
  * True when the output depends on the bars visible on the chart (`leftVisibleBarTime` / `rightVisibleBarTime` of
@@ -3371,5 +3377,5 @@ export type { ChartContext, VisibleRange, SymbolRequest, SymbolInfo } from './ch
3371
3377
  export { MissingSymbolDataError, symbolBarsOf } from './chart-context';
3372
3378
  export { mintickOf, timezoneOf, tickeridOf, tickerOf, symbolTypeOf, currencyOf, basecurrencyOf, rootOf, foregroundColorOf, backgroundColorOf, lastBarConfirmedOf, nowOf, visibleRangeOf, } from './chart-context';
3373
3379
  export { securityOther, securityOtherValues, securityLowerTf, otherSymbolChart, spreadSymbols, spreadBars, spreadOptions, type OtherSymbolOptions, type OtherSymbolChart, type SymbolCalendar, } from './other-symbol';
3374
- export declare const version = "0.15.0";
3380
+ export declare const version = "0.15.1";
3375
3381
  //# sourceMappingURL=index.d.ts.map