lightweight-charts-indicators 0.4.1 → 0.4.2

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.
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * Chandelier Exit
3
3
  *
4
- * ATR-based trailing stop system.
5
- * Long stop: highest high - ATR*mult (ratchets up only)
6
- * Short stop: lowest low + ATR*mult (ratchets down only)
7
- * Direction flips when price crosses the opposite stop.
4
+ * Long stop: highest(length) - ATR*mult
5
+ * Short stop: lowest(length) + ATR*mult
8
6
  *
9
- * Reference: TradingView "Chandelier Exit" by everget
7
+ * Both lines are plotted continuously, matching TradingView's built-in
8
+ * `ta.chandelier()` (TradingView/ta library). Direction state is still
9
+ * tracked to drive buy/sell markers and the fill colors, but the plotted
10
+ * series are never gated to NaN.
10
11
  */
11
12
  import { type IndicatorResult, type InputConfig, type PlotConfig, type Bar } from 'oakscriptjs';
12
13
  import type { MarkerData } from '../types';
@@ -1 +1 @@
1
- {"version":3,"file":"chandelier-exit.d.ts","sourceRoot":"","sources":["../../src/community/chandelier-exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,EAAE,oBAI3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,WAAW,EAIpC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAAU,EAIlC,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,eAAe,GAAG;IAAE,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CAyG9H;AAED,eAAO,MAAM,cAAc;;;;;;;;;;CAAkE,CAAC"}
1
+ {"version":3,"file":"chandelier-exit.d.ts","sourceRoot":"","sources":["../../src/community/chandelier-exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,EAAE,oBAI3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,WAAW,EAIpC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAAU,EAIlC,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,eAAe,GAAG;IAAE,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CA8F9H;AAED,eAAO,MAAM,cAAc;;;;;;;;;;CAAkE,CAAC"}
package/dist/index.cjs CHANGED
@@ -7678,18 +7678,11 @@ function calculate95(bars, inputs = {}) {
7678
7678
  const dirArr = [];
7679
7679
  for (let i = 0; i < bars.length; i++) {
7680
7680
  const atrVal = (atrArr[i] ?? 0) * atrMult;
7681
- let longStop = (highestArr[i] ?? bars[i].high) - atrVal;
7682
- let shortStop = (lowestArr[i] ?? bars[i].low) + atrVal;
7681
+ const longStop = (highestArr[i] ?? bars[i].high) - atrVal;
7682
+ const shortStop = (lowestArr[i] ?? bars[i].low) + atrVal;
7683
7683
  if (i > 0) {
7684
7684
  const prevLongStop = longStopArr[i - 1];
7685
7685
  const prevShortStop = shortStopArr[i - 1];
7686
- const prevClose = bars[i - 1].close;
7687
- if (prevClose > prevLongStop) {
7688
- longStop = Math.max(longStop, prevLongStop);
7689
- }
7690
- if (prevClose < prevShortStop) {
7691
- shortStop = Math.min(shortStop, prevShortStop);
7692
- }
7693
7686
  const prevDir = dirArr[i - 1];
7694
7687
  const close = bars[i].close;
7695
7688
  if (close > prevShortStop) {
@@ -7708,11 +7701,11 @@ function calculate95(bars, inputs = {}) {
7708
7701
  const warmup = atrPeriod;
7709
7702
  const longData = longStopArr.map((value, i) => ({
7710
7703
  time: bars[i].time,
7711
- value: i < warmup ? NaN : dirArr[i] === 1 ? value : NaN
7704
+ value: i < warmup ? NaN : value
7712
7705
  }));
7713
7706
  const shortData = shortStopArr.map((value, i) => ({
7714
7707
  time: bars[i].time,
7715
- value: i < warmup ? NaN : dirArr[i] === -1 ? value : NaN
7708
+ value: i < warmup ? NaN : value
7716
7709
  }));
7717
7710
  const midData = bars.map((b, i) => ({
7718
7711
  time: b.time,
package/dist/index.mjs CHANGED
@@ -6962,18 +6962,11 @@ function calculate95(bars, inputs = {}) {
6962
6962
  const dirArr = [];
6963
6963
  for (let i = 0; i < bars.length; i++) {
6964
6964
  const atrVal = (atrArr[i] ?? 0) * atrMult;
6965
- let longStop = (highestArr[i] ?? bars[i].high) - atrVal;
6966
- let shortStop = (lowestArr[i] ?? bars[i].low) + atrVal;
6965
+ const longStop = (highestArr[i] ?? bars[i].high) - atrVal;
6966
+ const shortStop = (lowestArr[i] ?? bars[i].low) + atrVal;
6967
6967
  if (i > 0) {
6968
6968
  const prevLongStop = longStopArr[i - 1];
6969
6969
  const prevShortStop = shortStopArr[i - 1];
6970
- const prevClose = bars[i - 1].close;
6971
- if (prevClose > prevLongStop) {
6972
- longStop = Math.max(longStop, prevLongStop);
6973
- }
6974
- if (prevClose < prevShortStop) {
6975
- shortStop = Math.min(shortStop, prevShortStop);
6976
- }
6977
6970
  const prevDir = dirArr[i - 1];
6978
6971
  const close = bars[i].close;
6979
6972
  if (close > prevShortStop) {
@@ -6992,11 +6985,11 @@ function calculate95(bars, inputs = {}) {
6992
6985
  const warmup = atrPeriod;
6993
6986
  const longData = longStopArr.map((value, i) => ({
6994
6987
  time: bars[i].time,
6995
- value: i < warmup ? NaN : dirArr[i] === 1 ? value : NaN
6988
+ value: i < warmup ? NaN : value
6996
6989
  }));
6997
6990
  const shortData = shortStopArr.map((value, i) => ({
6998
6991
  time: bars[i].time,
6999
- value: i < warmup ? NaN : dirArr[i] === -1 ? value : NaN
6992
+ value: i < warmup ? NaN : value
7000
6993
  }));
7001
6994
  const midData = bars.map((b, i) => ({
7002
6995
  time: b.time,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightweight-charts-indicators",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "446 technical analysis indicators for TradingView's lightweight-charts library",
6
6
  "main": "dist/index.cjs",