OPEN-SOURCE SCRIPT
Mis à jour HalfTrend Long/Short Signal Engine [BigBeluga]

HalfTrend Long/Short Signal Engine [BigBeluga] is an institutional-grade trend tracking toolkit built for TradingView. It filters out minor market noise to deliver definitive, non-repainting long and short entry signals based on asset volatility and structural swing pivots.
Instead of displaying standard lag-heavy moving averages, this system uses an adaptive directional engine to lock onto clean trend lines and overlay automatic risk-management matrices directly onto your chart. It calculates real-time win rates and scans multiple assets simultaneously so you can trade with systematic statistical backup.
🔵 MAIN ENGINE & MARKET CALCULATION MECHANICS
1. Pure HalfTrend Price Filter Matrix
2. Automated Risk Matrix & Multi-Asset Scanner
Pine Script®
🔵 WHY IT IS USEFUL
🔵 HOW TO USE THE SYSTEM
Streamline your trade execution, manage portfolio risk systematically, and screen multiple sectors at once with the HalfTrend Long/Short Signal Engine workspace.
Instead of displaying standard lag-heavy moving averages, this system uses an adaptive directional engine to lock onto clean trend lines and overlay automatic risk-management matrices directly onto your chart. It calculates real-time win rates and scans multiple assets simultaneously so you can trade with systematic statistical backup.
🔵 MAIN ENGINE & MARKET CALCULATION MECHANICS
1. Pure HalfTrend Price Filter Matrix
- Swing Pivot Trackers: The engine scans local high and low data using an adjustable lookback filter (Amplitude) to find actual structural swing points rather than temporary price spikes.
- Volatility-Adjusted Bands: It establishes dynamic outer channel boundaries using a 100-period Average True Range calculation divided by two (ATR/2). The total channel width automatically scales using your custom risk buffer parameter (Channel Deviation).
- Regime Flip Architecture: The system locks into a Bullish Regime when price crosses above structural highs, shifting the main tracking baseline to Green. When price slips below structural lows, it forces a Bearish Regime and changes the tracking baseline to Red.
2. Automated Risk Matrix & Multi-Asset Scanner
- Algorithmic Trade Execution: The moment a new trend regime initializes, the engine projects a strict trade tracking matrix showcasing an entry line, a clear stop-loss boundary, and three tiered profit targets (TP1, TP2, and TP3).
- Live Performance Dashboard: An integrated on-screen table calculates real-time historical metrics, tracking active wins, losses, current target risk-to-reward ratios ($1:3$), and overall system win rate percentages.
- Screener Security Matrix: The background engine leverages real-time multi-asset queries to stream concurrent trend statuses for five separate configurable symbols directly into a secondary visual dashboard.
// Automated Trade Risk & Multi-Asset Tracking Snippet
if buySignal
float dist = atr2 * baseRiskMult
activeSL := close - dist
activeTP1 := close + dist
activeTP2 := close + (dist * 2)
activeTP3 := close + (dist * 3)
tradeState := 1
entryPx := close
t1 = request.security(sym1, timeframe.period, trend)
🔵 WHY IT IS USEFUL
- Elimination of Market Noise: Standard moving averages constantly whip back and forth during consolidations. The HalfTrend calculation filters out minor intraday fluctuations, only shifting when a definitive structural high or low is broken.
- Mathematical Execution Blueprint: It takes the emotion out of trade management. Every signal comes equipped with dynamic, visually mapped stop losses and a $1:3$ risk-reward profit map that fills with real-time gradient paths.
- Macro Market Synchronicity: The multi-asset side-panel allows you to keep an eye on major market drivers (like BTC, ETH, Gold, or major FX pairs) simultaneously, ensuring your trades line up with broader institutional market direction.
🔵 HOW TO USE THE SYSTEM
- Trading Long Breakouts: When the system transitions from a bearish regime into a bullish regime, a GreenLONG label will print beneath the breakout candle. Execute your position at the white entry line, setting your dynamic stop-loss boundary inside the red risk gradient.
- Trading Short Breakdowns: Monitor the system for a shift into a bearish regime, indicated by a RedSHORT label appearing above the asset price. Execute short orders relative to the entry line and utilize the upper red gradient zone to map your protective risk ceiling.
- Managing Exits and Targets: Take partial profits sequentially as the asset price moves through the Green target lines (TP1, TP2, and TP3). If a sudden trend reversal prints an opposing signal before your final targets are satisfied, the script automatically triggers a reversal exit rule to preserve accumulated gains.
Streamline your trade execution, manage portfolio risk systematically, and screen multiple sectors at once with the HalfTrend Long/Short Signal Engine workspace.
Notes de version
- Added Channel Deviation color Transparency input at the style sectionNotes de version
Update: Accurate Win-Rate & Breakeven LogicThis update fixes the dashboard's performance metrics by eliminating double-counting and introducing breakeven logic. Because the Take Profit 1 (TP1) and Stop Loss (SL) are set at an equal distance, a trade that hits TP1 but later reverses to hit the SL results in a net-zero profit.
The script now correctly identifies these "scratch trades." Instead of logging them as both a win and a loss (which inflates the data), the update removes them from the counters entirely. This ensures your win rate reflects true, realized profitability rather than vanity metrics.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
🔵Gain access to our powerful tools : bigbeluga.com/tv
🔵Join our free discord for updates : discord.com/invite/FuW63RKgdc
All scripts & content provided by BigBeluga are for informational & educational purposes only.
🔵Join our free discord for updates : discord.com/invite/FuW63RKgdc
All scripts & content provided by BigBeluga are for informational & educational purposes only.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
🔵Gain access to our powerful tools : bigbeluga.com/tv
🔵Join our free discord for updates : discord.com/invite/FuW63RKgdc
All scripts & content provided by BigBeluga are for informational & educational purposes only.
🔵Join our free discord for updates : discord.com/invite/FuW63RKgdc
All scripts & content provided by BigBeluga are for informational & educational purposes only.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
