OPEN-SOURCE SCRIPT

Viprasol Sniper Confluence Entry/Exit

26 264
## Overview

The Sniper Confluence Entry/Exit indicator builds on Sniper Entry/Exit with SL&TP by , which provided EMA crossover signals with ATR-based stop-loss/take-profit levels, a VWAP overlay, RSI/MACD display, and retest candle highlighting. This version adds a 7-factor confluence scoring engine that gates every signal — crossovers only fire when multiple technical factors align, dramatically reducing false entries. Built for swing and intraday traders who want clean, high-probability setups with automatic risk management.

## How It Works

**Signal Generation (from original):**
Entries are triggered by a Fast EMA / Slow EMA crossover. When the fast EMA crosses above the slow EMA, a long signal is generated; when it crosses below, a short signal is generated. The original script displayed these crossovers alongside supporting indicators (VWAP, RSI, MACD) but did not require them to agree before firing a signal.

**7-Factor Confluence Engine (new):**
This version adds a scoring layer that sits between the crossover and the signal output. Each bar, the indicator evaluates 7 independent factors and assigns 1 point for each that confirms the trade direction. A signal only fires when the total score meets your minimum threshold (default: 4/7).

Scoring logic (pseudocode):
```
confluenceScore = 0

// Factor 1: Price vs VWAP
if (long and close > vwap) or (short and close < vwap) → score += 1

// Factor 2: RSI direction
if (long and rsi > 50) or (short and rsi < 50) → score += 1

// Factor 3: MACD trend
if (long and macdLine > signalLine) or (short and macdLine < signalLine) → score += 1

// Factor 4: EMA alignment
if (long and fastEMA > slowEMA) or (short and fastEMA < slowEMA) → score += 1

// Factor 5: ADX + directional index
if adx > 25 and ((long and diPlus > diMinus) or (short and diMinus > diPlus)) → score += 1

// Factor 6: Volume confirmation
if volume > volumeSMA and ((long and close > open) or (short and close < open)) → score += 1

// Factor 7: Secondary timeframe RSI
if (long and secondaryRSI > 50) or (short and secondaryRSI < 50) → score += 1

signal fires only if confluenceScore >= minimumScore
```

A score of 5/7 or higher typically indicates a strong, well-supported setup. The configurable minimum lets you tune signal frequency vs. quality.

**Bar-Close Confirmation (new):**
When enabled, signals are delayed until the bar closes, preventing premature entries from intra-bar wicks that reverse before close.

**ATR-Based Stop-Loss & Take-Profit (from original, extended):**
The original calculated a single stop-loss and take-profit from ATR. This version extends that to:
- **Stop-Loss** — ATR multiplied by your chosen risk factor (same core logic as original)
- **Take-Profit Levels (1-5)** — Configurable number of TP levels at 1R, 2R, 3R, 4R, 5R distances (new — original had fixed levels)
- **Trailing Stop to Breakeven** — Optionally moves SL to entry price once TP1 is hit (new)

**Retest Candle Highlighting (from original):**
Bars that pull back to the fast EMA after a signal are highlighted in orange, marking potential add-on or re-entry opportunities.

**Secondary Timeframe RSI (from original, extended):**
The original included a secondary timeframe RSI hardcoded to the 5-minute chart. This version makes the timeframe user-configurable.

## Key Features

**From the Original:**
- EMA crossover signal generation (fast/slow EMA)
- ATR-based stop-loss and take-profit calculation
- VWAP overlay with directional coloring
- RSI and MACD display
- Retest candle highlighting at EMA pullbacks
- Secondary timeframe RSI confirmation

**Added in This Version:**
- 7-factor confluence scoring engine with configurable minimum score threshold
- Bar-close confirmation filter to prevent wick-driven false entries
- Trailing stop-loss to breakeven after TP1 is hit
- Configurable number of take-profit levels (1-5, was fixed)
- Configurable secondary timeframe (was hardcoded to 5m)
- SL label showing breakeven status when trailing is active
- 5 alert conditions with dynamic messages
- Full dashboard showing all 7 confluence factors, position status, and targets hit

## How to Use

**Setup:**
1. Add to any chart (works on all markets and timeframes)
2. Set your preferred EMA periods (default: 9/21)
3. Adjust the minimum confluence score — higher = fewer signals, better quality
4. Set your ATR multiplier for stop-loss width

**Reading Signals:**
- **LONG label** appears below bar when bullish crossover fires with sufficient confluence
- **SHORT label** appears above bar when bearish crossover fires with sufficient confluence
- Blue line = Entry, Red line = Stop-Loss, Green dashed lines = Take-Profit levels
- Lines turn turquoise when their target is hit
- Orange candles indicate price retesting the fast EMA (potential add-on opportunity)

**Dashboard:**
The side panel shows real-time scores for all 7 factors plus current position info, targets hit, and SL status.

**Recommended Starting Settings:**
- Scalping (1m-5m): Fast EMA 5, Slow EMA 13, Min Score 5, ATR Mult 1.0
- Intraday (15m-1H): Fast EMA 9, Slow EMA 21, Min Score 4, ATR Mult 1.5
- Swing (4H-1D): Fast EMA 9, Slow EMA 21, Min Score 4, ATR Mult 2.0

## Settings

**Signal Settings:** Fast/Slow EMA periods and bar-close confirmation toggle.
**Confluence Filter:** Enable/disable the score filter and set the minimum threshold.
**Risk Management:** ATR period, SL multiplier, number of TP levels, and breakeven trailing toggle.
**Secondary Timeframe:** Choose which timeframe provides the secondary RSI confirmation.
**Dashboard:** Position, font size, and show/hide toggle.
**Visuals:** Toggle EMA ribbon, VWAP, TP/SL lines, retest highlighting, label sizes and offsets.

## Alerts

1. **Long Entry Signal** — Fires when a bullish confluence entry triggers
2. **Short Entry Signal** — Fires when a bearish confluence entry triggers
3. **Any Entry Signal** — Fires on either long or short entry
4. **Strong Bull Bias** — Fires when bull confluence score crosses above 70%
5. **Strong Bear Bias** — Fires when bear confluence score crosses above 70%

All alerts include {{ticker}}, {{close}}, and {{interval}} for dynamic notification messages.

## Limitations & Disclaimer

- EMA crossover signals are inherently lagging — they work best in trending markets and may produce whipsaws during consolidation
- The confluence score uses current-bar values; in fast markets, conditions can change quickly
- The secondary timeframe RSI uses `request.security()` which may repaint on the current bar of that timeframe
- TP/SL levels are visual guides — they do not execute trades automatically
- Past performance of any signal system does not guarantee future results
- This indicator is for educational and analytical purposes only — it is not financial advice. Always use proper risk management and do your own analysis before trading.

## Credits & Attribution

This indicator is derived from **"Sniper Entry/Exit with SL&TP (open-source, TradingView). The following components originate from that script:

- EMA crossover signal generation logic
- ATR-based stop-loss and take-profit calculation
- VWAP overlay
- RSI and MACD display
- Retest candle highlighting concept
- Secondary timeframe RSI (originally hardcoded to 5m)

Viprasol additions: 7-factor confluence scoring engine, bar-close confirmation, trailing stop to breakeven, configurable TP levels (1-5), configurable secondary timeframe, breakeven status labels, alert conditions, and dashboard.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。