A raw BUY or SELL signal tells you direction. A confidence score tells you how much to trust it. Building a meaningful confidence metric — one that reflects genuine indicator confluence, not arbitrary randomness — required careful engineering.

The 8 signal dimensions

Each dimension scores +1 (bullish), -1 (bearish), or 0 (neutral):

const scores = {
  ema_cross:  ema20 > ema50 ? 1 : -1,
  ema_long:   current > ema200 ? 1 : -1,
  rsi:        rsi < 40 ? 1 : rsi > 60 ? -1 : rsi > 50 ? 1 : -1,
  macd_lvl:   macdBull ? 1 : -1,
  macd_cross: macdHistRising ? 1 : -1,
  boll:       current < bbLower ? 1 : current > bbUpper ? -1 : current < bbMean ? 1 : -1,
  stoch:      stochRSI < 30 ? 1 : stochRSI > 70 ? -1 : stochRSI < 50 ? 1 : -1,
  pattern:    pb,  // +1 bullish pattern, -1 bearish, 0 neutral
  pzone:      current < support + range * 0.4 ? 1 : current > support + range * 0.6 ? -1 : 0,
};
const total = Object.values(scores).reduce((a, b) => a + b, 0);

Maximum possible total: +9 (all 9 dimensions agree bullish). Minimum: -9 (all bearish).

Signal direction threshold

  • Total ≥ +2: BUY signal
  • Total ≤ -2: SELL signal
  • Total between -1 and +1: NO TRADE

Confidence mapping

The confidence is mapped from the absolute score total:

if (total >= 2)       { signal = "BUY";      conf = 58 + (total / 10) * 35; }
else if (total <= -2) { signal = "SELL";     conf = 58 + (Math.abs(total) / 10) * 35; }
else                  { signal = "NO TRADE"; conf = 40; }
conf = Math.min(97, Math.max(55, conf));

At total = 2: conf = 58 + (2/10) × 35 = 65% At total = 6: conf = 58 + (6/10) × 35 = 79% At total = 9: conf = 58 + (9/10) × 35 = 89.5% → clamped at 97%

MTF confluence adjustment

After the base confidence is calculated, the MTF macro trend applies a final adjustment:

  • Macro trend aligns with signal: conf = Math.min(98, conf + 5)
  • Macro trend opposes signal: signal overridden to NO TRADE, conf = 45

The 98% cap is intentional. No algorithmic system should claim 100% certainty — that would be misleading. The 55% floor ensures NO TRADE zones always feel clearly weaker than directional signals.

---

Mustafa Kamal Hossain

Mustafa Kamal Hossain

Founder & Principal Engineer at Manfi. Passionate about Laravel, SaaS architecture, and high-performance engineering.