OPEN-SOURCE SCRIPT

Swing AURORA v4.0 — Refined Trend Signals

162
### Swing Algo v4.0 — Refined Trend Signals

#### Overview
Swing Algo v4.0 is an advanced technical indicator designed for TradingView, built to detect trend changes and provide actionable buy/sell signals in various market conditions. It combines multiple technical elements like moving averages, ADX for trend strength, Stochastic RSI for timing, and RSI divergence for confirmation, all while adapting to different timeframes through auto-tuning. This indicator overlays on your chart, highlighting trend regimes with background colors, displaying buy/sell labels (including "strong" variants), and offering early "potential" signals for proactive trading decisions. It's suitable for swing trading, trend following, or as a filter for other strategies across forex, stocks, crypto, and other assets.

#### Purpose
The primary goal of Swing Algo v4.0 is to help traders identify high-probability trend reversals and continuations early, reducing noise and false signals. It aims to provide clear, non-repainting signals that align with market structure, volatility, and momentum. By incorporating filters like higher timeframe (HTF) alignment, bias EMAs, and divergence, it refines entries for better accuracy. The indicator emphasizes balanced performance across aggressive, balanced, and conservative modes, making it versatile for both novice and experienced traders seeking to optimize their decision-making process.

#### What It Indicates
- **Trend Regimes (Background Coloring)**: The chart background changes color to reflect the current market regime:
- **Green (Intense for strong uptrends, faded when cooling)**: Indicates bullish trends where price is above the baseline and EMAs are aligned upward.
- **Red/Maroon (Intense maroon for strong downtrends, faded red when cooling)**: Signals bearish trends with price below the baseline and downward EMA alignment.
- **Faded Yellow**: Marks "no-trade" zones or potential trend changes, where conditions are choppy, weak, or neutral (e.g., low ADX, near baseline, or low volatility).
- **Buy/Sell Signals**: Labels appear on the chart for confirmed entries:
- "BUY" or "STRONG BUY" for bullish signals (strong variants require higher scores and optional divergence).
- "SELL" or "STRONG SELL" for bearish signals.
- **Potential Signals**: Early warnings like "Potential BUY" or "Potential SELL" appear before full confirmation, allowing traders to anticipate moves (confirmed after a few bars based on the trigger window).
- **Divergence Marks**: Small "DIV↑" (bullish) or "DIV↓" (bearish) labels highlight RSI divergences on pivots, adding confluence for strong signals.
- **Lines**: Optional plots for baseline (teal), EMA13/21 (lime/red based on crossover), providing visual trend context.

Signals are anchored either to the current bar or confirmed pivots, ensuring alignment with price action. The indicator avoids repainting by confirming on close if enabled.

#### Key Parameters and Customization
Swing Algo v4.0 offers minimal yet efficient parameters for fine-tuning, with defaults optimized for common use cases. Most can be auto-tuned based on timeframe for simplicity:

- **Confirm on Close (no repaint)**: Boolean (default: true) – Ensures signals don't repaint by waiting for bar confirmation.
- **Auto-tune by Timeframe**: Boolean (default: true) – Automatically adjusts lengths and sensitivity for 5-15m, 30-60m, 2-4h, or higher frames.
- **Mode**: String (options: Aggressive, Balanced [default], Conservative) – Controls signal thresholds; Aggressive for more signals, Conservative for fewer but higher-quality ones.
- **Signal Anchor**: String (options: Pivot (divLB) [default], Current bar) – Places labels on confirmed pivots or the current bar.
- **Trigger Window (bars)**: Integer (default: 3) – Window for signal timing; auto-tuned if enabled.
- **Baseline Type**: String (options: HMA [default], EMA, ALMA) – Core trend line; lengths auto-tune (e.g., 55 for short frames).
- **Use Bias EMA Filter**: Boolean (default: false) – Adds a long-term EMA for trend bias.
- **Use HTF Filter**: Boolean (default: false) – Aligns with higher timeframe (auto or manual like 60m, 240m, D); override for stricter scoring.
- **Sensitivity (10–90)**: Integer (default: 55) – Adjusts ADX threshold for trend detection; higher = more sensitive.
- **Use RSI-Stoch Trigger**: Boolean (default: true) – Enables Stochastic RSI for entry timing; customizable lengths, smooths, and levels.
- **Use RSI Divergence for STRONG**: Boolean (default: true) – Requires divergence for strong signals; pivot lookback (default: 5).
- **Visual Options**: Booleans for background regime, labels, divergence marks, and lines (all default: true).

These parameters are grouped for ease, with tooltips in TradingView for quick reference. Start with defaults and tweak based on backtesting.

#### How It Works
At its core, Swing Algo v4.0 calculates a baseline (e.g., HMA) to define the trend direction. It then scores potential buys/sells using factors like:
- **Trend Strength**: ADX above a dynamic threshold, combined with EMA crossovers (13/21) and slope analysis.
- **Volatility/Volume**: Bollinger/Keltner squeeze exits, volume z-score, and ATR filters to avoid choppy markets.
- **Timing**: Stochastic RSI crossovers or micro-timing via DEMA/TEMA for precise entries.
- **Filters**: Bias EMA, HTF alignment, gap from baseline, and no-trade zones (weak ADX, near baseline, low vol).
- **Divergence**: RSI pivots confirm strong signals.
- **Scoring**: Buy/sell scores (min 3-5 based on mode) trigger labels only when all gates pass, with early "potential" detection for foresight.

The algorithm processes these in real-time, auto-adapting to timeframe for efficiency. Signals flip only on direction changes to prevent over-trading. For best results, use on liquid assets and combine with risk management.

#### Disclaimer
This indicator is for educational and informational purposes only and does not constitute financial advice, investment recommendations, or trading signals. Trading involves significant risk of loss and is not suitable for all investors. Past performance is not indicative of future results. Always backtest the indicator on your preferred assets and timeframes, and consult a qualified financial advisor before making any trading decisions. The author assumes no liability for any losses incurred from using this script. Use at your own risk.

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.