Indicator · Pine Script v6 · On the chart

Liquidity Sweep - Previous Day High and Low

by TradingSignalBot

This indicator detects stop hunts and liquidity sweeps around the previous trading day's high and low.

View on GitHub

GitHub stars19on the repository
Pine versionv6current
Lines of code471
Settings18inputs
LicenceMIT
Last update3 weeks ago2 Nov 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

471 lines of Pine Script v6 from indicators/liquidity-sweep.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

liquidity-sweep.pine
//@version=6
// This source code is subject to the terms of the MIT License (LICENSE in the source repository).
// © TradingSignalBot
//
// Liquidity sweep (a stop hunt). The levels are the previous trading day's high and low (a day
// runs 17:00 to 17:00 New York). Between 03:00 and 12:00 New York, a candle that trades above the
// high sets up a sell, below the low a buy. If a candle closes back inside the level within four
// candles of the first break (that candle included), its close is the signal; otherwise the level
// is done for the day. The stop is beyond the sweep's furthest price plus 0.1 x ATR(14); the
// targets are multiples of the stop distance. Each level once a day. Built on 15-minute candles by
// default.
indicator("Liquidity Sweep - Previous Day High and Low, Entry, Stop and Targets", shorttitle = "Liquidity Sweep", overlay = true, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500)

const string ID = "liquidity-sweep"
const string NAME = "Liquidity sweep"
const float TP1_R = 1.0
const float TP2_R = 2.0
const float TP3_R = 3.0

// ---- TSBStyle:begin ----
// Inline copy of library/TSBStyle.pine (scripts/sync-style.mjs writes it: edit the library, not this).
// @function The ink colour: panel backgrounds.
// @returns color
colInk() => #0B0B0D

// @function The grey colour: secondary text and frames.
// @returns color
colGrey() => #8A949E

// @function The entry colour.
// @returns color
colWhite() => #FFFFFF

// @function The stop colour, and sells.
// @returns color
colRed() => #E5484D

// @function The target colour, and buys.
// @returns color
colGreen() => #16A34A

// @function The colour of a strategy's levels (the opening range, a swing, the previous day's high or low).
// @returns color
colGold() => #E8B84A

// @function The colour of a session range (the Asian range) and a second indicator line.
// @returns color
colBlue() => #5B8DEF

// @function The colour of indicator marks (a trend EMA, a divergence line).
// @returns color
colViolet() => #B18CFF

// @type The drawings of one signal, deleted together once it is no longer among the newest kept.
// @field lines Its lines.
// @field labels Its labels.
// @field boxes Its boxes.
type Drawn
    array<line> lines
    array<label> labels
    array<box> boxes

// @function An empty set of drawings.
// @returns Drawn
newDrawn() =>
    Drawn.new(array.new<line>(), array.new<label>(), array.new<box>())

// @function The pip size of a symbol, by the house convention: gold one dollar, JPY pairs 0.01, other currency pairs 0.0001, anything else ten ticks.
// @param ticker The symbol's ticker (syminfo.ticker).
// @param symType The symbol's type (syminfo.type).
// @param mintick The symbol's tick (syminfo.mintick).
// @param override A pip size to use instead; 0 for automatic.
// @returns float
pipSize(string ticker, string symType, float mintick, float override) =>
    string fiat = "USD EUR GBP JPY CHF AUD NZD CAD NOK SEK DKK SGD HKD MXN ZAR PLN TRY CNH"
    bool fx = symType == "forex" or (str.length(ticker) == 6 and str.contains(fiat, str.substring(ticker, 0, 3)) and str.contains(fiat, str.substring(ticker, 3, 6)))
    float p = mintick * 10.0
    if override > 0
        p := override
    else if str.contains(ticker, "XAU")
        p := 1.0
    else if fx
        p := str.endswith(ticker, "JPY") ? 0.01 : 0.0001
    p

// @function The distance between two prices in whole pips.
// @param a A price.
// @param b Another price.
// @param pipSz The pip size (pipSize()).
// @returns int
pipsBetween(float a, float b, float pipSz) =>
    math.round(math.abs(a - b) / pipSz)

// @function A price as the chart shows it.
// @param v The price.
// @returns string
priceText(float v) =>
    str.tostring(v, format.mintick)

