TraderSentiments
MetaTrader MT4 Indicator 100% Free MQL Source Code

SuperTrend MT4 Indicator

RaptozGroupBy RaptozGroup•
4.9 (120 reviews)
•15,000+ Downloads•
SuperTrend MT4 Indicator Chart Setup

SuperTrend indicator on MT4 showing dynamic trailing stops and trend reversal signals.

SuperTrend MT4 Indicator is a free RaptozGroup indicator for MetaTrader 4. Retained ATR bands and trend state. Optional higher-timeframe mode maps the previous completed higher-timeframe candle to each chart candle; this confirmation introduces a deliberate delay.

SuperTrend MT4 Indicator Overview

Version 3.00 implementation: Retained ATR bands and trend state. Optional higher-timeframe mode maps the previous completed higher-timeframe candle to each chart candle; this confirmation introduces a deliberate delay. Test on a demo chart; this release does not claim identical results to third-party indicators.

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:

Median Price = (High + Low) / 2
Upper Basic Band = Median Price + (Multiplier × ATR)
Lower Basic Band = Median Price − (Multiplier × ATR)

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 StyleTimeframeATR PeriodMultiplierCharacteristics
Fast ScalpingM1 / M571.5 – 2.0Rapid signal reaction; captures quick 10-15 pip impulse legs.
Standard Day TradingM15 / H1103.0Classic baseline settings; filters normal intraday market noise.
Swing / PositionH4 / D1143.5 – 4.0Smooth 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

FeatureSuperTrendParabolic SARExponential Moving Average
Volatility AdaptationYes (ATR-based)No (Acceleration factor)No (Fixed exponential smoothing)
Trailing Stop SuitabilityExceptionalProne to tight whipsawsRequires manual buffer offset
Ranging Market NoiseLow (Bands widen)High (Frequent flips)High (Repeated crossovers)

Key Features & Capabilities

Wilder ATR upper/lower bands
Retained trend state and trailing-band rules
Closed-candle trend-change alerts
Optional confirmed higher-timeframe overlay

Input Parameters & Settings Guide

Configure the indicator inputs inside MetaTrader MT4 via the Inputs tab upon attaching to your chart:

ParameterDefault ValueDescriptionRecommended
ATRPeriod10Wilder ATR periodDemo-test first
Multiplier3.0ATR band multiplierDemo-test first
TimeframePERIOD_CURRENTCurrent or higher timeframe; higher TF uses completed candlesDemo-test first
PopupAlertsfalseSee implementation notes.Demo-test first
PushAlertsfalseSee implementation notes.Demo-test first
EmailAlertsfalseSee implementation notes.Demo-test first
SoundAlertsfalseSee implementation notes.Demo-test first

Trading Strategy & Entry Rules

1

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.

2

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.

3

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.

4

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

Loading complete source file…

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:

Step 1

Download Source File

Download the raw .mq4 source file to your computer using the direct download button below.

Step 2

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.

Step 3

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.

Step 4

Attach to Chart & Configure

Return to your terminal, refresh the Navigator (Ctrl+N) panel, drag the indicator onto your active chart, and customize input parameters. These downloads do not require DLL imports.

Integrating with Expert Advisors (EA) via iCustom()

Buffer meanings differ between indicators. Check SetIndexBuffer and the plot labels in the complete source before using iCustom. A moving-average value is not a buy signal. Object-based zones and dashboards do not expose their drawings as signal buffers.

How to Set Up Mobile Push Notifications on iOS & Android

To receive the indicator’s supported alerts on your smartphone:

  1. Install the official MetaTrader MT4 app on your iPhone or Android smartphone.
  2. Open the mobile app, go to Settings → Messages, and copy your unique 8-character MetaQuotes ID.
  3. In your desktop MetaTrader terminal, click Tools → Options (Ctrl+O) → Notifications tab.
  4. Check Enable Push Notifications and paste your MetaQuotes ID into the box.
  5. 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 CodeDescriptionExact 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

Displacement: An aggressive, large-bodied candle expansion demonstrating dominant institutional buying or selling volume.
Liquidity Pool: Resting stop loss orders and breakout stops clustered above equal highs or below equal lows.
Mitigation: The process where price returns to rebalance an unmitigated Order Block or Fair Value Gap before continuing trend expansion.
Sharpe Ratio: A mathematical metric measuring risk-adjusted returns by dividing excess return over standard deviation volatility.

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: v3.00File Size: 9.2 KBTotal Downloads: 15,000+Access: Free source downloadPlatform: MetaTrader MT4

Download .mq4

Already using MetaTrader? Download the compiled .ex4 file and place it in MQL4/Indicators.

Standalone source • No DLL dependencies
15,000+ DownloadsCompatible with MT4 Build 1420+

Frequently Asked Questions

No. The indicator calculates its values strictly on confirmed closed candles, ensuring lines and reversal signals remain permanently fixed.
RaptozGroup
Developed & Audited by RaptozGroup

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