SSL REVERSAL & BREAKOUT MATRIX - MT5
====================================
UltimateTrading.tools  |  https://ultimatetrading.tools
Version 1.00  |  Licence: MPL 2.0 (see LICENCE section)

WHAT IT IS
----------
An SSL channel indicator for MetaTrader 5 that only prints a BUY or SELL
arrow when an SSL trend flip is confirmed by momentum, trend strength,
channel width and (optionally) the higher-timeframe SSL trend. Every
candidate signal gets a 0-100 score and a grade:

    90-100  A+
    80-89   A
    70-79   B
    60-69   C
    0-59    D

The arrow label reads like "BUY [A] 84%". Signals are evaluated on closed
candles only, so an arrow never appears and then disappears.

The indicator is an MQL5 port of the Pine Script v6 "WiselyWealth ; SSL
Momentum Reversal & Breakout Matrix" (TradingView Community / Antigravity
AI). This edition adds Deriv market auto-detection and a speed auto-tune.

INSTALLATION
------------
1. MT5: File > Open Data Folder > MQL5 > Indicators.
2. Copy SSL_Reversal_Breakout_Matrix_MT5.mq5 into that folder.
3. Open it in MetaEditor and press Compile (F7).
4. In MT5, refresh the Navigator and drag the indicator onto a chart.

THE SSL CHANNEL
---------------
Two moving averages are drawn: one of the highs and one of the lows.
A close above the High MA turns the trend bullish; a close below the Low
MA turns it bearish. The SSL line follows the Low MA in an uptrend and the
High MA in a downtrend. Six MA types: SMA, EMA (default), WMA, HMA, RMA,
VWMA. The channel lines turn purple when the channel is narrower than
0.5 ATR (a squeeze).

WHEN A SIGNAL FIRES
-------------------
BUY (SELL is the mirror):
  - the SSL trend flips from bearish to bullish on the closed candle
  - RSI(14) is above 50
  - DI+ is above DI- and ADX(14) is above the ADX threshold
  - channel width is at least the width threshold (measured in ATR)
  - HTF SSL trend is bullish (only when HTF confirmation is on)
  - buy score is at or above the minimum score
  - on spike markets: no up-spike on this candle or the one before

THE 0-100 SCORE
---------------
  Price action        25   flip bonus, breakout distance beyond the
                           channel (up to 0.5 ATR), body size, close
                           location in the candle range
  RSI momentum        20   distance from 50, rising/falling RSI
  ADX / DMI           25   DI dominance, ADX above threshold, ADX rising
  Relative volume     15   tick volume vs its 20-bar mean (fixed at 7.5
                           when volume is neutral - see below)
  Channel expansion   15   width vs threshold, width growing
  Penalties                opposing wick over 30% of the range (up to
                           -12), over-extension 2-3.5 ATR from the SSL
                           line (up to -8)

SIGNAL PROFILES
---------------
  Profile       ADX >   Width >   Min score
  Responsive    18      0.14      65
  Balanced      20      0.20      70   (default)
  Selective     25      0.28      80

DERIV AUTO-TUNE (Auto-tune = true)
----------------------------------
1) Market type. The symbol name and description are classified on attach
   (or set "Market type" manually). Each type adjusts the profile:

  Market               SSL len x  ADX +  Width x  Score +  Spike filter
  Volatility (incl 1s)   1.00       0     1.00      0      off
  Boom                   1.20      +2     1.10     +2      up, 4.0 x ATR
  Crash                  1.20      +2     1.10     +2      down, 4.0 x ATR
  Jump                   1.15      +2     1.10     +2      both, 3.5 x ATR
  Step                   1.00      -1     0.85      0      off
  Range Break            1.20      +2     1.20     +2      off
  DEX Up / DEX Down      1.10      +1     1.05     +1      up / down, 4.0
  Drift Switch           0.90      -2     1.00      0      off
  Vol over Boom/Crash    1.10      +1     1.05     +1      spike direction
  Gold, Forex, other     1.00       0     1.00      0      off