// @function The target multiples as a sentence: "1, 2, 3"; a target of 0 is left out.
// @param r1 TP1 in multiples of the stop distance.
// @param r2 TP2.
// @param r3 TP3, or 0.
// @returns string
rsText(float r1, float r2, float r3) =>
    string s = str.tostring(r1) + ", " + str.tostring(r2)
    if r3 > 0
        s += ", " + str.tostring(r3)
    s

// @function A target at a multiple of the stop distance, or na when the multiple is 0.
// @param isBuy True for a buy.
// @param entry The entry price.
// @param stop The stop price.
// @param r The multiple.
// @returns float
targetAt(bool isBuy, float entry, float stop, float r) =>
    float risk = math.abs(entry - stop)
    r > 0 ? (isBuy ? entry + r * risk : entry - r * risk) : na

// @function A filled tag at the right end of a level, with its text.
// @param x The bar index of the tag.
// @param y Its price.
// @param txt Its text.
// @param bg Its fill.
// @param fg Its text colour.
// @param lblSize A label size ("tiny", "small", "normal", "large").
// @returns label
levelTag(int x, float y, string txt, color bg, color fg, string lblSize) =>
    label.new(x = x, y = y, text = txt, xloc = xloc.bar_index, yloc = yloc.price, color = bg, textcolor = fg, style = label.style_label_left, size = lblSize)

// @function The entry, the stop and the targets, drawn from the signal candle, and the signal marked on it.
// @param isBuy True for a buy.
// @param entry The entry price (the signal candle's close).
// @param stop The stop price.
// @param tp1 TP1.
// @param tp2 TP2, or na.
// @param tp3 TP3, or na.
// @param x The signal candle's bar index.
// @param length How many candles the levels run to the right.
// @param name The strategy's name, for the mark on the candle.
// @param pipSz The pip size (pipSize()).
// @param lblSize A label size.
// @param anchor Where the mark sits: the candle's low for a buy, its high for a sell.
// @returns Drawn
drawSignal(bool isBuy, float entry, float stop, float tp1, float tp2, float tp3, int x, int length, string name, float pipSz, string lblSize, float anchor) =>
    Drawn d = newDrawn()
    int x2 = x + length
    string word = isBuy ? "BUY" : "SELL"
    d.lines.push(line.new(x1 = x, y1 = entry, x2 = x2, y2 = entry, xloc = xloc.bar_index, color = colWhite(), width = 2, style = line.style_solid))
    d.lines.push(line.new(x1 = x, y1 = stop, x2 = x2, y2 = stop, xloc = xloc.bar_index, color = colRed(), width = 1, style = line.style_dashed))
    d.labels.push(levelTag(x2, entry, "ENTRY · " + word + " " + priceText(entry), colWhite(), colInk(), lblSize))
    d.labels.push(levelTag(x2, stop, "STOP LOSS · " + str.tostring(pipsBetween(entry, stop, pipSz)) + " PIPS · " + priceText(stop), colRed(), colWhite(), lblSize))
    array<float> tps = array.from(tp1, tp2, tp3)
    for [k, tp] in tps
        if not na(tp)
            d.lines.push(line.new(x1 = x, y1 = tp, x2 = x2, y2 = tp, xloc = xloc.bar_index, color = colGreen(), width = 1, style = line.style_dashed))
            d.labels.push(levelTag(x2, tp, "TP" + str.tostring(k + 1) + " · +" + str.tostring(pipsBetween(entry, tp, pipSz)) + " PIPS · " + priceText(tp), colGreen(), colWhite(), lblSize))
    d.labels.push(label.new(x = x, y = anchor, text = word + " · " + name, xloc = xloc.bar_index, yloc = yloc.price, color = isBuy ? colGreen() : colRed(), textcolor = colWhite(), style = isBuy ? label.style_label_up : label.style_label_down, size = lblSize))
    d

// @function A shaded range (the opening range, the Asian range, a sweep) with its name in the corner.
// @param xLeft The first bar index.
// @param xRight The last bar index.
// @param top The range's high.
// @param bottom The range's low.
// @param col Its colour.
// @param txt Its name.
// @param lblSize A label size.
// @returns box
rangeBox(int xLeft, int xRight, float top, float bottom, color col, string txt, string lblSize) =>
    box.new(left = xLeft, top = top, right = xRight, bottom = bottom, border_color = col, border_width = 1, border_style = line.style_solid, xloc = xloc.bar_index, bgcolor = color.new(col, 85), text = txt, text_size = lblSize, text_color = col, text_halign = text.align_left, text_valign = text.align_top)

