3CandleWarEng is an overlay indicator that identifies three-candle price pattern setups alongside integrated order block detection and a moving average trend filter.
//@version=6
indicator("3CandleWarEng", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=500)
// ============================================================
// INPUT
// ============================================================
grpLines = "C1 Lines"
showLines = input.bool(true, "Show C1 High/Low lines", group=grpLines)
maxHistory = input.int(50, "Confirmed setups (C1-C2-C3 completed) to keep on chart", minval=5, maxval=200, group=grpLines)
lineColor = input.color(color.new(color.gray, 60), "Line color (C1 waiting for C2)", group=grpLines)
setupColor = input.color(color.new(color.fuchsia, 0), "Line color (C2 valid, waiting for C3)", group=grpLines)
grpSig = "Pattern Signals"
showBuy = input.bool(true, "Show BUY signals", group=grpSig)
showSell = input.bool(true, "Show SELL signals (mirrored)", group=grpSig)
buyColor = input.color(color.yellow, "Buy star color", group=grpSig)
sellColor = input.color(color.red, "Sell star color", group=grpSig)
closeToleranceATR = input.float(0.01, "C3 close tolerance vs C1 (in ATR, 0 = clean close)", minval=0, step=0.01, group=grpSig)
grpMA = "Moving Average Filter"
useMaFilter = input.bool(true, "Enable trend filter with moving average", group=grpMA)
maTF = input.timeframe("5", "MA timeframe", group=grpMA)
maLen = input.int(20, "SMA period", minval=1, group=grpMA)
maSrc = input.source(close, "Source", group=grpMA)
showMaPlot = input.bool(true, "Show MA on chart", group=grpMA)
maDynamicColor = input.bool(true, "Dynamic MA color based on trend", group=grpMA)
maColorUp = input.color(color.lime, "MA color (price above)", group=grpMA)
maColorDown = input.color(color.red, "MA color (price below)", group=grpMA)
maColorFlat = input.color(color.aqua, "MA color (fixed, if dynamic off)", group=grpMA)
grpOB = "Order Block"
obEnable = input.bool(true, "Enable Order Block detection", group=grpOB)
showObBoxes = input.bool(true, "Show Order Block boxes on chart", group=grpOB)
obRealtimeDraw = input.bool(true, "Draw OB on forming candle too (repainting)", group=grpOB)
useDisplacement = input.bool(true, "Require displacement (strong breakout)", group=grpOB)
atrLen = input.int(14, "ATR period (displacement)", minval=1, group=grpOB)
dispMult = input.float(1.2, "ATR multiplier for displacement", minval=0.1, step=0.1, group=grpOB)
obBoxCount = input.int(5, "Max OB per side on chart", minval=1, maxval=20, group=grpOB)
obMitigateOnClose = input.bool(true, "Mitigation on close (otherwise on wick)", group=grpOB)
obProximityATR = input.float(0.5, "'Nearby' margin (in ATR)", minval=0, step=0.1, group=grpOB)
obBypassMaOnTouch = input.bool(true, "Bypass MA filter if C1 or C2 touch a matching OB", group=grpOB)
obBorderTransp = input.int(70, "OB border transparency (0 = solid, 100 = invisible)", minval=0, maxval=100, group=grpOB)
bullObColor = input.color(color.new(color.teal, 80), "Bullish OB box color", group=grpOB)
bearObColor = input.color(color.new(color.orange, 80), "Bearish OB box color", group=grpOB)
warnColor = input.color(color.new(color.fuchsia, 0), "Warning label color (opposite OB)", group=grpOB)
grpTouch = "OB Touch Label"
showOBTouchLabel = input.bool(true, "Show 'OB' only on first touch of an important Order Block", group=grpTouch)
obTouchMinSizeATR = input.float(1.0, "Minimum OB size to be 'important' (in ATR)", minval=0, step=0.1, group=grpTouch)
obTouchMaxLabels = input.int(100, "Max OB Touch labels on chart", minval=5, maxval=500, group=grpTouch)
grpTrade = "Trade Levels (SL/TP)"
showTradeBox = input.bool(true, "Draw SL/TP boxes on confirmed signal", group=grpTrade)
rrRatio = input.float(2.0, "Take Profit ratio (R:R)", minval=0.5, step=0.5, group=grpTrade)
minAtrStopMult = input.float(0.5, "Minimum SL distance beyond C1 (in ATR)", minval=0, step=0.1, group=grpTrade)
tradeBoxBars = input.int(30, "Box extension to the right (bars)", minval=1, group=grpTrade)
maxTradeBoxes = input.int(10, "Max trade boxes on chart", minval=1, maxval=50, group=grpTrade)
tpBoxColor = input.color(color.new(color.green, 85), "Take Profit box color", group=grpTrade)
slBoxColor = input.color(color.new(color.red, 85), "Stop Loss box color", group=grpTrade)
tradeBorderTransp = input.int(40, "SL/TP box border transparency (0 = solid, 100 = invisible)", minval=0, maxval=100, group=grpTrade)
entryLineColor = input.color(color.new(color.white, 20), "Entry line color", group=grpTrade)
showTradeLabel = input.bool(false, "Show Entry/SL/TP label", group=grpTrade)
grpDbg = "Debug"
dbgOB = input.bool(false, "Debug: show OB touch state on C1/C2 and C3 tolerance", group=grpDbg)
// ============================================================
// STATE
// ============================================================
var int state = 0
var float c1High = na
var float c1Low = na
var line c1HiLine = na
var line c1LoLine = na
var bool isBuySetup = false
var bool isSellSetup = false
// Flag: C1 or C2 touched a matching OB
var bool c1c2TouchedBullOB = false
var bool c1c2TouchedBearOB = false
// OB anti-duplicate per bar
var int lastBullOBBar = -1
var int lastBearOBBar = -1
var line[] histHi = array.new_line()
var line[] histLo = array.new_line()
// Trade levels (SL/TP)
var box[] tpBoxes = array.new_box()
var box[] slBoxes = array.new_box()
var line[] entryLines = array.new_line()
var label[] rrLabels = array.new_label()
// "OB" label on first important touch
var label[] obTouchLabels = array.new_label()
// reset every bar
buySignal = false
sellSignal = false
buyNearOB = false
sellNearOB = false
buyWarnOB = false
sellWarnOB = false
// ============================================================
// MOVING AVERAGE ON CUSTOM TIMEFRAME (trend filter) + dynamic color
// ============================================================
maValue = request.security(syminfo.tickerid, maTF, ta.sma(maSrc, maLen), lookahead=barmerge.lookahead_off)
maPlotColor = maDynamicColor ? (close > maValue ? maColorUp : close < maValue ? maColorDown : maColorFlat) : maColorFlat
plot(showMaPlot ? maValue : na, title="SMA Filter", color=maPlotColor, linewidth=2)
aboveMa = not useMaFilter or close > maValue
belowMa = not useMaFilter or close < maValue
// ============================================================
// ORDER BLOCK: data structures
// ============================================================
var box[] bullBoxes = array.new_box()
var float[] bullTop = array.new_float()
var float[] bullBottom = array.new_float()
var bool[] bullTouched = array.new_bool()
var box[] bearBoxes = array.new_box()
var float[] bearTop = array.new_float()
var float[] bearBottom = array.new_float()
var bool[] bearTouched = array.new_bool()
atrVal = ta.atr(atrLen)
// ============================================================
// ORDER BLOCK: mitigation (confirmed bars only)
// ============================================================
if barstate.isconfirmed and obEnable
if array.size(bullBoxes) > 0
for i = array.size(bullBoxes) - 1 to 0
bx = array.get(bullBoxes, i)
bot = array.get(bullBottom, i)
box.set_right(bx, bar_index)
mitigated = obMitigateOnClose ? close < bot : low < bot
if mitigated
box.delete(bx)
array.remove(bullBoxes, i)
array.remove(bullTop, i)
array.remove(bullBottom, i)
array.remove(bullTouched, i)
if array.size(bearBoxes) > 0
for i = array.size(bearBoxes) - 1 to 0
bx = array.get(bearBoxes, i)
top = array.get(bearTop, i)
box.set_right(bx, bar_index)
mitigated = obMitigateOnClose ? close > top : high > top
if mitigated
box.delete(bx)
array.remove(bearBoxes, i)
array.remove(bearTop, i)
array.remove(bearBottom, i)
array.remove(bearTouched, i)
// ============================================================
// ORDER BLOCK: creation (real-time or confirmed bar only)
// ============================================================
if obEnable and (obRealtimeDraw or barstate.isconfirmed)
// --- Bullish OB ---
bullishOB = close[1] < open[1] and close > high[1] and (not useDisplacement or (close - open) > atrVal * dispMult)
if bullishOB and bar_index != lastBullOBBar
obTop = high[1]
obBot = low[1]
newBoxBull = box.new(left=bar_index[1], top=obTop, right=bar_index, bottom=obBot, border_color=color.new(bullObColor, obBorderTransp), bgcolor=showObBoxes ? bullObColor : na)
array.push(bullBoxes, newBoxBull)
array.push(bullTop, obTop)
array.push(bullBottom, obBot)
array.push(bullTouched, false)
lastBullOBBar := bar_index
if array.size(bullBoxes) > obBoxCount
box.delete(array.shift(bullBoxes))
array.shift(bullTop)
array.shift(bullBottom)
array.shift(bullTouched)
// --- Bearish OB ---
bearishOB = close[1] > open[1] and close < low[1] and (not useDisplacement or (open - close) > atrVal * dispMult)
if bearishOB and bar_index != lastBearOBBar
obTop = high[1]
obBot = low[1]
newBoxBear = box.new(left=bar_index[1], top=obTop, right=bar_index, bottom=obBot, border_color=color.new(bearObColor, obBorderTransp), bgcolor=showObBoxes ? bearObColor : na)
array.push(bearBoxes, newBoxBear)
array.push(bearTop, obTop)
array.push(bearBottom, obBot)
array.push(bearTouched, false)
lastBearOBBar := bar_index
if array.size(bearBoxes) > obBoxCount
box.delete(array.shift(bearBoxes))
array.shift(bearTop)
array.shift(bearBottom)
array.shift(bearTouched)
// ============================================================
// OB CHECK FUNCTIONS
// ============================================================
// Check if a price (px) is inside or near an OB box
f_nearAnyBox(tops, bottoms, px, margin) =>
bool found = false
if array.size(tops) > 0
for i = 0 to array.size(tops) - 1
t = array.get(tops, i)
b = array.get(bottoms, i)
if px <= t + margin and px >= b - margin
found := true
found
// Check if the [lo, hi] range of a candle overlaps an OB box
f_overlapsAnyBox(tops, bottoms, lo, hi, margin) =>
bool found = false
if array.size(tops) > 0
for i = 0 to array.size(tops) - 1
t = array.get(tops, i)
b = array.get(bottoms, i)
if hi >= b - margin and lo <= t + margin
found := true
found
// Check the FIRST touch on "important" OBs (size >= ATR threshold) and mark the box as already signalled
f_checkImportantTouch(tops, bottoms, touched, lo, hi, minSizeATR, atrV) =>
bool anyNewTouch = false
if array.size(tops) > 0
for i = 0 to array.size(tops) - 1
already = array.get(touched, i)
if not already
t = array.get(tops, i)
b = array.get(bottoms, i)
sizeOK = (t - b) >= atrV * minSizeATR
overlap = hi >= b and lo <= t
if sizeOK and overlap
array.set(touched, i, true)
anyNewTouch := true
anyNewTouch
// ============================================================
// "OB" LABEL ONLY ON FIRST TOUCH OF AN IMPORTANT OB
// ============================================================
if showOBTouchLabel and obEnable and showObBoxes
newBullTouch = f_checkImportantTouch(bullTop, bullBottom, bullTouched, low, high, obTouchMinSizeATR, atrVal)
newBearTouch = f_checkImportantTouch(bearTop, bearBottom, bearTouched, low, high, obTouchMinSizeATR, atrVal)
if newBullTouch or newBearTouch
obTouchLbl = label.new(bar_index, high, text="OB", style=label.style_label_down,
color=color.new(color.white, 100), textcolor=color.white, size=size.tiny)
array.push(obTouchLabels, obTouchLbl)
if array.size(obTouchLabels) > obTouchMaxLabels
label.delete(array.shift(obTouchLabels))
// ============================================================
// TRADE DRAWING FUNCTION (SL/TP boxes + entry line + R:R label)
// ============================================================
f_drawTrade(isLong, entryPx, slPx) =>
riskDist = math.abs(entryPx - slPx)
tpPx = isLong ? entryPx + riskDist * rrRatio : entryPx - riskDist * rrRatio
boxRight = bar_index + tradeBoxBars
tBox = box.new(left=bar_index, top=isLong ? tpPx : entryPx, right=boxRight,
bottom=isLong ? entryPx : tpPx, border_color=color.new(color.green, tradeBorderTransp), bgcolor=tpBoxColor)
sBox = box.new(left=bar_index, top=isLong ? entryPx : slPx, right=boxRight,
bottom=isLong ? slPx : entryPx, border_color=color.new(color.red, tradeBorderTransp), bgcolor=slBoxColor)
eLine = line.new(bar_index, entryPx, boxRight, entryPx, color=entryLineColor, width=1, style=line.style_dashed)
rrTxt = "Entry: " + str.tostring(entryPx, "#.#####") + "\nSL: " + str.tostring(slPx, "#.#####") +
"\nTP: " + str.tostring(tpPx, "#.#####") + "\nR:R = 1:" + str.tostring(rrRatio, "#.#")
lbl = label.new(boxRight, entryPx, text=rrTxt, style=label.style_label_left,
color=color.new(color.black, 100),
textcolor=showTradeLabel ? color.white : color.new(color.white, 100),
size=size.tiny)
array.push(tpBoxes, tBox)
array.push(slBoxes, sBox)
array.push(entryLines, eLine)
array.push(rrLabels, lbl)
if array.size(tpBoxes) > maxTradeBoxes
box.delete(array.shift(tpBoxes))
box.delete(array.shift(slBoxes))
line.delete(array.shift(entryLines))
label.delete(array.shift(rrLabels))
// ============================================================
// REAL-TIME CHECK (every tick, not only on confirmed bar)
// ============================================================
if state == 2
margin = atrVal * obProximityATR
tolC3 = atrVal * closeToleranceATR
buyBase = isBuySetup and low >= c1Low and high >= c1High and close > c1High - tolC3
sellBase = isSellSetup and high <= c1High and low <= c1Low and close < c1Low + tolC3
buyNearOBcheck = obEnable and buyBase and f_nearAnyBox(bullTop, bullBottom, close, margin)
sellNearOBcheck = obEnable and sellBase and f_nearAnyBox(bearTop, bearBottom, close, margin)
buyWarnOBcheck = obEnable and buyBase and f_nearAnyBox(bearTop, bearBottom, close, margin)
sellWarnOBcheck = obEnable and sellBase and f_nearAnyBox(bullTop, bullBottom, close, margin)
buyBypassMa = obEnable and obBypassMaOnTouch and c1c2TouchedBullOB
sellBypassMa = obEnable and obBypassMaOnTouch and c1c2TouchedBearOB
buyConfirm = buyBase and (aboveMa or buyNearOBcheck or buyBypassMa)
sellConfirm = sellBase and (belowMa or sellNearOBcheck or sellBypassMa)
if buyConfirm and showBuy
buySignal := true
buyNearOB := buyNearOBcheck
buyWarnOB := buyWarnOBcheck
if sellConfirm and showSell
sellSignal := true
sellNearOB := sellNearOBcheck
sellWarnOB := sellWarnOBcheck
// ============================================================
// STATEFUL LOGIC (confirmed bar only)
// ============================================================
if barstate.isconfirmed
if state == 0
c1High := high
c1Low := low
c1c2TouchedBullOB := false
c1c2TouchedBearOB := false
if obEnable
marginC1 = atrVal * obProximityATR
if f_overlapsAnyBox(bullTop, bullBottom, low, high, marginC1)
c1c2TouchedBullOB := true
if f_overlapsAnyBox(bearTop, bearBottom, low, high, marginC1)
c1c2TouchedBearOB := true
if showLines
c1HiLine := line.new(bar_index, high, bar_index + 2, high, xloc=xloc.bar_index, color=lineColor, width=1)
c1LoLine := line.new(bar_index, low, bar_index + 2, low, xloc=xloc.bar_index, color=lineColor, width=1)
state := 1
else if state == 1
brokeDown = low < c1Low
brokeUp = high > c1High
reclaimed = close >= c1Low and close <= c1High
buySetup = brokeDown and not brokeUp and reclaimed
sellSetup = brokeUp and not brokeDown and reclaimed
if obEnable and (buySetup or sellSetup)
marginC2 = atrVal * obProximityATR
if f_overlapsAnyBox(bullTop, bullBottom, low, high, marginC2)
c1c2TouchedBullOB := true
if f_overlapsAnyBox(bearTop, bearBottom, low, high, marginC2)
c1c2TouchedBearOB := true
if buySetup or sellSetup
isBuySetup := buySetup
isSellSetup := sellSetup
if showLines and not na(c1HiLine)
line.set_color(c1HiLine, setupColor)
line.set_color(c1LoLine, setupColor)
state := 2
else
if not na(c1HiLine)
line.delete(c1HiLine)
line.delete(c1LoLine)
c1High := high
c1Low := low
c1c2TouchedBullOB := false
c1c2TouchedBearOB := false
if obEnable
marginC1 = atrVal * obProximityATR
if f_overlapsAnyBox(bullTop, bullBottom, low, high, marginC1)
c1c2TouchedBullOB := true
if f_overlapsAnyBox(bearTop, bearBottom, low, high, marginC1)
c1c2TouchedBearOB := true
if showLines
c1HiLine := line.new(bar_index, high, bar_index + 2, high, xloc=xloc.bar_index, color=lineColor, width=1)
c1LoLine := line.new(bar_index, low, bar_index + 2, low, xloc=xloc.bar_index, color=lineColor, width=1)
else
c1HiLine := na
c1LoLine := na
state := 1
else if state == 2
margin = atrVal * obProximityATR
tolC3F = atrVal * closeToleranceATR
buyBaseFinal = isBuySetup and low >= c1Low and high >= c1High and close > c1High - tolC3F
sellBaseFinal = isSellSetup and high <= c1High and low <= c1Low and close < c1Low + tolC3F
buyNearOBFinal = obEnable and buyBaseFinal and f_nearAnyBox(bullTop, bullBottom, close, margin)
sellNearOBFinal = obEnable and sellBaseFinal and f_nearAnyBox(bearTop, bearBottom, close, margin)
buyBypassMaFinal = obEnable and obBypassMaOnTouch and c1c2TouchedBullOB
sellBypassMaFinal = obEnable and obBypassMaOnTouch and c1c2TouchedBearOB
buyConfirmFinal = buyBaseFinal and (aboveMa or buyNearOBFinal or buyBypassMaFinal)
sellConfirmFinal = sellBaseFinal and (belowMa or sellNearOBFinal or sellBypassMaFinal)
if dbgOB
label.new(bar_index, high,
text="C1C2 BullOB=" + str.tostring(c1c2TouchedBullOB) + "\nC1C2 BearOB=" + str.tostring(c1c2TouchedBearOB) +
"\nC1 low=" + str.tostring(c1Low, "#.#####") + " C1 high=" + str.tostring(c1High, "#.#####") +
"\nC3 low=" + str.tostring(low, "#.#####") + " close=" + str.tostring(close, "#.#####") +
"\ntol=" + str.tostring(tolC3F, "#.#####") +
"\nsellBase=" + str.tostring(sellBaseFinal) + " buyBase=" + str.tostring(buyBaseFinal) +
"\nsellConfirm=" + str.tostring(sellConfirmFinal) + " buyConfirm=" + str.tostring(buyConfirmFinal),
style=label.style_label_down, color=color.new(color.blue, 60), textcolor=color.white, size=size.tiny)
// --- Draw SL/TP on confirmed signal (non-repainting) ---
if showTradeBox and buyConfirmFinal
slPx = c1Low - atrVal * minAtrStopMult
f_drawTrade(true, close, slPx)
if showTradeBox and sellConfirmFinal
slPx = c1High + atrVal * minAtrStopMult
f_drawTrade(false, close, slPx)
if buyConfirmFinal or sellConfirmFinal
if not na(c1HiLine)
array.push(histHi, c1HiLine)
array.push(histLo, c1LoLine)
while array.size(histHi) > maxHistory
line.delete(array.shift(histHi))
line.delete(array.shift(histLo))
isBuySetup := false
isSellSetup := false
c1c2TouchedBullOB := false
c1c2TouchedBearOB := false
state := 0
else
if not na(c1HiLine)
line.delete(c1HiLine)
line.delete(c1LoLine)
isBuySetup := false
isSellSetup := false
c1High := high
c1Low := low
c1c2TouchedBullOB := false
c1c2TouchedBearOB := false
if obEnable
marginC1 = atrVal * obProximityATR
if f_overlapsAnyBox(bullTop, bullBottom, low, high, marginC1)
c1c2TouchedBullOB := true
if f_overlapsAnyBox(bearTop, bearBottom, low, high, marginC1)
c1c2TouchedBearOB := true
if showLines
c1HiLine := line.new(bar_index, high, bar_index + 2, high, xloc=xloc.bar_index, color=lineColor, width=1)
c1LoLine := line.new(bar_index, low, bar_index + 2, low, xloc=xloc.bar_index, color=lineColor, width=1)
else
c1HiLine := na
c1LoLine := na
state := 1
// ============================================================
// SIGNAL PLOT
// ============================================================
plotchar(buySignal, title="Buy Star", char="★", location=location.belowbar, color=buyColor, size=size.small)
plotchar(sellSignal, title="Sell Star", char="★", location=location.abovebar, color=sellColor, size=size.small)
if buyNearOB
label.new(bar_index, low, text="OB", style=label.style_label_up, color=color.new(bullObColor, 0), textcolor=color.white, size=size.tiny)
if sellNearOB
label.new(bar_index, high, text="OB", style=label.style_label_down, color=color.new(bearObColor, 0), textcolor=color.white, size=size.tiny)
if buyWarnOB
label.new(bar_index, high, text="⚠OB", style=label.style_label_down, color=warnColor, textcolor=color.white, size=size.tiny)
if sellWarnOB
label.new(bar_index, low, text="⚠OB", style=label.style_label_up, color=warnColor, textcolor=color.white, size=size.tiny)
if buySignal
alert("BUY confirmed on " + syminfo.ticker, alert.freq_once_per_bar)
if sellSignal
alert("SELL confirmed on " + syminfo.ticker, alert.freq_once_per_bar)
if buyNearOB
alert("BUY confirmed + Order Block confluence on " + syminfo.ticker, alert.freq_once_per_bar)
if sellNearOB
alert("SELL confirmed + Order Block confluence on " + syminfo.ticker, alert.freq_once_per_bar)
if buyWarnOB
alert("WARNING: BUY near a bearish Order Block (possible reversal) on " + syminfo.ticker, alert.freq_once_per_bar)
if sellWarnOB
alert("WARNING: SELL near a bullish Order Block (possible reversal) on " + syminfo.ticker, alert.freq_once_per_bar)
alertcondition(isBuySetup and state == 2, title="Buy Setup Pending", message="Low sweep + reclaim: waiting for C3 confirmation")
alertcondition(isSellSetup and state == 2, title="Sell Setup Pending", message="High sweep + reclaim: waiting for C3 confirmation")
alertcondition(buySignal, title="Buy Confirmed", message="C3 confirmed: BUY pattern completed")
alertcondition(sellSignal, title="Sell Confirmed", message="C3 confirmed: SELL pattern completed")
alertcondition(buyNearOB, title="Buy + Order Block", message="BUY confirmed in confluence with Order Block")
alertcondition(sellNearOB, title="Sell + Order Block", message="SELL confirmed in confluence with Order Block")
alertcondition(buyWarnOB, title="Buy - Opposite OB Warning", message="BUY near a bearish Order Block: reversal risk")
alertcondition(sellWarnOB, title="Sell - Opposite OB Warning", message="SELL near a bullish Order Block: reversal risk")
alertcondition(showOBTouchLabel, title="Important OB Touch", message="First candle touching an important Order Block")
Overview
3CandleWarEng plots reference lines for setup stages, triggers buy and sell signal stars, and highlights bullish or bearish order blocks defined by ATR displacement thresholds. Key options allow users to toggle trend filters, adjust ATR multipliers, configure order block mitigation settings, and display touch labels. The indicator can draw order blocks on the live forming bar, which repaints until the bar closes.
Three-candle pattern signal detection
Order block identification with ATR displacement filter
Moving average multi-timeframe trend filter
Order block mitigation and touch alerts
Visual chart overlay with customizable lines and boxes
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Show C1 High/Low lines
bool
true
showLines
Confirmed setups (C1-C2-C3 completed) to keep on chart
int
50
maxHistory
Line color (C1 waiting for C2)
color
color.new(color.gray, 60)
lineColor
Line color (C2 valid, waiting for C3)
color
color.new(color.fuchsia, 0)
setupColor
Show BUY signals
bool
true
showBuy
Show SELL signals (mirrored)
bool
true
showSell
Buy star color
color
color.yellow
buyColor
Sell star color
color
color.red
sellColor
C3 close tolerance vs C1 (in ATR, 0 = clean close)
float
0.01
closeToleranceATR
Enable trend filter with moving average
bool
true
useMaFilter
MA timeframe
timeframe
5
maTF
SMA period
int
20
maLen
Show all 40 settings
Setting
Type
Default
Variable
Source
source
close
maSrc
Show MA on chart
bool
true
showMaPlot
Dynamic MA color based on trend
bool
true
maDynamicColor
MA color (price above)
color
color.lime
maColorUp
MA color (price below)
color
color.red
maColorDown
MA color (fixed, if dynamic off)
color
color.aqua
maColorFlat
Enable Order Block detection
bool
true
obEnable
Show Order Block boxes on chart
bool
true
showObBoxes
Draw OB on forming candle too (repainting)
bool
true
obRealtimeDraw
Require displacement (strong breakout)
bool
true
useDisplacement
ATR period (displacement)
int
14
atrLen
ATR multiplier for displacement
float
1.2
dispMult
Max OB per side on chart
int
5
obBoxCount
Mitigation on close (otherwise on wick)
bool
true
obMitigateOnClose
'Nearby' margin (in ATR)
float
0.5
obProximityATR
Bypass MA filter if C1 or C2 touch a matching OB
bool
true
obBypassMaOnTouch
OB border transparency (0 = solid, 100 = invisible)
int
70
obBorderTransp
Bullish OB box color
color
color.new(color.teal, 80)
bullObColor
Bearish OB box color
color
color.new(color.orange, 80)
bearObColor
Warning label color (opposite OB)
color
color.new(color.fuchsia, 0)
warnColor
Show 'OB' only on first touch of an important Order Block
bool
true
showOBTouchLabel
Minimum OB size to be 'important' (in ATR)
float
1.0
obTouchMinSizeATR
Max OB Touch labels on chart
int
100
obTouchMaxLabels
Draw SL/TP boxes on confirmed signal
bool
true
showTradeBox
Take Profit ratio (R:R)
float
2.0
rrRatio
Minimum SL distance beyond C1 (in ATR)
float
0.5
minAtrStopMult
Box extension to the right (bars)
int
30
tradeBoxBars
Max trade boxes on chart
int
10
maxTradeBoxes
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This overlay indicator detects tweezer tops and bottoms and kangaroo-tail pin bars, then draws supply and demand zones from those patterns. It scores each zone, decays freshness, merges overlapping zones, and can invalidate a zone after a close-through or afte
This indicator plots Smart Money Concepts and price action components directly on the price chart. It highlights bullish and bearish order blocks, multi-timeframe pivot points, market structure swings with key Fibonacci retracement levels (0.618 and 0.786), zo
This Pine Script indicator plots Smart Money Concepts market structure directly on the price chart. It identifies swing highs and lows, internal market structures, Break of Structure events, Change of Character shifts, and EQH/EQL levels. Breaker blocs are hig
The Price Action Toolkit is an indicator that combines several price action tools on the chart. It calculates the ATR with user-defined length and shows it in a table. It plots multiple Kaufman Adaptive Moving Averages (KAMA) with different lengths and sources
This indicator plots Smart Money Concepts elements on the price chart including internal and swing order blocks, bullish and bearish structures with BOS and CHoCH breaks, fair value gaps, equal highs and lows, and swing points. It can color candles according t
This indicator plots ZigZag lines connecting swing highs and lows to map price structure. It draws candle body and shadow boxes on the price chart and detects CHoCH for potential trend shifts and BOS for continuation signals. The main setting toggles candle di