OPEN-SOURCE SCRIPT

Confluence Engine

126
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.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.