// @function A strategy's level (a swing, the previous day's high or low): a dotted line with its name at the left end.
// @param x1 The bar index it starts at.
// @param x2 The bar index it ends at.
// @param y Its price.
// @param col Its colour.
// @param txt Its name.
// @param below True to write the name under the line.
// @param lblSize A label size.
// @returns [line, label]
levelLine(int x1, int x2, float y, color col, string txt, bool below, string lblSize) =>
    line ln = line.new(x1 = x1, y1 = y, x2 = x2, y2 = y, xloc = xloc.bar_index, color = col, width = 1, style = line.style_dotted)
    label lb = label.new(x = x1, y = y, text = txt, xloc = xloc.bar_index, yloc = yloc.price, color = color.new(col, 100), textcolor = col, style = below ? label.style_label_up : label.style_label_down, size = lblSize)
    [ln, lb]

// @function A small mark on a candle (the break, the sweep, an RSI value).
// @param x The bar index.
// @param y The price.
// @param txt Its text.
// @param col Its colour.
// @param above True to put it over the price, false under it.
// @param tip The tooltip.
// @param lblSize A label size.
// @returns label
markLabel(int x, float y, string txt, color col, bool above, string tip, string lblSize) =>
    label.new(x = x, y = y, text = txt, xloc = xloc.bar_index, yloc = yloc.price, color = color.new(col, 100), textcolor = col, style = above ? label.style_label_down : label.style_label_up, size = lblSize, tooltip = tip)

// @function Deletes a signal's drawings.
// @param d The drawings.
// @returns bool
deleteDrawn(Drawn d) =>
    for ln in d.lines
        line.delete(ln)
    for lb in d.labels
        label.delete(lb)
    for bx in d.boxes
        box.delete(bx)
    true

// @function Keeps a signal's drawings, and deletes the oldest beyond the newest maxKept.
// @param list The drawings kept so far.
// @param d The new signal's drawings.
// @param maxKept How many signals to keep on the chart.
// @returns int
keepDrawn(array<Drawn> list, Drawn d, int maxKept) =>
    list.push(d)
    while list.size() > math.max(maxKept, 1)
        deleteDrawn(list.shift())
    list.size()

// @function The signal as the bot's message: side, symbol and strategy; entry, stop and targets in pips; the strategy's line; the disclaimer.
// @param isBuy True for a buy.
// @param symbol The symbol.
// @param name The strategy's name.
// @param entry The entry.
// @param stop The stop.
// @param tp1 TP1.
// @param tp2 TP2, or na.
// @param tp3 TP3, or na.
// @param pipSz The pip size.
// @param why The strategy's sentence on what happened and where the stop and targets go.
// @returns string
signalText(bool isBuy, string symbol, string name, float entry, float stop, float tp1, float tp2, float tp3, float pipSz, string why) =>
    string s = (isBuy ? "🟢 BUY " : "🔴 SELL ") + symbol + " · " + name + "\n\n"
    s += "Entry: " + priceText(entry) + " (market)\n"
    s += "Stop: " + priceText(stop) + " (" + str.tostring(pipsBetween(entry, stop, pipSz)) + " pips)\n"
    array<float> tps = array.from(tp1, tp2, tp3)
    for [k, tp] in tps
        if not na(tp)
            s += "TP" + str.tostring(k + 1) + ": " + priceText(tp) + " (+" + str.tostring(pipsBetween(entry, tp, pipSz)) + " pips)\n"
    s += "\n" + why + "\n\nNot financial advice. Trade at your own risk."
    s

// @function A string made safe to put between quotes in JSON.
// @param s The string.
// @returns string
jsonText(string s) =>
    str.replace_all(str.replace_all(str.replace_all(s, "\\", "\\\\"), "\"", "\\\""), "\n", "\\n")

