PROTECTED SOURCE SCRIPT

🧠Adil Hoca Hybrid MA Optimizer

65
**HYBRID MOVING AVERAGE OPTIMIZER - USER GUIDE**

**OVERVIEW**
This Pine Script indicator automatically selects the most successful moving averages by backtesting 104 different combinations in real-time. It operates on 4 speed levels (FAST/MID/SLOW/XSLOW) and detects trend reversals with high accuracy.

**KEY FEATURES**
- 13 different moving average types: EMA, SMA, RMA, WMA, VWMA, HMA, DEMA, TEMA, FRAMA, KAMA, ALMA, SMMA, VIDYA
- 4-level hierarchical structure: FAST (5-10), MID (13-17), SLOW (25-34), XSLOW (50-70)
- Automatic performance tracking and best MA selection
- Real-time confidence score calculation
- LONG and SHORT signals
- Visual panel and labels

**USER PARAMETERS**

1. **Learning Period (default: 250)**
- The number of bars the indicator uses to analyze historical data.
- Higher value: Longer learning time, more reliable results.
- Recommended: Between 200-500.

2. **Confidence Threshold (default: 0.75 - 75 percent)**
- The minimum success rate required to generate a signal.
- Higher value: Fewer but more reliable signals.
- Recommended: Between 0.70-0.85.

3. **Minimum Signals (default: 10)**
- The minimum number of signals an MA must generate to be considered for evaluation.
- Higher value: More tested, reliable combinations.
- Recommended: Between 5-20.

4. **MA Lines (default: on)**
- Displays the 4 best-selected MAs on the chart.
- Green (FAST), Orange (MID), Red (SLOW), Purple (XSLOW).

5. **Signals (default: on)**
- Shows LONG (up triangle) and SHORT (down triangle) signals.
- Signals are generated when the MA hierarchy changes.

6. **Info Panel (default: on)**
- Displays live statistics in the top-right corner.
- Selected MAs, confidence scores, and trend status.

**HOW IT WORKS**

1. **Learning Phase**
- The indicator silently tests all MA combinations over the initial 250 bars.
- It records the success rate of each combination.
- It compares predictions with actual price movements.

2. **Selection Phase**
- It selects the most successful MA at each level (FAST/MID/SLOW/XSLOW).
- Both the success rate and the number of signals are taken into account.
- It is continuously and dynamically updated.

3. **Signal Generation**
- A signal is generated when the hierarchy among the 4 selected MAs changes.
- **LONG:** FAST > MID > SLOW > XSLOW (all in an upward sequence).
- **SHORT:** FAST < MID < SLOW < XSLOW (all in a downward sequence).
- The combined confidence score must exceed the threshold value.

**INTERPRETING SIGNALS**

**LONG Signal (Green Up Triangle)**
- All MAs have shifted into a bullish formation.
- Indicates the beginning of a strong uptrend.
- Label: Shows the MAs used and the confidence score.

**SHORT Signal (Red Down Triangle)**
- All MAs have shifted into a bearish formation.
- Indicates the beginning of a strong downtrend.
- Label: Shows the MAs used and the confidence score.

**INFO PANEL EXPLANATIONS**

- **FAST:** The fastest-reacting MA (5-10 periods).
- **MID:** Medium-speed MA (13-17 periods).
- **SLOW:** Slow MA (25-34 periods).
- **XSLOW:** The slowest MA (50-70 periods).
- **Combined Confidence:** The average success score of the 4 levels.
- **Fast Score:** The success rate of the FAST level.
- **XSlow Score:** The success rate of the XSLOW level.
- **Trend:** The current market condition (STRONG UP/DOWN/MIXED).

**ADVANCED MA TYPES**

**FRAMA (Fractal Adaptive Moving Average)**
- An adaptive average based on fractal geometry.
- Automatically adjusts its speed based on market volatility.
- Behaves differently in trending and consolidation periods.

**KAMA (Kaufman Adaptive Moving Average)**
- Uses the Efficiency Ratio (ER).
- Reacts quickly in strong trends and slowly in sideways markets.
- Filters out noise.

**ALMA (Arnaud Legoux Moving Average)**
- Uses Gaussian distribution weighting.
- Has very low lag.
- Smooth and responsive.

**SMMA (Smoothed Moving Average)**
- Another name for RMA.
- Very smooth, lagging.
- Ideal for long-term trends.

**VIDYA (Variable Index Dynamic Average)**
- Based on the Chande Momentum Oscillator (CMO).
- Fast when momentum is high, slow when it is low.
- Adapts to volatility.

**USAGE TIPS**

1. **First Use**
- Add the indicator to your chart.
- Wait for the learning period to complete (250+ bars).
- Signals will start to appear automatically.

2. **Different Timeframes**
- Short-term trading: 5-15 minute charts.
- Mid-term trading: 1-4 hour charts.
- Long-term trading: Daily charts.

3. **Parameter Optimization**
- High-volatility markets: Increase the confidence threshold (0.80+).
- Low-volatility markets: Decrease the confidence threshold (0.70).
- For more signals: Lower the minimum signals (5-7).

4. **Combination with Other Indicators**
- Confirm overbought/oversold conditions with RSI.
- Confirm strength with volume indicators.
- Confirm position with support/resistance levels.

5. **Risk Management**
- Not every signal means an automatic trade.
- Set your stop-loss levels.
- Manage your position size.
- A combined confidence score above 80 percent is more reliable.

**OPTIMIZATION DETAILS**

**Test Function**
- Resolves the TradingView runtime error by converting repetitive code blocks into functions.
- Each MA is tested separately.
- Calculates the success rate by looking 10 bars ahead.

**Performance Tracking**
- Successful predictions: `price_correct` variable.
- Failed predictions: Cases that are not successful.
- Dynamic scoring: `(0.5 * 0.3) + (success_rate * 0.7)`

**WARNINGS**

- Past performance is not a guarantee of future results.
- Do not follow all signals blindly.
- Market conditions can change.
- Trade on a demo account before trading with real money.
- Know your own risk tolerance.

This indicator uses machine learning principles to automatically find the best moving average combinations. It is suitable for both beginners and experienced traders. However, it should always be used in conjunction with your own analysis, and risk management should not be neglected.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.