Swing highs and swing lows are where stops and pending orders pile up. When price pushes through one of those levels and closes beyond it, the structure breaks. When it only pokes through with a wick and closes back inside, the move was a fakeout: liquidity was taken and the level held.
This indicator by Jos-ProTrader (JPT) puts both situations on the price chart. It marks every confirmed swing, grades it as strong, normal or weak, draws its level, flags the first close beyond the latest swing and prints a BUY or SELL signal when a swing is swept and reclaimed on a closed bar.
Swings. A swing high is a bar whose high is above the highs of the 16 bars on each side (pivot strength). A swing low is the mirror image. A swing is only known 16 bars after it forms, so its level is drawn from the swing bar to the bar where it was confirmed.
Swing strength. Each swing earns up to three points:
Three points give a Strong swing, two a Normal one and fewer a Weak one.
Swing break. The first close above the latest swing high (or below the latest swing low) is a structure break. Only one break is counted per swing.
Fakeout. A bullish fakeout is a bar that trades below the latest swing low but closes back above it, with a lower wick of at least 25 % of its range. That is a sweep of the liquidity under the low followed by a reclaim. The bearish fakeout is the mirror image at the latest swing high. Two optional filters make it stricter: the bar must close in the direction of the signal, and the sweep must go beyond the swing by a minimum fraction of the ATR. Signals are only given on closed bars.
//---------------------------------------------------------------
// PRC_Fakeout Swing Signals
// version = 0
// 18.11.2026
// Iván González @ www.prorealcode.com
// Author: Jos-ProTrader
// Sharing ProRealTime knowledge
//--------------------------------------------------------------------//
DEFPARAM DRAWONLASTBARONLY = true
// ===================== INPUTS: SWING DETECTION =====================
pivotLen = 16 // pivot strength (bars on each side), min 2
showLabels = 1 // 1 = show swing labels
showLevels = 1 // 1 = show swing levels
extendLevels = 0 // 1 = extend swing levels to the right
maxLevels = 20 // maximum stored levels per side (5 - 100)
// ===================== INPUTS: SWING STRENGTH =====================
atrLen = 14 // ATR length
atrFactor = 1.0 // ATR strength: distance to the previous swing, in ATRs
wickFactor = 0.40 // minimum wick, as a fraction of the bar range
bodyFactor = 0.50 // minimum body, as a fraction of the bar range
// ===================== INPUTS: FAKE BREAKOUT DETECTION =====================
showFakeSignals = 1 // 1 = show BUY / SELL fake breakout signals
requireCandleColor = 0 // 1 = the reversal bar must close in the signal direction
minWickPercent = 0.25 // minimum sweep wick, as a fraction of the bar range
atrSweepFilter = 0 // 1 = the sweep must go beyond the swing by minSweepATR ATRs
minSweepATR = 0.10 // minimum sweep distance, in ATRs
// ===================== INPUTS: VISUAL =====================
showBreakMarkers = 1 // 1 = show swing break dots
showStrengthLabels = 1 // 1 = show the Strong / Normal / Weak text
showCurrentSwing = 1 // 1 = show the current swing high / low lines
maxLabels = 300 // most recent swing labels kept on the chart
maxMarkers = 500 // most recent break dots and BUY / SELL signals kept on the chart
// ===================== INDICATORS =====================
myATR = averagetruerange[atrLen](close)
IF barindex >= atrLen THEN
markOff = myATR
ELSE
markOff = high - low
ENDIF
bodySize = abs(close - open)
rangeSize = high - low
upperWick = high - max(open, close)
lowerWick = min(open, close) - low
IF rangeSize > 0 THEN
bodyPct = bodySize / rangeSize
upperPct = upperWick / rangeSize
lowerPct = lowerWick / rangeSize
ELSE
bodyPct = 0
upperPct = 0
lowerPct = 0
ENDIF
// pivots: strict against the later bars, >= against the earlier ones
hhAfter = highest[pivotLen](high)
hhBefore = highest[pivotLen](high)[pivotLen + 1]
llAfter = lowest[pivotLen](low)
llBefore = lowest[pivotLen](low)[pivotLen + 1]
newPH = 0
newPL = 0
IF barindex >= 2 * pivotLen THEN
IF high[pivotLen] > hhAfter AND high[pivotLen] >= hhBefore THEN
newPH = 1
ENDIF
IF low[pivotLen] < llAfter AND low[pivotLen] <= llBefore THEN
newPL = 1
ENDIF
ENDIF
// ===================== STORAGE =====================
ONCE hasSH = 0
ONCE hasSL = 0
ONCE lastSH = 0
ONCE lastSL = 0
ONCE highBroken = 0
ONCE lowBroken = 0
ONCE nPv = 0
ONCE nMk = 0
// ===================== SWING HIGH DETECTION =====================
IF newPH = 1 THEN
pvHigh = high[pivotLen]
IF hasSH = 0 THEN
distH = myATR[pivotLen]
ELSE
distH = abs(pvHigh - lastSH)
ENDIF
scoreH = 0
IF distH > myATR[pivotLen] * atrFactor THEN
scoreH = scoreH + 1
ENDIF
IF upperPct[pivotLen] > wickFactor THEN
scoreH = scoreH + 1
ENDIF
IF bodyPct[pivotLen] > bodyFactor THEN
scoreH = scoreH + 1
ENDIF
lastSH = pvHigh
hasSH = 1
highBroken = 0
// swing store (both sides share it, in creation order)
$pvX[nPv] = barindex - pivotLen
$pvY[nPv] = pvHigh
$pvS[nPv] = scoreH
$pvD[nPv] = barindex
$pvU[nPv] = 1
$pvO[nPv] = markOff[pivotLen]
nPv = nPv + 1
ENDIF
// ===================== SWING LOW DETECTION =====================
IF newPL = 1 THEN
pvLow = low[pivotLen]
IF hasSL = 0 THEN
distL = myATR[pivotLen]
ELSE
distL = abs(pvLow - lastSL)
ENDIF
scoreL = 0
IF distL > myATR[pivotLen] * atrFactor THEN
scoreL = scoreL + 1
ENDIF
IF lowerPct[pivotLen] > wickFactor THEN
scoreL = scoreL + 1
ENDIF
IF bodyPct[pivotLen] > bodyFactor THEN
scoreL = scoreL + 1
ENDIF
lastSL = pvLow
hasSL = 1
lowBroken = 0
$pvX[nPv] = barindex - pivotLen
$pvY[nPv] = pvLow
$pvS[nPv] = scoreL
$pvD[nPv] = barindex
$pvU[nPv] = 0
$pvO[nPv] = markOff[pivotLen]
nPv = nPv + 1
ENDIF
// ===================== SWING BREAK DETECTION =====================
bullBreak = 0
bearBreak = 0
IF hasSH = 1 AND close > lastSH AND highBroken = 0 THEN
bullBreak = 1
highBroken = 1
ENDIF
IF hasSL = 1 AND close < lastSL AND lowBroken = 0 THEN
bearBreak = 1
lowBroken = 1
ENDIF
// marker store: type 1 = bullish break, 2 = bearish break, 3 = BUY, 4 = SELL
// Y is frozen here, on the bar of the event
IF showBreakMarkers = 1 THEN
IF bullBreak = 1 THEN
$mkX[nMk] = barindex
$mkY[nMk] = high + 0.4 * markOff
$mkT[nMk] = 1
nMk = nMk + 1
ENDIF
IF bearBreak = 1 THEN
$mkX[nMk] = barindex
$mkY[nMk] = low - 0.4 * markOff
$mkT[nMk] = 2
nMk = nMk + 1
ENDIF
ENDIF
// ===================== FAKE BREAKOUT DETECTION =====================
IF hasSL = 1 THEN
bullSweepDist = lastSL - low
ELSE
bullSweepDist = 0
ENDIF
IF hasSH = 1 THEN
bearSweepDist = high - lastSH
ELSE
bearSweepDist = 0
ENDIF
bullSweepOk = 0
IF atrSweepFilter = 0 OR bullSweepDist >= myATR * minSweepATR THEN
bullSweepOk = 1
ENDIF
bearSweepOk = 0
IF atrSweepFilter = 0 OR bearSweepDist >= myATR * minSweepATR THEN
bearSweepOk = 1
ENDIF
// bullish liquidity sweep and reclaim
fakeBull = 0
IF hasSL = 1 AND low < lastSL AND close > lastSL AND lowerPct >= minWickPercent AND bullSweepOk = 1 THEN
IF requireCandleColor = 0 OR close > open THEN
fakeBull = 1
ENDIF
ENDIF
// bearish liquidity sweep and rejection
fakeBear = 0
IF hasSH = 1 AND high > lastSH AND close < lastSH AND upperPct >= minWickPercent AND bearSweepOk = 1 THEN
IF requireCandleColor = 0 OR close < open THEN
fakeBear = 1
ENDIF
ENDIF
// signals only on closed bars: the bar is recorded when the next one opens
IF showFakeSignals = 1 AND barindex > 0 THEN
IF fakeBull[1] = 1 THEN
$mkX[nMk] = barindex - 1
$mkY[nMk] = low[1] - 1.2 * markOff[1]
$mkT[nMk] = 3
nMk = nMk + 1
ENDIF
IF fakeBear[1] = 1 THEN
$mkX[nMk] = barindex - 1
$mkY[nMk] = high[1] + 1.2 * markOff[1]
$mkT[nMk] = 4
nMk = nMk + 1
ENDIF
ENDIF
// ===================== DRAWING =====================
IF islastbarupdate THEN
// swing levels (last maxLevels per side) and swing labels (last maxLabels)
IF nPv > 0 THEN
cntH = 0
cntL = 0
cntLb = 0
FOR j = nPv - 1 DOWNTO 0 DO
xA = $pvX[j]
xB = $pvD[j]
yP = $pvY[j]
sc = $pvS[j]
IF $pvU[j] = 1 THEN
IF showLevels = 1 AND cntH < maxLevels THEN
IF extendLevels = 1 THEN
DRAWRAY(xA, yP, xB, yP) COLOURED(242, 54, 69, 255) STYLE(line, 2)
ELSE
DRAWSEGMENT(xA, yP, xB, yP) COLOURED(242, 54, 69, 255) STYLE(line, 2)
ENDIF
ENDIF
cntH = cntH + 1
IF showLabels = 1 AND showStrengthLabels = 1 AND cntLb < maxLabels THEN
yT = yP + 0.6 * $pvO[j]
IF sc = 3 THEN
DRAWTEXT("Strong High", xA, yT, SansSerif, Bold, 9) COLOURED(242, 54, 69, 255)
ELSIF sc = 2 THEN
DRAWTEXT("Normal High", xA, yT, SansSerif, Bold, 9) COLOURED(255, 152, 0, 255)
ELSE
DRAWTEXT("Weak High", xA, yT, SansSerif, Bold, 9) COLOURED(120, 123, 134, 255)
ENDIF
ENDIF
ELSE
IF showLevels = 1 AND cntL < maxLevels THEN
IF extendLevels = 1 THEN
DRAWRAY(xA, yP, xB, yP) COLOURED(0, 230, 118, 255) STYLE(line, 2)
ELSE
DRAWSEGMENT(xA, yP, xB, yP) COLOURED(0, 230, 118, 255) STYLE(line, 2)
ENDIF
ENDIF
cntL = cntL + 1
IF showLabels = 1 AND showStrengthLabels = 1 AND cntLb < maxLabels THEN
yT = yP - 0.6 * $pvO[j]
IF sc = 3 THEN
DRAWTEXT("Strong Low", xA, yT, SansSerif, Bold, 9) COLOURED(0, 180, 90, 255)
ELSIF sc = 2 THEN
DRAWTEXT("Normal Low", xA, yT, SansSerif, Bold, 9) COLOURED(230, 180, 0, 255)
ELSE
DRAWTEXT("Weak Low", xA, yT, SansSerif, Bold, 9) COLOURED(120, 123, 134, 255)
ENDIF
ENDIF
ENDIF
cntLb = cntLb + 1
IF cntH >= maxLevels AND cntL >= maxLevels AND cntLb >= maxLabels THEN
BREAK
ENDIF
NEXT
ENDIF
// break dots and BUY / SELL signals (last maxMarkers)
IF nMk > 0 THEN
kFirst = max(0, nMk - maxMarkers)
FOR k = kFirst TO nMk - 1 DO
mT = $mkT[k]
IF mT = 1 THEN
DRAWTEXT("●", $mkX[k], $mkY[k], SansSerif, Standard, 8) COLOURED(0, 230, 118, 255)
ELSIF mT = 2 THEN
DRAWTEXT("●", $mkX[k], $mkY[k], SansSerif, Standard, 8) COLOURED(242, 54, 69, 255)
ELSIF mT = 3 THEN
DRAWTEXT("BUY", $mkX[k], $mkY[k], SansSerif, Bold, 11) COLOURED(0, 180, 90, 255)
ELSE
DRAWTEXT("SELL", $mkX[k], $mkY[k], SansSerif, Bold, 11) COLOURED(242, 54, 69, 255)
ENDIF
NEXT
ENDIF
ENDIF
// ===================== CURRENT SWING LEVELS =====================
// before the first swing the line sits on the close with alpha 0 (invisible)
IF hasSH = 1 THEN
plotSH = lastSH
aSH = 217
ELSE
plotSH = close
aSH = 0
ENDIF
IF hasSL = 1 THEN
plotSL = lastSL
aSL = 217
ELSE
plotSL = close
aSL = 0
ENDIF
IF showCurrentSwing = 0 THEN
aSH = 0
aSL = 0
ENDIF
RETURN plotSH COLOURED(242, 54, 69, aSH) STYLE(line, 2) AS "Current Swing High", plotSL COLOURED(0, 230, 118, aSL) STYLE(line, 2) AS "Current Swing Low"