// @function The signal as JSON for a webhook (the format docs/alerts.md describes).
// @param id The strategy's id ("london-breakout").
// @param isBuy True for a buy.
// @param symbol The symbol (syminfo.ticker).
// @param exchange The exchange (syminfo.prefix).
// @param tf The chart's timeframe (timeframe.period).
// @param entry The entry.
// @param stop The stop.
// @param tp1 TP1.
// @param tp2 TP2, or na.
// @param tp3 TP3, or na.
// @param barTime The signal candle's close time, in milliseconds (time_close).
// @param msg The message (signalText()).
// @param secretKey A shared secret for the webhook, or "".
// @returns string
alertJson(string id, bool isBuy, string symbol, string exchange, string tf, float entry, float stop, float tp1, float tp2, float tp3, int barTime, string msg, string secretKey) =>
    string tps = priceText(tp1)
    if not na(tp2)
        tps += "," + priceText(tp2)
    if not na(tp3)
        tps += "," + priceText(tp3)
    string j = "{\"source\":\"tv-strategies\",\"strategy\":\"" + id + "\",\"symbol\":\"" + jsonText(symbol) + "\",\"exchange\":\"" + jsonText(exchange) + "\",\"timeframe\":\"" + tf + "\""
    j += ",\"side\":\"" + (isBuy ? "buy" : "sell") + "\",\"entry\":" + priceText(entry) + ",\"stop\":" + priceText(stop) + ",\"targets\":[" + tps + "]"
    j += ",\"time\":" + str.tostring(barTime) + ",\"text\":\"" + jsonText(msg) + "\""
    if secretKey != ""
        j += ",\"secret\":\"" + jsonText(secretKey) + "\""
    j + "}"

// @function Fills the latest-signal panel: the strategy, the side and symbol, and the levels.
// @param t A table of one column and three rows.
// @param isBuy True for a buy.
// @param name The strategy's name.
// @param symbol The symbol.
// @param detail The levels in one line.
// @returns bool
heroPanel(table t, bool isBuy, string name, string symbol, string detail) =>
    table.cell(t, 0, 0, "New signal · " + name, text_color = colGrey(), text_halign = text.align_right, text_size = size.small)
    table.cell(t, 0, 1, (isBuy ? "▲ BUY  " : "▼ SELL  ") + symbol, text_color = isBuy ? colGreen() : colRed(), text_halign = text.align_right, text_size = size.large)
    table.cell(t, 0, 2, detail, text_color = colWhite(), text_halign = text.align_right, text_size = size.small)
    true

// @function Writes a notice (a timeframe the strategy cannot run on) in a one-cell table.
// @param t A table of one cell.
// @param msg The notice.
// @returns bool
notice(table t, string msg) =>
    table.cell(t, 0, 0, msg, text_color = colGold(), text_halign = text.align_left, text_size = size.small)
    true
// ---- TSBStyle:end ----

const string GRP_S = "Strategy"
const string NY = "America/New_York"
int fromH = input.int(3, "Sweeps from (New York)", minval = 0, maxval = 23, inline = "from", group = GRP_S, tooltip = "The start of the London hours.")
int fromM = input.int(0, "", minval = 0, maxval = 59, inline = "from", group = GRP_S)
int toH = input.int(12, "Sweeps until (New York)", minval = 0, maxval = 23, inline = "to", group = GRP_S, tooltip = "The end of the New York morning.")
int toM = input.int(0, "", minval = 0, maxval = 59, inline = "to", group = GRP_S)
int within = input.int(4, "Close back within (candles)", minval = 1, maxval = 50, group = GRP_S, tooltip = "Counted from the candle that first broke the level, that candle included.")
float buffer = input.float(0.1, "Stop buffer, times ATR(14)", minval = 0.0, step = 0.05, group = GRP_S, tooltip = "Added beyond the sweep's furthest price.")
int maxGapH = input.int(72, "Skip a day after a gap of more than (hours)", minval = 1, maxval = 240, group = GRP_S, tooltip = "Between the previous day's last candle and this day's first. 72, as TradingSignalBot runs it, keeps Mondays with Friday's levels and skips the day after a longer break.")
bool showLevels = input.bool(true, "Show the previous day's high and low", group = GRP_S)

