Supertrend Pro is a MetaTrader 5 custom indicator built in MQL5. It uses ATR-based dynamic bands to identify bullish and bearish market trends, recolors confirmed candles according to the active trend, and provides optional mobile push notifications when a confirmed trend reversal occurs.
## Features
- ATR-based Supertrend calculation
- Separate bullish and bearish Supertrend bands
- Closed-bar trend confirmation
- Trend-colored candles
- Mobile push notifications for confirmed trend reversals
- Neutral startup state before the first trend is established
- Incremental calculation using `prev_calculated`
- Optimized ATR data copying
- Automatic chart theme application
- Restoration of the previous chart appearance when the indicator is removed
- Documented indicator buffers for Expert Advisors and other MQL5 programs
- Compatible with different symbols, price scales, and digit formats
## Trend States
Supertrend Pro exposes the current confirmed trend through Buffer 7.
| State | Value |
|---|---:|
| Bullish | `1.0` |
| Bearish | `0.0` |
| Neutral | `-1.0` |
The neutral state is used only during initial trend establishment. Once a bullish or bearish trend is confirmed, the indicator switches only between bullish and bearish states.
-`InpATRMultiplier` — multiplier used to position the Supertrend bands. Default: `1.5`
### Notifications
-`InpEnablePushNotifications` — enables mobile push notifications for confirmed bullish-to-bearish and bearish-to-bullish trend changes.
The first transition from neutral to bullish or bearish does not generate a notification.
## Indicator Buffers
Supertrend Pro exposes eight buffers.
| Buffer | Description |
|---:|---|
| 0 | Candle Open |
| 1 | Candle High |
| 2 | Candle Low |
| 3 | Candle Close |
| 4 | Candle Trend Color |
| 5 | Upper/Bearish Supertrend Band |
| 6 | Lower/Bullish Supertrend Band |
| 7 | Trend State |
For programmatic access:
- If Buffer 7 is `1.0`, the active Supertrend value is in Buffer 6.
- If Buffer 7 is `0.0`, the active Supertrend value is in Buffer 5.
- If Buffer 7 is `-1.0`, the initial trend is still unresolved.
## Closed-Bar Confirmation
Supertrend Pro confirms trend changes only after a candle closes.
With chronological indexing:
-`rates_total - 1` is the current live bar.
-`rates_total - 2` is the newest confirmed bar.
An intrabar price crossing does not establish a new trend. The reversal becomes official only when the candle closes beyond the active Supertrend band.
## Mobile Push Notifications
Notifications are sent only for confirmed directional reversals:
- Bullish → Bearish
- Bearish → Bullish
Notifications are not sent for:
- Bullish → Bullish
- Bearish → Bearish
- Neutral → Bullish
- Neutral → Bearish
- historical recalculation
- indicator attachment
- history refresh
- timeframe change
- parameter change
- terminal restart
- multi-bar catch-up after inactivity
Example:
```text
Supertrend | EURUSD PERIOD_M15 | Trend changed to BULLISH
```
MetaTrader mobile notifications must be configured in the terminal for push delivery to work.
## Chart Theme
While attached, Supertrend Pro applies the following chart appearance:
- Background: `clrWhiteSmoke`
- Foreground: `clrBlack`
- Bullish candles and lower band: `clrSeaGreen`
- Bearish candles and upper band: `clrCrimson`
- Bid line: bullish color
- Ask line: bearish color
- Grid: hidden
- Chart mode: candles
The previous chart appearance is saved during initialization and restored when the indicator is removed.
## Programmatic Access
Expert Advisors and other MQL5 applications can access Supertrend Pro using `iCustom()` and `CopyBuffer()`.
Example:
```cpp
inthandle=iCustom(_Symbol,
PERIOD_CURRENT,
"supertrendPro",
10,
1.5,
true);
doubletrend[1];
doubleupperBand[1];
doublelowerBand[1];
CopyBuffer(handle,7,1,1,trend);
CopyBuffer(handle,5,1,1,upperBand);
CopyBuffer(handle,6,1,1,lowerBand);
```
Shift `1` refers to the latest confirmed bar.
## Installation
1. Copy `supertrendPro.mq5` into the MetaTrader 5 `MQL5/Indicators` directory.
2. Open the file in MetaEditor.
3. Compile the indicator.
4. Return to MetaTrader 5 and refresh the Navigator if necessary.
5. Attach **Supertrend Pro** to a chart.
6. Configure the ATR settings and push-notification option as required.
## Usage
A bullish trend is represented by:
- green confirmed candles;
- the lower Supertrend band;
- trend state `1.0`.
A bearish trend is represented by:
- red confirmed candles;
- the upper Supertrend band;
- trend state `0.0`.
The active band trails the trend and can tighten in the trend direction. A confirmed close beyond the active band changes the trend state.
## Compatibility
The calculation does not rely on Forex-specific pip assumptions. It uses the symbol's native price data, ATR values, `_Digits`, and MetaTrader 5 price precision.
The indicator is designed for use across Forex pairs, metals, CFDs, stocks, and crypto symbols supported by the connected broker.