OPEN-SOURCE SCRIPT
Cập nhật

Confluence Engine

547
Confluence Engine is a practical, non-repainting decision aid that scores market conditions from −100…+100 by combining six proven modules: Trend, Momentum, Volatility, Volume, Structure, and an HTF confirmation. It’s designed for crypto, forex, indices, and stocks, and it fires entries only on confirmed bar closes.

What’s inside

Trend: EMA 20/50/200 alignment plus a Supertrend/KAMA toggle (you choose the baseline).

Momentum: RSI + MACD with confirmed-pivot divergence detection.

Volatility: ATR% and Bollinger Band width vs its average to favor expansion over chop.

Volume: OBV-style cumulative flow slope + volume surge vs SMA×multiplier.

Market Structure: Confirmed pivots, BOS (break of structure) and CHOCH (change of character).

HTF Filter: Closed higher-timeframe context via request.security(..., barmerge.gaps_on, barmerge.lookahead_off).

Why it does not repaint

Signals are computed and plotted on closed bars only.

Pivots/divergences use confirmed pivot points (no forward look).

HTF series are fetched with lookahead_off and use the last closed HTF bar in realtime.

No future bar references are used for entries or alerts.

How to use (3 steps)

Pick a timeframe pair: use a 4–6× HTF multiplier (5m→30m, 15m→1h, 1h→4h, 4h→1D, 1D→1W).

Trade with the HTF: take longs only when the HTF filter is bullish; shorts only when bearish.

Prefer expansion: act when BB width > its average and ATR% is elevated; skip most signals in compression.

Suggested presets (start here)

Crypto (BTC/ETH): 15m→1h, 1h→4h. stLen=10, stMult=3.0, bbLen=20, surgeMul=1.8–2.2, thresholds +40 / −40 (intraday can try +35 / −35).

Forex majors: 15m→1h, 1h→4h. stLen=10–14, stMult=2.5–3.0, surgeMul=1.5–1.8, thresholds +35 / −35 (swing: +45 / −45).

US equities (liquid): 5m→30m/1h, 15m→1h/2h. stMult=3.0–3.5, surgeMul=1.6–2.0, thresholds +45 / −45 to reduce chop.

Indices (ES/NQ): 5m→30m, 15m→1h. Defaults are fine; start at +40 / −40.

Gold/Oil: 15m→1h, 1h→4h. Thresholds +35 / −35, surgeMul=1.6–1.9.

Inputs (plain English)

Use Supertrend (off = KAMA): choose the trend baseline.

EMA Fast/Mid/Slow: 20/50/200 by default for classic stack.

RSI/MACD + divergence pivots: momentum and exhaustion context.

ATR Length & BB Length: volatility regime detection.

Volume SMA & Surge Multiplier: defines “meaningful” volume spikes.

Pivot left/right & “Confirm BOS/CHOCH on Close”: structure strictness.

Enable HTF & Higher Timeframe: confirms the lower timeframe direction.

Thresholds (+long / −short): when the score crosses these, you get signals.

Signals & alerts (IDs preserved)

Entry shapes plot at bar close when the score crosses thresholds.

Alerts you can enable:

CONFLUENCE LONG — long entry signal

CONFLUENCE SHORT — short entry signal

BULLISH BIAS — score turned positive

BEARISH BIAS — score turned negative

Best practices

Focus on signals with HTF agreement and volatility expansion; require volume participation (surge or rising OBV slope) for higher quality.

Raise thresholds (+45/−45 or +50/−50) to reduce whipsaws in choppy sessions.

Lower thresholds (+35/−35) only if you also require volatility/volume filters.

Performance & scope

Works across crypto/FX/equities/indices; no broker data or special feeds required.

No repainting by design; signals/alerts are computed on closed bars.

As with any tool, results vary by regime; always combine with risk management.

Disclosure
This script is for educational purposes only and is not financial advice. Trading involves risk. Test on historical data and paper trade before using live.
Phát hành các Ghi chú
# Updated Confluence Engine

**Why we updated it**
To make the confluence score **reliable on crypto 24/7**, eliminate edge-case repaint perceptions, simplify visuals for mobile, and ship **publish-ready alerts**. The first version occasionally showed **NaN on crypto Daily**, had intrabar signal flips, and alerts weren’t webhook-friendly.

**What’s new (vs the original Confluence Engine)**

* **Crypto-ready Confluence Score**: Adds a **Crypto Regime** (BTC Dominance, USDT Dominance, ETHBTC, BTC momentum) and forward-fills external data so weekends don’t break the score.
* **Dual Regime Layer**: Auto/Manual switch between **Macro Regime** (−DXY, −VIX, +BTC) and **Crypto Regime**; both are blended into the score and fully **NaN-safe**.
* **Zero-Repaint Signals**: Entries/bias are **confirmed-bar only**. Higher-TF inputs use `lookahead_off` with a realtime shift. Structure pivots are confirmed before use.
* **Cleaner Momentum Divergence**: Uses **stored pivots** (not same-bar) for sturdier divergence detection.
* **Heatmap 2.0**: Choice of **Gradient** or **Zones**, with optional smoothing—no more striping; consistent look across markets/timeframes.
* **HUD Refinement**: Compact module readout (Trend/Mom/Vol/Volm/Struct/HTF/Regime + ATR%) and last-bar rendering for speed.
* **Preset Layer**: Crypto/Forex/Stocks/Commodities presets adjust lengths & weights without touching logic.
* **Alerts That Publish**: Constant JSON templates with **locked `{{plot_*}}` indices** for bots/webhooks.
* **Performance Polish**: Tuple functions (`ta.bb/ta.macd`), fewer redraws, and NaN-safe math keep charts responsive.

**What this means for traders**

* A **stable, interpretable score** on crypto and traditional markets.
* **Safer entries** (no intrabar flip surprises) and **clearer visuals** on any device.
* **Automation-ready** alerts out of the box.

**How to use**

* Watch **±40** as action rails (trend continuation/reversal).
* For crypto, set **Preset = Crypto** or enable **Use Crypto Regime**.
* Use **Zones** heatmap on Daily; **Gradient** with light smoothing on intraday.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.