Indicator · Pine Script v5 · On the chart

GBPUSD H1 QuadLayer

by GifariKemal· code credited to SURGE-WSI

An institutional order block and EMA pullback indicator designed for GBPUSD on the 1-hour timeframe.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code281
Settings25inputs
LicenceMIT
Last update3 days ago25 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

281 lines of Pine Script v5 from pinescript/GBPUSD_H1_QuadLayer_v69.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

GBPUSD_H1_QuadLayer_v69.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SURGE-WSI

//@version=5
indicator("GBPUSD H1 QuadLayer v6.9", shorttitle="QuadLayer v6.9", overlay=true)

// ============================================================
// INPUT PARAMETERS
// ============================================================
group_risk = "Risk Management"
riskPercent = input.float(1.0, "Risk %", minval=0.1, maxval=5.0, step=0.1, group=group_risk)
slAtrMult = input.float(1.5, "SL ATR Multiplier", minval=0.5, maxval=3.0, step=0.1, group=group_risk)
tpRatio = input.float(1.5, "TP:SL Ratio", minval=1.0, maxval=5.0, step=0.1, group=group_risk)

group_atr = "ATR Settings"
atrPeriod = input.int(14, "ATR Period", minval=5, maxval=50, group=group_atr)
minAtrPips = input.float(8.0, "Min ATR (pips)", minval=1.0, maxval=50.0, group=group_atr)
maxAtrPips = input.float(25.0, "Max ATR (pips)", minval=10.0, maxval=100.0, group=group_atr)

group_ema = "EMA Settings"
emaFast = input.int(20, "Fast EMA", minval=5, maxval=50, group=group_ema)
emaSlow = input.int(50, "Slow EMA", minval=20, maxval=200, group=group_ema)

group_entry = "Entry Signals"
useOrderBlock = input.bool(true, "Use Order Block", group=group_entry)
useEmaPullback = input.bool(true, "Use EMA Pullback", group=group_entry)
minQuality = input.float(60.0, "Min Signal Quality", minval=0, maxval=100, group=group_entry)

group_session = "Session Filter"
useSessionFilter = input.bool(true, "Enable Session Filter", group=group_session)
skipHour11 = input.bool(true, "Skip Hour 11", group=group_session)
skipOBHour8 = input.bool(true, "Skip OrderBlock Hour 8", group=group_session)
skipOBHour16 = input.bool(true, "Skip OrderBlock Hour 16", group=group_session)
skipEMAHour13 = input.bool(true, "Skip EMA Hour 13", group=group_session)
skipEMAHour14 = input.bool(true, "Skip EMA Hour 14", group=group_session)

group_time = "Trading Hours (UTC)"
londonStart = input.int(8, "London Start", minval=0, maxval=23, group=group_time)
londonEnd = input.int(10, "London End", minval=0, maxval=23, group=group_time)
nyStart = input.int(13, "New York Start", minval=0, maxval=23, group=group_time)
nyEnd = input.int(17, "New York End", minval=0, maxval=23, group=group_time)

group_visual = "Visual Settings"
showLabels = input.bool(true, "Show Signal Labels", group=group_visual)
showSLTP = input.bool(true, "Show SL/TP Lines", group=group_visual)
showEMA = input.bool(true, "Show EMA Lines", group=group_visual)
showKillZone = input.bool(true, "Show Kill Zone Background", group=group_visual)

// ============================================================
// CONSTANTS
// ============================================================
pipSize = syminfo.mintick * 10

// Day Multipliers (v6.9: Thu 0.8, Fri 0.3)
getDayMult(d) =>
    switch d
        1 => 1.0  // Monday
        2 => 0.9  // Tuesday
        3 => 1.0  // Wednesday
        4 => 0.8  // Thursday (v6.9: best day)
        5 => 0.3  // Friday (v6.9: worst day)
        => 0.0    // Weekend

// Hour Multipliers
getHourMult(h) =>
    switch h
        6 => 0.5
        7 => 0.0   // Skip
        8 => 1.0
        9 => 1.0
        10 => 0.9
        11 => 0.0  // Skip
        12 => 0.7
        13 => 1.0
        14 => 1.0
        15 => 1.0
        16 => 0.9
        17 => 0.7
        18 => 0.3
        => 0.0

// ============================================================
// INDICATORS
// ============================================================
atr = ta.atr(atrPeriod)
atrPips = atr / pipSize
ema20 = ta.ema(close, emaFast)
ema50 = ta.ema(close, emaSlow)
rsi = ta.rsi(close, 14)