2) Measured noise. On load the indicator measures how efficiently price
   moves on this symbol and timeframe (mean efficiency ratio x sqrt(n);
   a random walk scores about 1.0), over up to 2,000 closed bars.
     CHOPPY   (< 0.85)  SSL length x 1.25
     TRENDING (> 1.20)  SSL length x 0.80
   Final SSL length = base length x market multiplier x noise multiplier.

3) Live speed. ATR(14) is compared with its long-run average on every bar.
     FAST (> 1.35x)  ADX +3, width x 1.15, min score +3
     SLOW (< 0.75x)  ADX -2, width x 0.90, min score -3

Auto-tune = false restores the original settings: base SSL length and the
profile thresholds only, spike filter off unless forced on.

SPIKE FILTER
------------
On Boom, Crash, Jump, DEX and Vol-over markets, a candle whose true range
exceeds the spike size (x previous ATR) in the spike direction is capped
before it reaches ATR and DMI, so one spike cannot inflate them. An SSL
flip made by a spike (this candle or the previous one) does not fire a
signal in the spike direction. Force it on or off with "Spike filter".

VOLUME SCORE
------------
Deriv synthetics tick at a near-constant rate, so tick volume carries no
information there. If tick volume over the last 300 bars varies by less
than 10% (coefficient of variation), the volume factor is fixed at 7.5/15.
Override with "Volume score" (Tick volume / Neutral).

INFO PANEL
----------
  Row 1  market family, detail and measured seconds between ticks
  Row 2  live speed (FAST / NORMAL / SLOW) and measured noise
  Row 3  active SSL length and MA, ADX, width and score thresholds
  Row 4  spike filter and volume score state, HTF timeframe if used
  Row 5  current SSL trend and its confidence score and grade

INPUTS
------
SSL Parameters      MA Type, SSL Length (base)
Signal & Filter     Signal Profile, Enable HTF Confirmation, HTF Timeframe,
                    Show Signals & Labels
Deriv Auto-Tune     Auto-tune, Market type, Spike filter, Volume score
Display             colours, Show info panel, Panel X / Y
Alerts              Confirmed BUY/SELL, SSL trend flip, Trend weakening,
                    Popup, Push, Sound, Sound file

Note: the HTF timeframe must be higher than the chart timeframe. If it is
not, no signals are produced while HTF confirmation is on.

ALERTS
------
Alerts fire once, on the candle that just closed - never for history when
the indicator loads. Confirmed BUY/SELL is on by default; SSL trend flip
and Trend weakening (channel width or ADX drops below its threshold) are
off by default. Channels: popup, push notification, sound.

BUFFERS (for EAs via iCustom / CopyBuffer)
------------------------------------------
  10  BUY arrow price         (EMPTY_VALUE when no signal)
  11  SELL arrow price        (EMPTY_VALUE when no signal)
  12  Buy score   0-100
  13  Sell score  0-100
  14  Trend confidence 0-100  (score of the current SSL direction)
  15  Signal  +1 buy / -1 sell / 0 none
  16  SSL state  +1 bull / -1 bear
Read shift 1 (the last closed candle). Shift 0 (the forming candle) never
carries a signal or score. Arrow buffers 10/11 are only filled when "Show
Signals & Labels" is on; buffer 15 is always filled.

LICENCE
-------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
you can obtain one at https://mozilla.org/MPL/2.0/.

Original work: "WiselyWealth ; SSL Momentum Reversal & Breakout Matrix"
(Pine Script v6), TradingView Community / Antigravity AI. The MQL5 port
remains under MPL 2.0 and the original attribution is kept in the source
header. If you distribute a modified version, keep it under MPL 2.0 and
make its source available.

DISCLAIMER
----------
Educational tool, not financial advice. Trading synthetic indices, forex
and metals carries a high risk of loss. Test on a demo account first.
