OPEN-SOURCE SCRIPT
Telah dikemas kini

HalfTrend Long/Short Signal Engine [BigBeluga]

20 815
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
  • 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.
    syot kilat


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).
    syot kilat
  • 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.
    syot kilat
  • 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.
    syot kilat


Pine Script®
// 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.
Nota Keluaran
- Added Channel Deviation color Transparency input at the style section
Nota Keluaran
Update: Accurate Win-Rate & Breakeven Logic
This 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.
Nota Keluaran
Credits to everget for the original HalfTrend logic used in this script:
HalfTrend

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.