// ADX Calculation
dmp = ta.rma(math.max(high - high[1], 0), 14)
dmm = ta.rma(math.max(low[1] - low, 0), 14)
tr = ta.rma(ta.tr, 14)
pdi = 100 * dmp / tr
mdi = 100 * dmm / tr
adx = 100 * ta.rma(math.abs(pdi - mdi) / (pdi + mdi), 14)

// ============================================================
// TIME FILTERS
// ============================================================
currentHour = hour(time, "UTC")
currentDay = dayofweek(time)

dayMult = getDayMult(currentDay)
hourMult = getHourMult(currentHour)

inLondon = currentHour >= londonStart and currentHour <= londonEnd
inNewYork = currentHour >= nyStart and currentHour <= nyEnd
inKillZone = inLondon or inNewYork

isValidTime = dayMult > 0 and hourMult > 0 and inKillZone
isSkipHour11 = skipHour11 and currentHour == 11
isValidSession = isValidTime and not isSkipHour11

// ============================================================
// REGIME DETECTION
// ============================================================
isBullish = close > ema20 and ema20 > ema50
isBearish = close < ema20 and ema20 < ema50
isSideways = not isBullish and not isBearish

// ============================================================
// ATR FILTER
// ============================================================
isValidATR = atrPips >= minAtrPips and atrPips <= maxAtrPips

// ============================================================
// ORDER BLOCK DETECTION
// ============================================================
bodyRatio = math.abs(close - open) / (high - low)
prevBearish = close[1] < open[1]
prevBullish = close[1] > open[1]
currBullish = close > open
currBearish = close < open

// Bullish Order Block
bullishOB = prevBearish and currBullish and bodyRatio > 0.55 and close > high[1]
// Bearish Order Block
bearishOB = prevBullish and currBearish and bodyRatio > 0.55 and close < low[1]

obQuality = bodyRatio * 100
obBuySignal = useOrderBlock and bullishOB and obQuality >= minQuality and isBullish
obSellSignal = useOrderBlock and bearishOB and obQuality >= minQuality and isBearish

// Session filter for Order Block
obBuyFiltered = obBuySignal and not (useSessionFilter and ((skipOBHour8 and currentHour == 8) or (skipOBHour16 and currentHour == 16)))
obSellFiltered = obSellSignal and not (useSessionFilter and ((skipOBHour8 and currentHour == 8) or (skipOBHour16 and currentHour == 16)))

// ============================================================
// EMA PULLBACK DETECTION
// ============================================================
atrDistance = atrPips * pipSize * 1.5

// BUY Pullback
emaBuyCondition = currBullish and close > ema20 and ema20 > ema50
emaBuyDistance = low - ema20
emaBuyPullback = emaBuyCondition and emaBuyDistance <= atrDistance and bodyRatio > 0.4 and adx > 20 and rsi > 30 and rsi < 70

// SELL Pullback
emaSellCondition = currBearish and close < ema20 and ema20 < ema50
emaSellDistance = ema20 - high
emaSellPullback = emaSellCondition and emaSellDistance <= atrDistance and bodyRatio > 0.4 and adx > 20 and rsi > 30 and rsi < 70

// Calculate EMA pullback quality
calcEmaQuality(distToEma, _adx, _rsi, _bodyRatio) =>
    touchQ = math.max(0, 30 - (distToEma / pipSize))
    adxQ = math.min(25, (_adx - 15) * 1.5)
    rsiQ = math.abs(50 - _rsi) < 20 ? 25 : 15
    bodyQ = math.min(20, _bodyRatio * 30)
    math.min(100, math.max(55, touchQ + adxQ + rsiQ + bodyQ))

emaBuyQuality = calcEmaQuality(emaBuyDistance, adx, rsi, bodyRatio)
emaSellQuality = calcEmaQuality(emaSellDistance, adx, rsi, bodyRatio)

emaBuySignal = useEmaPullback and emaBuyPullback and emaBuyQuality >= minQuality
emaSellSignal = useEmaPullback and emaSellPullback and emaSellQuality >= minQuality

// Session filter for EMA Pullback
emaBuyFiltered = emaBuySignal and not (useSessionFilter and ((skipEMAHour13 and currentHour == 13) or (skipEMAHour14 and currentHour == 14)))
emaSellFiltered = emaSellSignal and not (useSessionFilter and ((skipEMAHour13 and currentHour == 13) or (skipEMAHour14 and currentHour == 14)))

