Need help for custom indicator

Hellow ,Rencently i use chatgpt make a indicator but it not work

the logic is watching the delta value if the delta is over 20 but the candle stick is bearish or

the delta is min -20 but the candle stick is bull it will give me the alter

here is the code :

const predef = require("./tools/predef");
const meta = require("./tools/meta");




  const DEFAULTS = {
  deltaThreshold: 20,
  colorBullish: "#00e676",  // bullish signal 绿色
  colorBearish: "#ff5252",  // bearish signal 红色
  colorNeutral: "#999999"   // 默认颜色
};


class deltaReverseSignal {
  constructor(opts = {}) {
    this.opts = Object.assign({}, DEFAULTS, opts);
  }


  map(d) {
    // 提取基本数据(Tradovate 数据结构中,d.open, d.close 通常可用)
    const open = typeof d.open === "function" ? d.open() : d.open;
    const close = typeof d.close === "function" ? d.close() : d.close;
    const offerVol = typeof d.offerVolume === "function" ? d.offerVolume() : d.offerVolume;
    const bidVol = typeof d.bidVolume === "function" ? d.bidVolume() : d.bidVolume;


    const delta = offerVol - bidVol;
    let color = this.opts.colorNeutral;
    let signal = null;


    const isBullBar = close > open;
    const isBearBar = close < open;


    // --- 检测反向信号 ---
    if (delta > this.opts.deltaThreshold && isBearBar) {
      color = this.opts.colorBearish;
      signal = "Bearish";  // delta 强买但价格下跌 → 看空
    } else if (delta < -this.opts.deltaThreshold && isBullBar) {
      color = this.opts.colorBullish;
      signal = "Bullish";  // delta 强卖但价格上涨 → 看多
    }


    return {
      value: delta,
      color: color,
      signal: signal
    };
  }
}


module.exports = deltaReverseSignal;

Search Delta indicators and look for NCK Delta Spike Reversal. You can set a min delta for triggers. Also check out the CVD version

ty got one called delta divergence