MetaTrader MT4 Indicator 100% Free MQL Source Code

Break of Structure (BOS & CHoCH) MT4 Indicator

RaptozGroupBy RaptozGroup
4.9 (120 reviews)
15,000+ Downloads
Break of Structure MT4 Indicator Example

BOS and CHoCH MT4 indicator mapping bullish and bearish structural breaks.

The Break of Structure (BOS & CHoCH) MT4 Indicator is a free MQL4 technical tool that automatically maps market structure, labels bullish/bearish BOS trend continuations, and alerts traders to early CHoCH trend reversals.

Break of Structure (BOS & CHoCH) MT4 Indicator Overview

What Is Market Structure, BOS, and CHoCH in Smart Money Concepts?

In Smart Money Concepts (SMC) and price action trading, Market Structure is the primary framework used to define trend direction and identify high-conviction reversal pivot points. Markets do not move in straight lines; they develop through a continuous series of swing highs and swing lows.

When price breaks an established swing point in the direction of the dominant trend, a Break of Structure (BOS) occurs, confirming that institutional momentum is continuing. Conversely, when price breaks a critical swing point in the opposite direction, a Change of Character (CHoCH) occurs, providing an early signal that the prevailing trend has ended and an institutional reversal is underway.

Break of Structure (BOS) vs Change of Character (CHoCH)

Break of Structure (BOS)

In an uptrend: Price breaks above the previous Higher High (HH). In a downtrend: Price breaks below the previous Lower Low (LL). Confirms trend continuation and validates the newly created Higher Low or Lower High swing base.

Change of Character (CHoCH)

In an uptrend: Price violates and closes below the last Higher Low (HL). In a downtrend: Price breaks above the last Lower High (LH). Signals the initial shift in market control from buyers to sellers (or vice versa).

Major External Structure vs Internal Sub-Structure

A crucial institutional nuance is distinguishing between external swing structure and internal sub-structure. External structure represents the macro trend boundaries (H4/Daily swings), while internal structure develops inside the leg of that major swing (M5/M15). An internal CHoCH on M5 often represents a minor pullback inside a major Daily bullish expansion leg.

Candle Body Close vs Wick Break Validation

A common pitfall in retail trading is confusing a wick sweep with a genuine structural break. The Break of Structure MT4 Indicator provides configurable validation modes:

Break ConditionStructural MeaningIndicator Classification
Candle Body CloseFull institutional displacement confirming commitment to new price territory.Valid BOS / CHoCH
Wick-Only SpikeLiquidity grab or stop sweep without sustained order volume.Liquidity Sweep (Not a BOS)

Pro Trader Execution Rules & Structural Traps

  • Always Trade in Harmony with External Structure: Do not take an internal bearish CHoCH if price has just tapped into a fresh Daily Demand zone.
  • Identify the Origin Order Block: When a strong displacement BOS occurs, mark the origin candle that initiated the move—it serves as your prime re-entry level.
  • Beware of Inducement Highs/Lows: The first minor pullbacks immediately following a BOS are often engineered as liquidity inducement traps.

Supported MT4 Timeframes & Multi-Timeframe Alignment

TimeframeTrading RoleApplication
M1 / M5Execution / TimingPinpointing internal CHoCH shifts inside HTF supply/demand zones.
M15 / H1Intraday StructureMapping London/NY session trend continuation BOS levels.
H4 / D1Macro DirectionIdentifying major swing highs/lows and institutional macro trend.

Key Features & Capabilities

Automatic detection of Break of Structure (BOS) and Change of Character (CHoCH)
Strict candle body close validation filter to eliminate wick noise
Visual connecting structure lines and non-repainting chart labels
Real-time audio, popup, and mobile push notification alerts
Compatible with MT4 Build 1420+ across all financial markets

Input Parameters & Settings Guide

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

ParameterDefault ValueDescriptionRecommended
InpSwingDepth5Fractal swing depth sensitivity5 for Standard, 3 for Fast
InpRequireBodyClosetrueRequire candle body close for valid BOSTrue
InpShowBOSLabelstrueDisplay BOS text labels on chartTrue
InpShowCHoCHLabelstrueDisplay CHoCH text labels on chartTrue
InpAlertOnBreaktrueAudio & popup alert upon structure breakTrue

Trading Strategy & Entry Rules

1

Step 1: Determine Macro Trend Direction

Look at the H4/Daily chart and identify whether price is forming consecutive bullish or bearish BOS breaks.

2

Step 2: Identify Market Structure Pullback

Wait for price to retrace into an unmitigated Order Block or Fair Value Gap.

3

Step 3: Await Lower Timeframe CHoCH

On M5, wait for price to break the counter-trend structure (Change of Character) with a confirmed candle body close.

4

Step 4: Execute on Return to Origin

Place entry on the pullback to the origin candle that caused the CHoCH break.

5

Step 5: Target Next Structural BOS Level

Set profit targets at the previous major swing high or low for a 1:3+ risk-to-reward ratio.

MQL4 Source Code

//+------------------------------------------------------------------+
//|                                  MarketStructure_BOS_CHoCH_MT4.mq4|
//|                    Copyright 2026, TraderSentiments Quant Team   |
//|                                    https://tradersentiments.com  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, TraderSentiments"
#property link      "https://tradersentiments.com/indicators/mt4/smart-money/break-of-structure-indicator"
#property version   "2.00"
#property strict
#property indicator_chart_window

input int      InpSwingDepth       = 5;           // Swing High/Low Depth
input bool     InpRequireBodyClose = true;        // Require Candle Body Close
input bool     InpShowBOSLabels    = true;        // Show BOS Labels
input bool     InpShowCHoCHLabels  = true;        // Show CHoCH Labels
input bool     InpAlertOnBreak     = true;        // Popup Alert on Structure Break

int OnInit() {
   IndicatorShortName("Market Structure BOS & CHoCH MT4");
   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:

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, 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(), "MarketStructure_BOS_CHoCH_MT4", 0, 1);
double signalSell = iCustom(Symbol(), Period(), "MarketStructure_BOS_CHoCH_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:

  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.

MarketStructure_BOS_CHoCH_MT4.mq4

Version: v2.00File Size: 16.2 KBTotal Downloads: 15,000+License: Free Open SourcePlatform: MetaTrader MT4

Download .mq4
VirusTotal Verified Clean • Zero DLL Dependencies
15,000+ DownloadsCompatible with MT4 Build 1420+

Frequently Asked Questions

BOS (Break of Structure) confirms continuation in the direction of the active trend. CHoCH (Change of Character) signals the initial reversal against the prevailing trend.
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.

MarketStructure_BOS_CHoCH_MT4.mq4
15,000+ DownloadsFree Open Source
Download .mq4