// ============================================================
// COMBINED SIGNALS
// ============================================================
buySignal = isValidSession and isValidATR and not isSideways and (obBuyFiltered or emaBuyFiltered)
sellSignal = isValidSession and isValidATR and not isSideways and (obSellFiltered or emaSellFiltered)

// Determine signal type for label
getSignalType(isOB, isEMA) =>
    isOB ? "OB" : isEMA ? "EMA" : ""

buyType = getSignalType(obBuyFiltered, emaBuyFiltered)
sellType = getSignalType(obSellFiltered, emaSellFiltered)

// ============================================================
// SL/TP CALCULATION
// ============================================================
slPips = atr * slAtrMult
tpPips = slPips * tpRatio

buySL = close - slPips
buyTP = close + tpPips
sellSL = close + slPips
sellTP = close - tpPips

// ============================================================
// PLOTTING
// ============================================================
// EMA Lines
plot(showEMA ? ema20 : na, "EMA 20", color=color.blue, linewidth=1)
plot(showEMA ? ema50 : na, "EMA 50", color=color.orange, linewidth=1)

// Kill Zone Background
bgcolor(showKillZone and inLondon ? color.new(color.blue, 95) : na, title="London Session")
bgcolor(showKillZone and inNewYork ? color.new(color.green, 95) : na, title="New York Session")

// Signal Markers
plotshape(buySignal, "Buy Signal", shape.triangleup, location.belowbar,
          color=color.green, size=size.normal, text="")
plotshape(sellSignal, "Sell Signal", shape.triangledown, location.abovebar,
          color=color.red, size=size.normal, text="")

// Signal Labels
if showLabels and buySignal
    quality = obBuyFiltered ? obQuality : emaBuyQuality
    label.new(bar_index, low, buyType + "\nQ:" + str.tostring(quality, "#") + "\nSL:" + str.tostring(slPips/pipSize, "#.#") + "p",
              color=color.green, textcolor=color.white, style=label.style_label_up, size=size.small)

if showLabels and sellSignal
    quality = obSellFiltered ? obQuality : emaSellQuality
    label.new(bar_index, high, sellType + "\nQ:" + str.tostring(quality, "#") + "\nSL:" + str.tostring(slPips/pipSize, "#.#") + "p",
              color=color.red, textcolor=color.white, style=label.style_label_down, size=size.small)

// SL/TP Lines (only on signal bars)
plot(showSLTP and buySignal ? buySL : na, "Buy SL", color=color.red, style=plot.style_circles, linewidth=2)
plot(showSLTP and buySignal ? buyTP : na, "Buy TP", color=color.green, style=plot.style_circles, linewidth=2)
plot(showSLTP and sellSignal ? sellSL : na, "Sell SL", color=color.red, style=plot.style_circles, linewidth=2)
plot(showSLTP and sellSignal ? sellTP : na, "Sell TP", color=color.green, style=plot.style_circles, linewidth=2)

// ============================================================
// INFO TABLE
// ============================================================
var table infoTable = table.new(position.top_right, 2, 10, bgcolor=color.new(color.black, 80))

if barstate.islast
    table.cell(infoTable, 0, 0, "QuadLayer v6.9", text_color=color.white, text_size=size.normal)
    table.cell(infoTable, 1, 0, "GBPUSD H1", text_color=color.yellow, text_size=size.normal)

    table.cell(infoTable, 0, 1, "ATR:", text_color=color.gray, text_size=size.small)
    table.cell(infoTable, 1, 1, str.tostring(atrPips, "#.#") + " pips", text_color=isValidATR ? color.green : color.red, text_size=size.small)

    table.cell(infoTable, 0, 2, "Regime:", text_color=color.gray, text_size=size.small)
    regimeText = isBullish ? "BULLISH" : isBearish ? "BEARISH" : "SIDEWAYS"
    regimeColor = isBullish ? color.green : isBearish ? color.red : color.gray
    table.cell(infoTable, 1, 2, regimeText, text_color=regimeColor, text_size=size.small)

    table.cell(infoTable, 0, 3, "Session:", text_color=color.gray, text_size=size.small)
    sessionText = inLondon ? "LONDON" : inNewYork ? "NEW YORK" : "OFF"
    sessionColor = inKillZone ? color.green : color.gray
    table.cell(infoTable, 1, 3, sessionText, text_color=sessionColor, text_size=size.small)

    table.cell(infoTable, 0, 4, "Day Mult:", text_color=color.gray, text_size=size.small)
    table.cell(infoTable, 1, 4, str.tostring(dayMult, "#.#"), text_color=dayMult > 0.5 ? color.green : color.orange, text_size=size.small)

    table.cell(infoTable, 0, 5, "Hour Mult:", text_color=color.gray, text_size=size.small)
    table.cell(infoTable, 1, 5, str.tostring(hourMult, "#.#"), text_color=hourMult > 0 ? color.green : color.red, text_size=size.small)

    table.cell(infoTable, 0, 6, "ADX:", text_color=color.gray, text_size=size.small)
    table.cell(infoTable, 1, 6, str.tostring(adx, "#.#"), text_color=adx > 20 ? color.green : color.orange, text_size=size.small)

    table.cell(infoTable, 0, 7, "RSI:", text_color=color.gray, text_size=size.small)
    rsiColor = rsi > 70 ? color.red : rsi < 30 ? color.green : color.white
    table.cell(infoTable, 1, 7, str.tostring(rsi, "#.#"), text_color=rsiColor, text_size=size.small)

