OPEN-SOURCE SCRIPT

Dempster-Shafer Evidence Fusion [forexobroker]

383
Dempster-Shafer Evidence Fusion [forexobroker] combines six independent child evidences (EMA slope, RSI deviation, ATR-normalized return, signed volume z-score, range-expansion conviction, close-in-range positioning) into a single mass distribution over the hypothesis frame {Long, Short, Hold} using Dempster's rule of combination. Unlike a weighted-average composite where conflicting child signals dilute the score, Dempster-Shafer explicitly tracks epistemic uncertainty as a separate Hold mass and resolves conflict via a conflict denominator, so the combined output is properly normalized and the Hold mass quantifies disagreement among children. The unique angle is principled belief fusion rather than ad hoc voting or averaging.

🔶 ALGORITHM

1. Six child evidences are computed each bar. Each child produces a signed strength in (-1, 1).
2. Strength is mapped to a mass triplet: m(Long) = max(s,0) * |s|, m(Short) = -min(s,0) * |s|, m(Hold) = 1 - |s|. Sums equal one.
3. Children: (1) ATR-normalized EMA slope, tanh-squashed; (2) (RSI - 50)/50; (3) tanh of (close - close[1])/atr; (4) signed volume z-score, tanh-squashed; (5) range-expansion ratio signed by return direction, tanh-squashed; (6) (close - lowest(low,N))/(highest(high,N) - lowest(low,N)) re-centered to (-1, 1).
4. Pair-wise Dempster fusion: for two evidences (m1, m2), conflict K = m1(L)m2(S) + m1(S)m2(L); m12(L) = (m1(L)m2(L) + m1(L)m2(H) + m1(H)m2(L)) / (1-K). Symmetric for Short. Hold collects m1(H)m2(H)/(1-K). After fusion the triplet is renormalized for floating-point safety.
5. All six evidences are cascaded pair-by-pair to a final triplet (m_L, m_S, m_H).
6. Conviction equals max(m_L, m_S, m_H). The threshold (default 0.55) defines when one hypothesis dominates.
7. A signal fires when the dominant mass exceeds the threshold and standard gates pass.

🔶 SIGNAL LOGIC

- Buy: combined m(Long) above the signal threshold AND session filter passes AND position is not already long AND cooldown bars elapsed AND barstate.isconfirmed.
- Sell: combined m(Short) above the signal threshold AND session filter passes AND position is not already short AND cooldown bars elapsed AND barstate.isconfirmed.

Because m(L) + m(S) + m(H) = 1 by construction, both buy and sell cannot trigger on the same bar; ties resolve as Hold.

🔶 INPUTS

- Calculation group: EMA Length (default 21), EMA Lookback (default 5), RSI Length (default 14), ATR Length (default 14), Volume StDev Len (default 20), Range Avg Length (default 20), Position-In-Range Len (default 20).
- Signal Logic group: Combined Mass Threshold (default 0.55), cooldown bars (default 15).
- Filters group: optional session restriction (default 0000-2400).
- Visual group: dashboard toggle, 3-layer glow toggle, long/short/hold colors and dashboard background.

🔶 ALERTS

DSE Buy, DSE Sell, DSE Any Signal, DSE Long Cross, DSE Short Cross, DSE Uncertain, DSE High Conviction, DSE Net Long, DSE Net Short, DSE Webhook JSON.

🔶 LIMITATIONS

- Dempster's rule is sensitive to high-conflict situations; when child signals disagree strongly the denominator (1-K) becomes small and a near-zero numerator can amplify noise. The script floors the denominator at 1e-10.
- Six children all derived from the same OHLCV stream are not strictly independent evidences; the assumption underlying classical Dempster-Shafer is somewhat relaxed here.
- The tanh squashing of slope, return, and volume scales is opinionated; instruments with very different volatility profiles may need different child mapping ranges.
- A high conviction Hold mass means children disagree; this is information, not a problem to fix, but it does mean stretches of low signal density are expected.
- Volume is used as an evidence input; on symbols without exchange volume that child collapses to near-zero strength and the remaining five carry the consensus.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.