// ---- common:begin ----
// Shared by every indicator in the pack: src/common.pine, copied in by scripts/sync-style.mjs.
// It expects ID, NAME, TP1_R, TP2_R and TP3_R to be declared above it.
const string GRP_T = "Entry, stop and targets"
const string GRP_D = "Drawing"
const string GRP_A = "Alerts"
float tp1R = input.float(TP1_R, "TP1, times the stop distance", minval = 0.1, step = 0.1, group = GRP_T)
float tp2R = input.float(TP2_R, "TP2, times the stop distance", minval = 0.1, step = 0.1, group = GRP_T)
float tp3R = input.float(TP3_R, "TP3, times the stop distance (0: no TP3)", minval = 0.0, step = 0.1, group = GRP_T)
int keepN = input.int(10, "Signals kept on the chart", minval = 1, maxval = 40, group = GRP_D)
int extendN = input.int(20, "Levels run for (candles)", minval = 3, maxval = 300, group = GRP_D)
string lblSize = input.string("small", "Label size", options = ["tiny", "small", "normal", "large"], group = GRP_D)
bool showHero = input.bool(true, "Latest signal panel", group = GRP_D)
float pipIn = input.float(0.0, "Pip size (0: automatic)", minval = 0.0, step = 0.0001, group = GRP_D, tooltip = "Automatic: gold 1.00, JPY pairs 0.01, other currency pairs 0.0001, anything else ten ticks.")
bool jsonAlerts = input.bool(true, "Send each signal as JSON to alert() calls", group = GRP_A, tooltip = "Create an alert on this indicator with the condition \"Any alert() function call\" to receive it.")
string secret = input.string("", "Webhook secret (optional)", group = GRP_A, tooltip = "Added to the JSON as \"secret\", for a webhook receiver that checks it. Leave empty if yours takes the secret in its address.")

float pip = pipSize(syminfo.ticker, syminfo.type, syminfo.mintick, pipIn)
bool closed = barstate.isconfirmed
bool afterGap = bar_index > 0 and time - time[1] > 86400000
var array<Drawn> drawn = array.new<Drawn>()
var table hero = table.new(position.top_right, 1, 3, bgcolor = color.new(colInk(), 10), frame_color = colGrey(), frame_width = 1)
var table note = table.new(position.bottom_right, 1, 1, bgcolor = color.new(colInk(), 10))

// What the bar signalled, for the alert conditions and the Data Window. Set where a signal fires.
bool buySig = false
bool sellSig = false
float sigEntry = na
float sigStop = na
float sigTp1 = na
float sigTp2 = na
float sigTp3 = na

// One signal at this candle's close: drawn, kept, shown in the panel and sent as JSON.
// `why` is the strategy's line for the message. Returns the drawings (for the strategy's own
// marks) and the three targets.
emit(bool isBuy, float entry, float stopPx, string why) =>
    float t1 = targetAt(isBuy, entry, stopPx, tp1R)
    float t2 = targetAt(isBuy, entry, stopPx, tp2R)
    float t3 = targetAt(isBuy, entry, stopPx, tp3R)
    Drawn d = drawSignal(isBuy, entry, stopPx, t1, t2, t3, bar_index, extendN, NAME, pip, lblSize, isBuy ? low : high)
    keepDrawn(drawn, d, keepN)
    if showHero
        heroPanel(hero, isBuy, NAME, syminfo.ticker, "Entry " + priceText(entry) + " · stop " + priceText(stopPx) + " (" + str.tostring(pipsBetween(entry, stopPx, pip)) + " pips) · TP1 " + priceText(t1))
    if jsonAlerts
        alert(alertJson(ID, isBuy, syminfo.ticker, syminfo.prefix, timeframe.period, entry, stopPx, t1, t2, t3, time_close, signalText(isBuy, syminfo.ticker, NAME, entry, stopPx, t1, t2, t3, pip, why), secret), alert.freq_once_per_bar_close)
    [d, t1, t2, t3]
// ---- common:end ----

int tfSec = timeframe.in_seconds()
bool tfOk = timeframe.isintraday and tfSec <= 3600
string tfNote = NAME + ": use an intraday chart of one hour or less (15 minutes is the default)."
int nyMin = hour(time, NY) * 60 + minute(time, NY)
int sinceBreak = (nyMin - 1020 + 1440) % 1440
int s0 = (fromH * 60 + fromM - 1020 + 1440) % 1440
int s1 = (toH * 60 + toM - 1020 + 1440) % 1440
int dayKey = year(time + 25200000, NY) * 10000 + month(time + 25200000, NY) * 100 + dayofmonth(time + 25200000, NY)
bool newDay = bar_index == 0 or dayKey != dayKey[1]
float atrV = ta.atr(14)

