OPEN-SOURCE SCRIPT

ClarityTrend SwiftEdge

2 303
# TrendSync Indicator

## Overview
The TrendSync Indicator is a powerful tool designed to help traders identify high-probability trading opportunities by combining two proven technical analysis methods: Linear Regression-based candlesticks and an ATR-based trailing stop strategy (UT Bot Alerts). This indicator enhances these components with unique features, including candlestick smoothing for improved visual clarity and signal reinforcement to reduce noise, making it ideal for trend-following and swing trading across various markets and timeframes.

## Originality and Purpose
This indicator merges the strengths of Linear Regression Candles and UT Bot Alerts to create a synergistic approach to trend detection:
- **Linear Regression Candles** use linear regression to smooth price data, producing candlesticks that highlight the underlying trend while filtering out market noise. This helps traders visualize trend direction more clearly.
- **UT Bot Alerts** employ an ATR-based trailing stop to generate dynamic buy and sell signals, adapting to market volatility and identifying key reversal points.
- **Unique Contributions**:
- **Candlestick Smoothing**: Added an optional SMA or EMA-based smoothing feature to make candlesticks visually cleaner and easier to interpret, especially in volatile markets.
- **Signal Reinforcement**: Introduces a filter that only displays buy/sell signals when both Linear Regression Candles and UT Bot Alerts confirm the same trend direction, reducing false signals and improving reliability.

The combination is purposeful: Linear Regression Candles provide a smoothed trend context, while UT Bot Alerts pinpoint precise entry and exit points. The reinforcement feature ensures that only the strongest signals are shown, enhancing decision-making for traders.

## How It Works
### Linear Regression Candles
- The indicator applies linear regression to OHLC (open, high, low, close) prices over a user-defined period (default: 11 bars) to create smoothed candlesticks.
- Bullish candlesticks (green) are plotted when the smoothed open is below the smoothed close, and bearish candlesticks (red) when the open is above the close.
- An optional smoothing layer (SMA or EMA, default length: 5 bars) can be applied to further reduce noise, making trends visually clearer.
- A signal line (SMA or EMA, default length: 11 bars) tracks the smoothed close price to highlight the overall trend direction.

### UT Bot Alerts
- Uses an ATR-based trailing stop (default ATR period: 10 bars, sensitivity: 1) to generate buy and sell signals.
- A buy signal is triggered when the price crosses above the trailing stop, and a sell signal when it crosses below, confirmed by a 1-period EMA crossover.
- Optionally, signals can be based on Heikin Ashi close prices (manually calculated) for smoother trend detection.

### Signal Reinforcement
- When enabled (default: true), buy signals are only shown if the Linear Regression Candles are bullish, and sell signals if they are bearish. This ensures alignment between the trend context and signal triggers, reducing false positives.

### Visuals
- **Candlesticks**: Semi-transparent green (bullish) and red (bearish) candlesticks for clear trend visualization.
- **Signal Line**: A white line (thicker for visibility) showing the smoothed trend.
- **Signals**: Large "BUY" (green) and "SELL" (red) labels below/above bars for easy identification.
- **Bar Coloring**: Green bars for bullish UT Bot conditions, red for bearish, enhancing trend awareness.

## How to Use
1. **Add to Chart**: Apply the TrendSync Indicator to any chart in TradingView.
2. **Configure Inputs** (accessible via the indicator’s settings):
- **LinReg Settings**:
- *Signal Smoothing (default: 11)*: Length of the signal line (SMA or EMA).
- *Use SMA for Signal Line*: Toggle between SMA (checked) or EMA (unchecked).
- *Enable Linear Regression (default: true)*: Turn on/off linear regression for candlesticks.
- *Linear Regression Length (default: 11)*: Period for linear regression calculation.
- *Smooth Candlesticks (default: false)*: Enable smoothing for cleaner candlesticks.
- *Candlestick Smoothing Length (default: 5)*: Period for SMA/EMA smoothing.
- *Smoothing Type (default: SMA)*: Choose SMA or EMA for candlestick smoothing.
- **UT Bot Settings**:
- *Key Value (Sensitivity, default: 1)*: Adjusts the ATR multiplier for the trailing stop. Higher values widen the stop, reducing signals.
- *ATR Period (default: 10)*: Period for ATR calculation.
- *Use Heikin Ashi for Signals (default: false)*: Use Heikin Ashi close prices for UT Bot signals.
- **Signal Settings**:
- *Reinforce Signals (default: true)*: Only show signals when LinReg and UT Bot agree.
3. **Interpret Signals**:
- **BUY**: A green "BUY" label below a bar indicates a potential long entry, especially strong when reinforced.
- **SELL**: A red "SELL" label above a bar indicates a potential short entry.
- Use the signal line and candlestick colors to confirm the trend context.
4. **Set Alerts**:
- Create alerts for "TrendSync Long" (buy) and "TrendSync Short" (sell) to receive notifications when reinforced signals occur.

## Best Practices
- **Timeframes**: Works on all timeframes, but 1H-4H charts are recommended for swing trading, and 5M-15M for scalping.
- **Markets**: Suitable for stocks, forex, crypto, and commodities. Test on your preferred market to optimize settings.
- **Settings Optimization**:
- Increase `Candlestick Smoothing Length` (e.g., 7-10) for volatile markets to reduce noise.
- Adjust `Key Value` (e.g., 0.5-2) to balance signal frequency and reliability.
- Disable `Reinforce Signals` for more frequent signals, but expect potential noise.
- **Confirmation**: Combine with other tools (e.g., support/resistance, volume) for better trade validation.

## Credits
- **Original Scripts**: Built upon "Humble LinReg Candles" and "UT Bot Alerts" from TradingView’s public library.
- **Enhancements by [Your Name]**: Developed candlestick smoothing, signal reinforcement, and custom visuals to create a unique, trader-friendly tool.

## License
MIT License: Free to use, modify, and share, provided original credits are retained.

## Disclaimer
This indicator is for educational and informational purposes only and should not be considered financial advice. Always conduct your own research and test strategies before trading.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
OSZAR »