Advertisement IC Markets

Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Discuss 1-minute to 15-minute price action setups, fading intraday momentum, key support/resistance zones, and proven short-term trading methodologies.
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

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++

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);
  }
//+------------------------------------------------------------------+
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Recommended broker for automated trading & scalping IC Markets
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

Here i prepared version for MT5 traders:

Code: Select all

//+------------------------------------------------------------------+
//|                                     LiquiditySweepDetector.mq5 |
//|                                            Liquidity Sweep MT5 |
//+------------------------------------------------------------------+
#property copyright "Open Source"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2

//--- plot Bullish
#property indicator_label1  "Bullish Sweep"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrDeepSkyBlue
#property indicator_width1  2

//--- plot Bearish
#property indicator_label2  "Bearish Sweep"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrRed
#property indicator_width2  2

input int InpLookbackPeriod = 20; // Pivot Lookback Period

double BullSweepBuffer[];
double BearSweepBuffer[];
int atrHandle;
double atrBuffer[];

int OnInit()
  {
   SetIndexBuffer(0, BullSweepBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(0, PLOT_ARROW, 233);
   
   SetIndexBuffer(1, BearSweepBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(1, PLOT_ARROW, 234);
   
   atrHandle = iATR(_Symbol, _Period, 14);
   if(atrHandle == INVALID_HANDLE) return INIT_FAILED;
   
   ArraySetAsSeries(BullSweepBuffer, false);
   ArraySetAsSeries(BearSweepBuffer, false);
   ArraySetAsSeries(atrBuffer, false);
   
   return(INIT_SUCCEEDED);
  }

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[])
  {
   if(rates_total < InpLookbackPeriod + 2) return 0;
   
   int limit = prev_calculated == 0 ? InpLookbackPeriod + 1 : prev_calculated - 1;
   
   if(CopyBuffer(atrHandle, 0, 0, rates_total, atrBuffer) <= 0) return 0;
   
   for(int i = limit; i < rates_total; i++)
     {
      BullSweepBuffer[i] = 0.0;
      BearSweepBuffer[i] = 0.0;
      
      double pivotHigh = 0.0;
      double pivotLow = 999999.0;
      
      // Find pivot high/low looking back InpLookbackPeriod bars from i-1
      for(int j = 1; j <= InpLookbackPeriod; j++)
        {
         if(i-j >= 0)
           {
            if(high[i-j] > pivotHigh) pivotHigh = high[i-j];
            if(low[i-j] < pivotLow) pivotLow = low[i-j];
           }
        }
        
      double atr = atrBuffer[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);
  }
//+------------------------------------------------------------------+
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

And here is version for IC traders:

Code: Select all

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class LiquiditySweepDetector : Indicator
    {
        [Parameter("Lookback Period", DefaultValue = 20)]
        public int LookbackPeriod { get; set; }

        [Output("Bullish Sweep", LineColor = "DeepSkyBlue", PlotType = PlotType.Points, Thickness = 4)]
        public IndicatorDataSeries BullSweep { get; set; }

        [Output("Bearish Sweep", LineColor = "Red", PlotType = PlotType.Points, Thickness = 4)]
        public IndicatorDataSeries BearSweep { get; set; }

        private AverageTrueRange _atr;

        protected override void Initialize()
        {
            _atr = Indicators.AverageTrueRange(14, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {
            if (index < LookbackPeriod + 1)
                return;

            double pivotHigh = double.MinValue;
            double pivotLow = double.MaxValue;

            // Find highest high and lowest low over the lookback period, excluding the current bar
            for (int i = 1; i <= LookbackPeriod; i++)
            {
                if (Bars.HighPrices[index - i] > pivotHigh)
                    pivotHigh = Bars.HighPrices[index - i];
                    
                if (Bars.LowPrices[index - i] < pivotLow)
                    pivotLow = Bars.LowPrices[index - i];
            }

            double atrValue = _atr.Result[index];

            // Bearish Sweep: Pierces above pivot high but closes below
            if (Bars.HighPrices[index] > pivotHigh && Bars.ClosePrices[index] < pivotHigh && Bars.OpenPrices[index] < pivotHigh)
            {
                BearSweep[index] = Bars.HighPrices[index] + (atrValue * 0.5);
            }

            // Bullish Sweep: Pierces below pivot low but closes above
            if (Bars.LowPrices[index] < pivotLow && Bars.ClosePrices[index] > pivotLow && Bars.OpenPrices[index] > pivotLow)
            {
                BullSweep[index] = Bars.LowPrices[index] - (atrValue * 0.5);
            }
        }
    }
}

Let me know, if you like it :-)
Take a care.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
LondonScalper
Posts: 770
Joined: Sat Sep 05, 2026 7:54 am

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by LondonScalper »

PTScalper wrote: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.
Sweeps happen — stops cluster, price pokes through, then reverses. Calling every spike a smart-money trap, though, can become a story that excuses poor stop placement.

Desk approach: I expect liquidity runs around obvious Asian highs/lows into the London open. Sometimes I wait for the poke and the reclaim; sometimes I simply place invalidation beyond the zone I think gets taken. A detector that paints every wick can train you to fade everything, including genuine breakouts.

Useful idea, used sparingly. The edge is patience around known levels, not more arrows.

How do you filter which sweeps you fade versus which you treat as real continuation?
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

LondonScalper wrote: Sat Sep 12, 2026 9:28 am
PTScalper wrote: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.
Sweeps happen — stops cluster, price pokes through, then reverses. Calling every spike a smart-money trap, though, can become a story that excuses poor stop placement.

Desk approach: I expect liquidity runs around obvious Asian highs/lows into the London open. Sometimes I wait for the poke and the reclaim; sometimes I simply place invalidation beyond the zone I think gets taken. A detector that paints every wick can train you to fade everything, including genuine breakouts.

Useful idea, used sparingly. The edge is patience around known levels, not more arrows.

How do you filter which sweeps you fade versus which you treat as real continuation?
Hi LondonScalper,

thank you for interesting question.

The difference between a liquidity sweep and a genuine breakout comes down to structural alignment, time of day, and the speed of the reclaim. Price action at a key level is a question; the time spent beyond that level is the answer.
Here is how to filter sweeps from true continuation:

1. Higher-Timeframe (HTF) Structural Alignment

Institutions sweep liquidity to build a position in the direction of their underlying bias. If the daily and 4-hour trends are heavily bullish, a spike below the Asian low into a known demand block is a high-probability sweep to fade. Conversely, if you get a spike above the Asian high in that same bullish environment, fading it is a low-probability gamble—that is likely the genuine structural continuation. You fade against the local momentum, but only in the direction of the macro trend.

2. The Time-in-Zone Rule (Acceptance vs. Rejection)

A sweep is a smash-and-grab operation. Smart money does not want to hang around and offer good prices to the rest of the market.
The Sweep: Price violently breaks the level, triggers the stops, and instantly snaps back (reclaims) within 1 to 2 candles on your execution timeframe (e.g., 5m or 15m). The longer the wick, the harder the rejection.
The Continuation: Price breaks the level and stays there. If it prints 3 or 4 consecutive closes beyond the Asian high/low, the market is accepting the new valuation. The stop-run has transitioned into active institutional participation.

3. The Session Window

Context dictates intent. A violent break of a level precisely at the Frankfurt/London crossover (07:00–08:30 GMT) or the New York open (13:30–14:30 GMT) has a massive statistical probability of being a liquidity run to set the high or low of the day. A similar breakout occurring at 10:30 GMT, well into the session flow, is much more likely to be genuine trend continuation driven by real commercial order flow.

4. Footprint and Limit Absorption
If you have access to order flow or Cumulative Volume Delta (CVD), the mechanics of a trap become visible. Genuine continuation shows aggressive market orders pushing price, with delta confirming the move. A sweep often shows massive aggressive volume on the breakout candle that simply hits a brick wall of passive limit orders. When you see delta hitting new extremes but price failing to advance, the trap is set.

Your approach of waiting for the poke and the reclaim is the ultimate natural filter. It forces the market to show its hand, trading a small amount of entry slippage for a massive increase in structural confirmation.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

To code this, you need a state machine. You cannot rely on a simple ⁠ta.crossover()⁠ because a true sweep is a sequence of events tied to a strict time limit.
The architecture of the script must do three things:

1. Box the Session: Record the highest high and lowest low specifically during the defined Asian hours.

2. Start the Clock (The Sweep): The moment price crosses the Asian boundary, a "Time-in-Zone" counter starts.

3. Evaluate the Outcome (Acceptance vs. Rejection): If the candle closes back inside the boundary before the counter exceeds your limit, it triggers a Reclaim. If the counter exceeds the limit, the script assumes the market has accepted the new valuation and cancels the trap setup.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

The Pine Script Implementation

This script paints a clean, extending line from the Asian High and Low into the London/NY sessions. It strictly monitors the time-in-zone to print execution signals only when a rapid structural rejection occurs.

Code: Select all

 //@version=5
indicator("Asian Sweep & Reclaim [Desk Setup]", overlay=true)

// --- Inputs ---
grp_session = "Session Parameters"
asiaSession = input.session("1800-0200", title="Asian Session (Chart Timezone)", group=grp_session)
extendLines = input.bool(true, title="Extend Session Lines", group=grp_session)

grp_logic   = "Sweep Logic"
maxTime     = input.int(2, "Max Bars in Zone", minval=1, group=grp_logic, tooltip="1 = Same-bar wick rejection. 2 = Reclaim on the next bar.")

// ==========================================
// 1. DEFINE THE ASIAN RANGE
// ==========================================
inAsia = not na(time(timeframe.period, asiaSession))

var float asiaHigh = na
var float asiaLow  = na

// Reset highs/lows at the start of a new Asian session
if inAsia and not inAsia[1]
    asiaHigh := high
    asiaLow  := low
else if inAsia
    asiaHigh := math.max(asiaHigh, high)
    asiaLow  := math.min(asiaLow, low)

// Visuals: Draw the levels only after Asia closes so the chart stays clean
plot(not inAsia and extendLines ? asiaHigh : na, color=color.new(color.red, 40), style=plot.style_linebr, linewidth=1, title="Asia High")
plot(not inAsia and extendLines ? asiaLow : na, color=color.new(color.blue, 40), style=plot.style_linebr, linewidth=1, title="Asia Low")

// ==========================================
// 2. STATE MACHINE (TIME IN ZONE)
// ==========================================
var bool sweepingHigh  = false
var int  barsAboveHigh = 0

var bool sweepingLow   = false
var int  barsBelowLow  = 0

// Only look for sweeps outside of the Asian session
if not inAsia
    // --- HIGH SWEEP LOGIC ---
    if high > asiaHigh and not sweepingHigh
        sweepingHigh  := true
        barsAboveHigh := 1
    else if sweepingHigh
        barsAboveHigh += 1

    // Evaluate High Reclaim
    isHighReclaim = sweepingHigh and close < asiaHigh and barsAboveHigh <= maxTime
    
    // Reset High State (Either reclaimed, or accepted higher prices)
    if isHighReclaim or barsAboveHigh > maxTime
        sweepingHigh  := false
        barsAboveHigh := 0

    // --- LOW SWEEP LOGIC ---
    if low < asiaLow and not sweepingLow
        sweepingLow  := true
        barsBelowLow := 1
    else if sweepingLow
        barsBelowLow += 1

    // Evaluate Low Reclaim
    isLowReclaim = sweepingLow and close > asiaLow and barsBelowLow <= maxTime
    
    // Reset Low State (Either reclaimed, or accepted lower prices)
    if isLowReclaim or barsBelowLow > maxTime
        sweepingLow  := false
        barsBelowLow := 0

else
    // Reset everything when the next Asian session begins
    sweepingHigh  := false
    sweepingLow   := false
    barsAboveHigh := 0
    barsBelowLow  := 0
    
    // Variables used for signal triggering
    isHighReclaim = false
    isLowReclaim  = false

// ==========================================
// 3. EXECUTION SIGNALS
// ==========================================
plotshape(isHighReclaim, title="Short Reclaim", style=shape.triangledown, location=location.abovebar, color=color.rgb(255, 82, 82), size=size.small)
plotshape(isLowReclaim,  title="Long Reclaim",  style=shape.triangleup,   location=location.belowbar, color=color.rgb(0, 230, 119), size=size.small)
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

Tuning the Filter for the Desk

The 1-Bar vs 2-Bar Setting: If you set ⁠maxTime⁠ to ⁠1⁠, the script will only flag "wick" sweeps—where price pierces the level and closes back inside on the exact same candle. Setting it to ⁠2⁠ allows for a 2-bar reversal, where bar 1 closes outside (baiting breakout traders) and bar 2 engulfs it to close back inside.

Timezone Alignment: The ⁠input.session⁠ relies on your chart's current timezone setting. Ensure your TradingView chart timezone matches your mental model (e.g., if you consider Asia to be 18:00 to 02:00 EST, set your chart to New York time).

The Discretionary Override: The script paints the arrows purely based on structure. As discussed, you should only take the ⁠Long Reclaim⁠ arrows if the HTF (e.g., 4H/Daily) is structurally bullish.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

To implement a higher-timeframe filter, you must pull data from a secondary timeframe without distorting your current chart's execution timeframe. In Pine Script, this is done using the ⁠request.security()⁠ function.

By requesting a 4-hour Exponential Moving Average (EMA) while trading on a 5-minute or 15-minute chart, you can programmatically block the script from signaling a short against a massive 4-hour bullish trend, or a long into a 4-hour bearish trend.

Here is the updated script. It adds a toggleable HTF filter and plots the 4-hour EMA directly on your lower-timeframe chart for visual context.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 3349
Joined: Mon Jul 20, 2026 1:28 pm

Re: Unlocking the Smart Money Play: Why You Need a Liquidity Sweep Detector for Forex Scalping

Post by PTScalper »

Code in Pine:

Code: Select all

 //@version=5
indicator("Asian Sweep & Reclaim [HTF Filtered]", overlay=true)

// --- Inputs ---
grp_session = "Session Parameters"
asiaSession = input.session("1800-0200", title="Asian Session", group=grp_session)
extendLines = input.bool(true, title="Extend Session Lines", group=grp_session)

grp_logic   = "Sweep Logic"
maxTime     = input.int(2, "Max Bars in Zone", minval=1, group=grp_logic)

grp_htf     = "HTF Trend Filter"
htfRes      = input.timeframe("240", title="HTF Timeframe (240 = 4H)", group=grp_htf)
htfLen      = input.int(50, title="HTF EMA Length", group=grp_htf)
useFilter   = input.bool(true, title="Enable HTF Filter", group=grp_htf)

// ==========================================
// 1. HTF FILTER LOGIC
// ==========================================
// Fetch the EMA from the higher timeframe (e.g., 4H)
htfEma = request.security(syminfo.tickerid, htfRes, ta.ema(close, htfLen))

// Plot the HTF EMA on the current execution chart
plot(useFilter ? htfEma : na, color=color.new(color.white, 50), linewidth=2, title="HTF EMA")

// Define structural bias
htfBullish = not useFilter or (close > htfEma)
htfBearish = not useFilter or (close < htfEma)

// ==========================================
// 2. DEFINE THE ASIAN RANGE
// ==========================================
inAsia = not na(time(timeframe.period, asiaSession))

var float asiaHigh = na
var float asiaLow  = na

if inAsia and not inAsia[1]
    asiaHigh := high
    asiaLow  := low
else if inAsia
    asiaHigh := math.max(asiaHigh, high)
    asiaLow  := math.min(asiaLow, low)

plot(not inAsia and extendLines ? asiaHigh : na, color=color.new(color.red, 40), style=plot.style_linebr, linewidth=1, title="Asia High")
plot(not inAsia and extendLines ? asiaLow : na, color=color.new(color.blue, 40), style=plot.style_linebr, linewidth=1, title="Asia Low")

// ==========================================
// 3. STATE MACHINE (TIME IN ZONE)
// ==========================================
var bool sweepingHigh  = false
var int  barsAboveHigh = 0

var bool sweepingLow   = false
var int  barsBelowLow  = 0

isHighReclaim = false
isLowReclaim  = false

if not inAsia
    // --- HIGH SWEEP LOGIC ---
    if high > asiaHigh and not sweepingHigh
        sweepingHigh  := true
        barsAboveHigh := 1
    else if sweepingHigh
        barsAboveHigh += 1

    isHighReclaim := sweepingHigh and close < asiaHigh and barsAboveHigh <= maxTime
    
    if isHighReclaim or barsAboveHigh > maxTime
        sweepingHigh  := false
        barsAboveHigh := 0

    // --- LOW SWEEP LOGIC ---
    if low < asiaLow and not sweepingLow
        sweepingLow  := true
        barsBelowLow := 1
    else if sweepingLow
        barsBelowLow += 1

    isLowReclaim := sweepingLow and close > asiaLow and barsBelowLow <= maxTime
    
    if isLowReclaim or barsBelowLow > maxTime
        sweepingLow  := false
        barsBelowLow := 0
else
    sweepingHigh  := false
    sweepingLow   := false
    barsAboveHigh := 0
    barsBelowLow  := 0

// ==========================================
// 4. EXECUTION SIGNALS (WITH HTF FILTER)
// ==========================================
// Gate the signals behind the HTF directional bias
validShort = isHighReclaim and htfBearish
validLong  = isLowReclaim and htfBullish

plotshape(validShort, title="Short Reclaim", style=shape.triangledown, location=location.abovebar, color=color.rgb(255, 82, 82), size=size.small)
plotshape(validLong,  title="Long Reclaim",  style=shape.triangleup,   location=location.belowbar, color=color.rgb(0, 230, 119), size=size.small)
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Post Reply