// A level of the previous day and where its sweep has got to.
type Level
    bool isSell = false
    float p = na
    int breachBar = na
    float ext = na
    int extBar = na
    bool done = false

// Moves a level on by this candle. True when this candle closed back inside it after a sweep.
stepLevel(Level L) =>
    bool fire = false
    if not L.done
        bool beyond = L.isSell ? high > L.p : low < L.p
        if na(L.breachBar)
            if beyond
                L.breachBar := bar_index
                L.ext := L.isSell ? high : low
                L.extBar := bar_index
        else if L.isSell ? high > L.ext : low < L.ext
            L.ext := L.isSell ? high : low
            L.extBar := bar_index
        if not na(L.breachBar)
            if L.isSell ? close < L.p : close > L.p
                L.done := true
                fire := true
            else if bar_index - L.breachBar + 1 >= within
                L.done := true
    fire

var float dHi = na
var float dLo = na
var int dN = 0
var float pdh = na
var float pdl = na
var int dayStart = na
var Level hiL = na
var Level loL = na

if closed and tfOk
    if newDay
        bool prevFull = dN >= 0.7 * 86400 / tfSec
        bool near = bar_index > 0 and time - time[1] <= maxGapH * 3600000
        pdh := dN > 0 ? dHi : na
        pdl := dN > 0 ? dLo : na
        hiL := prevFull and near ? Level.new(isSell = true, p = dHi) : na
        loL := prevFull and near ? Level.new(isSell = false, p = dLo) : na
        dayStart := bar_index
        dHi := high
        dLo := low
        dN := 1
    else
        dHi := math.max(dHi, high)
        dLo := math.min(dLo, low)
        dN += 1
    if sinceBreak >= s0 and sinceBreak < s1
        array<Level> both = array.new<Level>()
        if not na(hiL)
            both.push(hiL)
        if not na(loL)
            both.push(loL)
        for L in both
            if stepLevel(L) and not na(atrV)
                bool sell = L.isSell
                float stopPx = sell ? L.ext + buffer * atrV : L.ext - buffer * atrV
                if sell ? stopPx > close : stopPx < close
                    string word = sell ? "high" : "low"
                    string why = "Previous day's " + word + " swept and the price closed back inside. Stop beyond the sweep; targets at " + rsText(tp1R, tp2R, tp3R) + " times the stop."
                    [d, t1, t2, t3] = emit(not sell, close, stopPx, why)
                    [ln, lb] = levelLine(dayStart, bar_index + 3, L.p, colGold(), "PREVIOUS DAY'S " + str.upper(word) + " · " + priceText(L.p), not sell, lblSize)
                    d.lines.push(ln)
                    d.labels.push(lb)
                    d.labels.push(markLabel(int((dayStart + L.breachBar) / 2), L.p, sell ? "BUY STOPS" : "SELL STOPS", colGrey(), sell, "Where the stops of traders " + (sell ? "short under the high" : "long over the low") + " rest.", lblSize))
                    d.boxes.push(rangeBox(L.breachBar, bar_index, sell ? L.ext : L.p, sell ? L.p : L.ext, colRed(), "LIQUIDITY SWEEP · " + str.tostring(pipsBetween(L.p, L.ext, pip)) + " PIPS", lblSize))
                    buySig := buySig or not sell
                    sellSig := sellSig or sell
                    sigEntry := close
                    sigStop := stopPx
                    sigTp1 := t1
                    sigTp2 := t2
                    sigTp3 := t3

plot(showLevels and not newDay ? pdh : na, "Previous day's high", color = color.new(colGold(), 40), style = plot.style_linebr)
plot(showLevels and not newDay ? pdl : na, "Previous day's low", color = color.new(colGold(), 40), style = plot.style_linebr)

// ---- outputs:begin ----
// Shared by every indicator in the pack: src/outputs.pine, copied in by scripts/sync-style.mjs.
// It expects tfOk and tfNote to be declared above it.
plot(sigEntry, "Entry", color = colWhite(), display = display.data_window)
plot(sigStop, "Stop", color = colRed(), display = display.data_window)
plot(sigTp1, "TP1", color = colGreen(), display = display.data_window)
plot(sigTp2, "TP2", color = colGreen(), display = display.data_window)
plot(sigTp3, "TP3", color = colGreen(), display = display.data_window)
alertcondition(buySig, NAME + ": buy", NAME + ': BUY {{ticker}} ({{interval}}). Entry {{plot("Entry")}}, stop {{plot("Stop")}}, TP1 {{plot("TP1")}}, TP2 {{plot("TP2")}}, TP3 {{plot("TP3")}}.')
alertcondition(sellSig, NAME + ": sell", NAME + ': SELL {{ticker}} ({{interval}}). Entry {{plot("Entry")}}, stop {{plot("Stop")}}, TP1 {{plot("TP1")}}, TP2 {{plot("TP2")}}, TP3 {{plot("TP3")}}.')
alertcondition(buySig or sellSig, NAME + ": any signal", NAME + ': signal on {{ticker}} ({{interval}}). Entry {{plot("Entry")}}, stop {{plot("Stop")}}, TP1 {{plot("TP1")}}, TP2 {{plot("TP2")}}, TP3 {{plot("TP3")}}.')
if barstate.islast and not tfOk
    notice(note, tfNote)
// ---- outputs:end ----

Overview

During a user-defined New York trading window, it watches for price breaks beyond the prior day's levels followed by a close back inside within a set candle count. Upon confirmation, it overlays entry, stop loss (ATR buffer above/below the extreme), and up to three R-multiple target levels directly on the chart, complete with an optional recent signal summary dashboard.

Details

Published by

TradingSignalBot on GitHub

Draws

On the price chart

Timeframes

M15-H1, M1-M5

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

forexindicatorlondon-breakoutpine-scriptsupertrendtrading-strategytradingview

Settings

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

SettingTypeDefaultVariable
Sweeps from (New York)int3fromH
fromMint0fromM
Sweeps until (New York)int12toH
toMint0toM
Close back within (candles)int4within
Stop buffer, times ATR(14)float0.1buffer
Skip a day after a gap of more than (hours)int72maxGapH
Show the previous day's high and lowbooltrueshowLevels
TP1, times the stop distancefloatTP1_Rtp1R
TP2, times the stop distancefloatTP2_Rtp2R
TP3, times the stop distance (0: no TP3)floatTP3_Rtp3R
Signals kept on the chartint10keepN
Show all 18 settings
SettingTypeDefaultVariable
Levels run for (candles)int20extendN
Label sizestringsmalllblSize
Latest signal panelbooltrueshowHero
Pip size (0: automatic)float0.0pipIn
Send each signal as JSON to alert() callsbooltruejsonAlerts
Webhook secret (optional)stringsecret
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 tracks smart money market structure directly on the price chart. It calculates dual-period swing highs and swing lows to detect Changes of Character (CHoCH), Breaks of Structure (BOS), inducements, and liquidity sweeps. When structural levels ar

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · Apache-2.0 GitHub repository of Market Structure with Inducements & Sweeps [LuxAlgo]

Orderblocks (Nephew_Sam_)

by theonetrade
34 stars

This indicator identifies and plots bullish and bearish orderblock levels directly on the price chart based on fractal market structure breaks. It detects swing points using configurable 3-bar or 5-bar fractals, tracks breaks of closes or candle extremes, and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 2 weeks ago · MIT GitHub repository of Orderblocks (Nephew_Sam_)
28 stars

This indicator maps Smart Money Concepts (SMC) market structure directly onto the price chart. It detects internal and swing structure breaks (BOS and CHoCH), tracks bullish and bearish order blocks, identifies fair value gaps (FVG), highlights equal highs and

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints
Updated 5 weeks ago · Custom licence GitHub repository of Smart Money Concepts [LuxAlgo] Test B
13 stars

This script identifies and visualizes bullish and bearish order blocks on the price chart. It detects low-volatility consolidation ranges followed by breakout moves accompanied by high trading volume. Users can select between Simple, Relative, or Weighted volu

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · MIT GitHub repository of Advanced Order Blocks with Volume
11 stars

This indicator identifies market structure by tracking confirmed swing highs and lows using pivot points. It detects breaks of structure (BOS) and changes of character (CHoCH) when the bar close breaches the most recent unbroken swing level. Visual outputs on

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 4 weeks ago · MPL-2.0 GitHub repository of Market Structure BOS CHoCH

More SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers