Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping
Posted: Thu Jul 30, 2026 7:40 pm
Hey everyone,
If you’re scalping the lower timeframes (like the 5M or 15M), you’ve probably experienced the frustration of getting stopped out
by a sudden spike, only to watch the market immediately reverse in your original direction. This isn’t bad luck—it’s a liquidity
sweep.Smart money (institutions and large market makers) relies on areas with concentrated order blocks, such as prior swing
highs and lows, to fill their massive positions. They intentionally push the price past these key levels to trigger resting stop-loss
and breakout orders. Once the liquidity is absorbed, the market aggressively reverses.
As scalpers, identifying these traps in real-time is one of the most profitable edge-building strategies out there.
However, manually tracking every recent high and low across multiple pairs is exhausting.
This is where a Liquidity Sweep Detector becomes essential.A proper liquidity sweep indicator automates
the process by mapping out recent structure and scanning for a specific candlestick formation: a piercing wick
that breaks a key level, followed by a body close back inside the range.Here is how I trade sweeps:Context is King:
I map my directional bias on the 1H or 4H chart.The Sweep: On the 5M or 15M, I wait for the price to spike above
a recent high (bearish sweep) or below a recent low (bullish sweep).The Confirmation:
The candle must reject the level and close back inside. The longer the wick, the stronger the rejection.Execution:
Enter on the close of the sweep candle or on a break of structure on the 1M chart.To help you get started,
I’ve coded a simple Liquidity Sweep Detector for MT4 (MQL4) below. It scans for a pivot high/low over a customizable
lookback period and plots arrows when price wicks past that level but closes back inside.Test it out on a demo account,
tweak the lookback periods to fit your timeframe, and let me know your thoughts below!
The MT4 Indicator Code (MQL4)Here is the source code for the custom indicator you can include in your post.
It uses the Average True Range (ATR) to cleanly space the arrows away from the candles.C++
If you’re scalping the lower timeframes (like the 5M or 15M), you’ve probably experienced the frustration of getting stopped out
by a sudden spike, only to watch the market immediately reverse in your original direction. This isn’t bad luck—it’s a liquidity
sweep.Smart money (institutions and large market makers) relies on areas with concentrated order blocks, such as prior swing
highs and lows, to fill their massive positions. They intentionally push the price past these key levels to trigger resting stop-loss
and breakout orders. Once the liquidity is absorbed, the market aggressively reverses.
As scalpers, identifying these traps in real-time is one of the most profitable edge-building strategies out there.
However, manually tracking every recent high and low across multiple pairs is exhausting.
This is where a Liquidity Sweep Detector becomes essential.A proper liquidity sweep indicator automates
the process by mapping out recent structure and scanning for a specific candlestick formation: a piercing wick
that breaks a key level, followed by a body close back inside the range.Here is how I trade sweeps:Context is King:
I map my directional bias on the 1H or 4H chart.The Sweep: On the 5M or 15M, I wait for the price to spike above
a recent high (bearish sweep) or below a recent low (bullish sweep).The Confirmation:
The candle must reject the level and close back inside. The longer the wick, the stronger the rejection.Execution:
Enter on the close of the sweep candle or on a break of structure on the 1M chart.To help you get started,
I’ve coded a simple Liquidity Sweep Detector for MT4 (MQL4) below. It scans for a pivot high/low over a customizable
lookback period and plots arrows when price wicks past that level but closes back inside.Test it out on a demo account,
tweak the lookback periods to fit your timeframe, and let me know your thoughts below!
The MT4 Indicator Code (MQL4)Here is the source code for the custom indicator you can include in your post.
It uses the Average True Range (ATR) to cleanly space the arrows away from the candles.C++
Code: Select all
//+------------------------------------------------------------------+
//| LiquiditySweepDetector.mq4 |
//| Liquidity Sweep MT4 |
//+------------------------------------------------------------------+
#property copyright "Open Source"
#property link ""
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrDeepSkyBlue
#property indicator_color2 clrRed
#property indicator_width1 2
#property indicator_width2 2
//--- input parameters
input int InpLookbackPeriod = 20; // Pivot Lookback Period
//--- indicator buffers
double BullSweepBuffer[];
double BearSweepBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- Bullish Sweep setup (Buy)
SetIndexBuffer(0, BullSweepBuffer);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 233); // Up Arrow
SetIndexLabel(0, "Bullish Sweep");
//--- Bearish Sweep setup (Sell)
SetIndexBuffer(1, BearSweepBuffer);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 234); // Down Arrow
SetIndexLabel(1, "Bearish Sweep");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
// Require minimum bars
if(rates_total < InpLookbackPeriod + 2)
return(0);
int limit = rates_total - prev_calculated;
if(prev_calculated == 0)
limit = rates_total - InpLookbackPeriod - 2;
for(int i = limit; i >= 1; i--)
{
BullSweepBuffer[i] = EMPTY_VALUE;
BearSweepBuffer[i] = EMPTY_VALUE;
// Look back 'n' bars from the previous candle to find the pivot points
int highestIndex = iHighest(Symbol(), 0, MODE_HIGH, InpLookbackPeriod, i + 1);
int lowestIndex = iLowest(Symbol(), 0, MODE_LOW, InpLookbackPeriod, i + 1);
if(highestIndex == -1 || lowestIndex == -1)
continue;
double pivotHigh = High[highestIndex];
double pivotLow = Low[lowestIndex];
// Calculate buffer spacing based on ATR for dynamic arrow placement
double atr = iATR(Symbol(), 0, 14, i);
// Bearish Sweep: Price pierced above previous pivot high but closed below it
if(High[i] > pivotHigh && Close[i] < pivotHigh && Open[i] < pivotHigh)
{
BearSweepBuffer[i] = High[i] + (atr * 0.5);
}
// Bullish Sweep: Price pierced below previous pivot low but closed above it
if(Low[i] < pivotLow && Close[i] > pivotLow && Open[i] > pivotLow)
{
BullSweepBuffer[i] = Low[i] - (atr * 0.5);
}
}
return(rates_total);
}
//+------------------------------------------------------------------+