SuperTrend indicator on MT4 showing dynamic trailing stops and trend reversal signals.
The SuperTrend MT4 Indicator is a free technical tool written in MQL4 for MetaTrader 4. It provides clean, non-repainting trend direction signals and dynamic volatility-based trailing stop levels with customizable audio and popup alerts.
SuperTrend MT4 Indicator Overview
What Is the SuperTrend Indicator in Forex & Financial Trading?
The SuperTrend Indicator is widely recognized as one of the most effective and straightforward trend-following and dynamic trailing stop systems in quantitative technical analysis. Originally developed by Olivier Seban, SuperTrend is built upon the foundation of Average True Range (ATR) volatility measurement.
Unlike static indicators that generate numerous false whipsaws during ranging markets, SuperTrend automatically expands and contracts its trailing stop bands according to dynamic market volatility. When price action is trading above the indicator band, the line turns Green, establishing a confirmed bullish trend. When price crosses and closes below the band, the line flips Red, signaling a bearish trend reversal.
Mathematical Formulation & Volatility Band Calculations
The SuperTrend calculation incorporates a median baseline price adjusted by an ATR multiplier factor:
A persistent memory loop retains the previous band level so that the trailing line only ratchets in the direction of the trend (upward in a bull trend, downward in a bear trend) until an explicit price close breaks across the boundary.
SuperTrend Parameter Settings by Trading Style
| Trading Style | Timeframe | ATR Period | Multiplier | Characteristics |
|---|---|---|---|---|
| Fast Scalping | M1 / M5 | 7 | 1.5 – 2.0 | Rapid signal reaction; captures quick 10-15 pip impulse legs. |
| Standard Day Trading | M15 / H1 | 10 | 3.0 | Classic baseline settings; filters normal intraday market noise. |
| Swing / Position | H4 / D1 | 14 | 3.5 – 4.0 | Smooth multi-week trend holding; rides major macroeconomic moves. |
The Dual SuperTrend Multi-Timeframe Strategy
One of the most robust ways professional quant traders deploy SuperTrend is through a Dual-Timeframe Trend Confirmation system:
1. Higher Timeframe (HTF) Trend Anchor
Attach SuperTrend (14, 3.5) on the 4-Hour or Daily chart. If the HTF SuperTrend is Green, you are strictly prohibited from taking short trades, insulating you from counter-trend bull traps.
2. Lower Timeframe (LTF) Execution Trigger
On the 15-Minute or 5-Minute chart with SuperTrend (10, 3.0), execute long positions when the LTF line flips Green in alignment with the HTF direction.
Pro Trader Best Practices & Common SuperTrend Mistakes
- Avoid Trading Choppy Consolidation Ranges: When markets enter tight horizontal ranges, SuperTrend can produce alternating buy and sell flips. Pair SuperTrend with the ADX (Average Directional Index) to avoid trading when ADX < 20.
- Do Not Enter When Price Is Overextended: If price is already 50+ pips away from the SuperTrend line when the signal occurs, wait for a minor pullback toward the band rather than buying the top.
- Use SuperTrend as a Dynamic Stop Loss: Instead of a static pip stop, adjust your stop loss to trail behind the active SuperTrend line at the close of every new candle.
SuperTrend vs Parabolic SAR vs Moving Averages
| Feature | SuperTrend | Parabolic SAR | Exponential Moving Average |
|---|---|---|---|
| Volatility Adaptation | Yes (ATR-based) | No (Acceleration factor) | No (Fixed exponential smoothing) |
| Trailing Stop Suitability | Exceptional | Prone to tight whipsaws | Requires manual buffer offset |
| Ranging Market Noise | Low (Bands widen) | High (Frequent flips) | High (Repeated crossovers) |
Key Features & Capabilities
Input Parameters & Settings Guide
Configure the indicator inputs inside MetaTrader MT4 via the Inputs tab upon attaching to your chart:
| Parameter | Default Value | Description | Recommended |
|---|---|---|---|
| InpATRPeriod | 10 | ATR volatility smoothing length | 10 for Standard, 14 for Smoother Trend |
| InpMultiplier | 3.0 | ATR band multiplier factor | 3.0 for Day Trading, 2.0 for Scalping |
| InpAlertOnTrendChange | true | Audio & popup alert upon trend reversal | True |
| InpSendEmailNotification | false | Dispatch email on trend flip | Optional |
Trading Strategy & Entry Rules
Step 1: Multi-Timeframe Trend Alignment Filter
Open the 4-Hour (H4) or Daily chart and verify the SuperTrend color. Only take Long trades when HTF is Green and Short trades when HTF is Red.
Step 2: Enter on Lower Timeframe Pullbacks
On the 15-Minute (M15) chart, wait for price to pull back near the active SuperTrend line rather than chasing breakout peaks.
Step 3: Dynamic Trailing Stop Management
Move your protective stop loss along the SuperTrend line as it advances, locking in progressive profit while allowing winning runs to develop.
Step 4: Exit on Confirmed Trend Flip
Close the entire position when a candle cleanly closes on the opposite side of the SuperTrend line.
MQL4 Source Code
//+------------------------------------------------------------------+
//| SuperTrend_MultiTimeframe_MT4.mq4|
//| Copyright 2026, TraderSentiments Quant Team |
//| https://tradersentiments.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, TraderSentiments"
#property link "https://tradersentiments.com/indicators/mt4/trend/supertrend-indicator"
#property version "2.20"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrLimeGreen
#property indicator_color2 clrCrimson
#property indicator_width1 2
#property indicator_width2 2
input int InpATRPeriod = 10; // ATR Period
input double InpMultiplier = 3.0; // ATR Multiplier Factor
input bool InpAlertOnTrendChange= true; // Popup Alert on Trend Reversal
int OnInit() {
IndicatorShortName("SuperTrend MT4 (" + IntegerToString(InpATRPeriod) + "," + DoubleToStr(InpMultiplier, 1) + ")");
return(INIT_SUCCEEDED);
}How to Install & Compile in MetaTrader MT4
Follow this complete step-by-step technical guide to install, compile, and configure the custom MQL4 indicator on your desktop trading terminal:
Download Source File
Download the raw .mq4 source file to your computer using the direct download button below.
Open MT4 Data Folder
Open your MetaTrader terminal, navigate to the top menu bar, click File → Open Data Folder, and open the MQL4 → Indicators subfolder.
Copy & Compile in MetaEditor
Paste the downloaded file into the Indicators directory. Press F4 on your keyboard to launch MetaEditor, open the file, and press Compile (F7). Ensure the compiler reports 0 errors and 0 warnings.
Attach to Chart & Configure
Return to your terminal, refresh the Navigator (Ctrl+N) panel, drag the indicator onto your active chart, check Allow DLL imports (if applicable), and customize input parameters.
Integrating with Expert Advisors (EA) via iCustom()
Algorithmic traders and quant developers can seamlessly integrate this indicator into custom automated Expert Advisors (EAs). Because the indicator calculates values into standardized plot buffers on closed bars, you can query buffer values using native MQL4 functions without recompilation:
// MT4 MQL4 iCustom Calling Syntax Example
double signalBuy = iCustom(Symbol(), Period(), "SuperTrend_MultiTimeframe_MT4", 0, 1);
double signalSell = iCustom(Symbol(), Period(), "SuperTrend_MultiTimeframe_MT4", 1, 1);
if (signalBuy != 0.0 && signalBuy != EMPTY_VALUE) {
// Bullish signal confirmed on closed bar [1] -> Execute Buy Order
}
if (signalSell != 0.0 && signalSell != EMPTY_VALUE) {
// Bearish signal confirmed on closed bar [1] -> Execute Sell Order
}How to Set Up Mobile Push Notifications on iOS & Android
To receive real-time push alerts on your smartphone whenever an institutional signal triggers:
- Install the official MetaTrader MT4 app on your iPhone or Android smartphone.
- Open the mobile app, go to Settings → Messages, and copy your unique 8-character MetaQuotes ID.
- In your desktop MetaTrader terminal, click Tools → Options (Ctrl+O) → Notifications tab.
- Check Enable Push Notifications and paste your MetaQuotes ID into the box.
- Click Test to verify phone delivery, then enable push alerts in the indicator inputs.
Institutional Risk Management & Capital Preservation Protocol
Professional proprietary trading desks operate under strict risk control parameters to ensure longevity:
- Maximum 1% - 2% Risk Rule: Never risk more than 1% to 2% of total account equity on any individual trade setup.
- Minimum 1:2.5 Risk-to-Reward Ratio (RRR): Only execute setups where the potential profit target is at least 2.5 times greater than the stop-loss invalidation distance.
- Multi-Timeframe Confluence Required: Never take an intraday trade against the primary Daily or 4-Hour trend direction.
- High-Impact Economic News Awareness: Avoid entering new positions 15 minutes before and after major macroeconomic data releases (such as US Non-Farm Payrolls, CPI Inflation, and central bank FOMC/ECB interest rate announcements).
Strategy Backtesting & Historical Modeling Protocol
Before deploying any indicator or automated strategy in a live trading environment, professional quants conduct rigorous multi-year backtesting across varying market conditions:
- 99.9% Tick Data Modeling: Use high-precision tick history from reputable data providers (such as Dukascopy or TrueFX) to eliminate spread anomalies and slippage distortion.
- Spread & Commission Inclusion: Always test with realistic variable spreads and broker commission structures to simulate true real-world execution friction.
- Out-of-Sample Walk-Forward Optimization: Avoid curve-fitting by validating parameters on 70% in-sample data and testing robustness on 30% out-of-sample data.
- Monte Carlo Drawdown Analysis: Run randomized trade sequence simulations to calculate the maximum potential drawdown under adverse market volatility regimes.
Virtual Private Server (VPS) & Execution Latency Optimization
For active day traders, scalpers, and automated Expert Advisors, execution speed is paramount:
- Low-Latency Proximity Hosting: Deploy your MetaTrader MT4 terminal on a dedicated Windows VPS located in the same financial data center (e.g. Equinix LD4 in London or NY4 in New York) as your broker server to achieve sub-millisecond execution times.
- Terminal Memory Optimization: Go to Tools → Options → Charts and decrease Max bars in chart to 5,000 to conserve CPU and RAM resources.
- Audio & News Feed Disabling: Turn off unneeded terminal audio event chimes and background news feeds to ensure 100% of CPU cycles are dedicated to indicator calculations.
Common MetaTrader Error Codes & Resolution Matrix
| Error Code | Description | Exact Resolution Action |
|---|---|---|
| ERR_INVALID_STOPS (130) | Stop Loss or Take Profit is too close to current price. | Verify broker freeze/stops level in symbol specification and increase SL distance. |
| ERR_OFF_QUOTES (136) | Broker server has no available liquidity quotes. | Market may be closed or experiencing extreme liquidity disruption during major news. |
| ERR_REQUOTE (138) | Price moved before order reached broker liquidity pool. | Increase slippage tolerance deviation parameter in your order execution settings. |
| ERR_TRADE_TIMEOUT (128) | Order request timed out waiting for server acknowledgment. | Check internet connection latency or migrate terminal to a dedicated trading VPS. |
Institutional Quantitative Trading Lexicon
Broker Execution Models & Raw Spread Compatibility
To achieve optimal performance when using custom technical indicators:
- ECN / Raw Spread Accounts: Use True ECN accounts with 0.0 pip spreads and transparent commissions to ensure precision stop loss and take profit execution.
- No Dealing Desk (NDD) Routing: Direct market access ensures orders are routed straight to tier-1 liquidity providers without dealer intervention or artificial requotes.
- Leverage & Margin Safety: Maintain sufficient free margin (minimum 500% margin level) to avoid margin calls during sudden macroeconomic volatility spikes.
SuperTrend_MultiTimeframe_MT4.mq4
Version: v2.20File Size: 16.5 KBTotal Downloads: 15,000+License: Free Open SourcePlatform: MetaTrader MT4
Frequently Asked Questions

Quantitative algorithmic trading research desk specializing in MetaTrader MQL4/MQL5 automated systems, institutional order book mechanics, and risk management tools.