// ============================================================
// ALERTS
// ============================================================
alertcondition(buySignal, "Buy Signal", "QuadLayer v6.9 BUY Signal on {{ticker}}")
alertcondition(sellSignal, "Sell Signal", "QuadLayer v6.9 SELL Signal on {{ticker}}")
alertcondition(buySignal or sellSignal, "Any Signal", "QuadLayer v6.9 Signal on {{ticker}}")

Overview

GBPUSD H1 QuadLayer filters trading signals based on specific London and New York session kill zones, ATR volatility thresholds, signal quality metrics, and day or hour multipliers. The script displays signal labels, projected stop-loss and take-profit levels, fast and slow EMA lines, and kill zone session backgrounds directly on the price chart to assist with trade timing.

Details

Published by

GifariKemal on GitHub

Code credit

SURGE-WSI, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

SMC / ICT / price action, Moving averages, Sessions & time, Volatility & bands

Markets

Forex

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingforexhmmictkalman-filtermetatrader5pythonquantitative-financesmart-money-conceptstrading-bot

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Risk %float1.0riskPercent
SL ATR Multiplierfloat1.5slAtrMult
TP:SL Ratiofloat1.5tpRatio
ATR Periodint14atrPeriod
Min ATR (pips)float8.0minAtrPips
Max ATR (pips)float25.0maxAtrPips
Fast EMAint20emaFast
Slow EMAint50emaSlow
Use Order BlockbooltrueuseOrderBlock
Use EMA PullbackbooltrueuseEmaPullback
Min Signal Qualityfloat60.0minQuality
Enable Session FilterbooltrueuseSessionFilter
Show all 25 settings
SettingTypeDefaultVariable
Skip Hour 11booltrueskipHour11
Skip OrderBlock Hour 8booltrueskipOBHour8
Skip OrderBlock Hour 16booltrueskipOBHour16
Skip EMA Hour 13booltrueskipEMAHour13
Skip EMA Hour 14booltrueskipEMAHour14
London Startint8londonStart
London Endint10londonEnd
New York Startint13nyStart
New York Endint17nyEnd
Show Signal LabelsbooltrueshowLabels
Show SL/TP LinesbooltrueshowSLTP
Show EMA LinesbooltrueshowEMA
Show Kill Zone BackgroundbooltrueshowKillZone
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.

Similar Pine Scripts

This indicator combines six trading tools into a single chart overlay to optimize indicator limits. It calculates Bollinger Bands, projects weekend price boundaries, plots market structure elements like order blocks, breaker blocks, and MSB lines, marks New Yo

Indicator v6 Support & resistanceSMC / ICT / price action Repaints

This indicator detects compressed corrective coils inside a higher-timeframe trend and signals when they resolve into clean directional breaks. It plots compression bands, fractal boxes, efficiency scores, and a light dashboard on the price chart. Signals clas

Indicator v6 Volatility & bandsSMC / ICT / price action
Updated yesterday · MIT GitHub repository of Compression Fractal Release [WavesUnchained]

MattSuite V3

by mmarbmatt
8 stars

MattSuite V3 is an overlay indicator that combines market-structure and trend tools on the price chart. It identifies bullish and bearish fair value gaps and estimates their strength, flags break of structure and change of character, and marks order blocks. It

Indicator v5 SMC / ICT / price actionVolatility & bands
Updated 1 year ago · None stated GitHub repository of MattSuite V3

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers