Strategy · Pine Script v5 · On the chart

PDL — Prior Day Level Retest (Bull)

by Grahamovernightly

This strategy enters one long trade when the bar low comes within a set point tolerance of the prior day's low and the close finishes above that level.

View on GitHub

Repaints

GitHub stars5on the repository
Pine versionv5runs as is
Lines of code58
Settings7inputs
LicenceMIT
Last update4 months ago1 Jun 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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

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

PDL_prior_day_level_retest.pine
//@version=5
strategy("PDL — Prior Day Level Retest (Bull)", overlay=true,
     default_qty_type=strategy.percent_of_equity, default_qty_value=2,
     initial_capital=100000, commission_type=strategy.commission.cash_per_order, commission_value=0.5)

// ═══════════════════════════════════════════════════════════════════
// LOCKED BASELINE — from Python deep sweep (Rob 81.2, PF 1.97)
// DO NOT TUNE THESE WITHOUT PYTHON VALIDATION
// ═══════════════════════════════════════════════════════════════════

// Parameters
sessStart   = input.int(9,      "Session Start Hour (UTC)")
sessEnd     = input.int(18,     "Session End Hour (UTC)")
tolerance   = input.float(3.0,  "Tolerance (pts)")
stopPts     = input.float(15.0, "Stop Loss (pts)")
targetR     = input.float(2.5,  "Target R-multiple")
killHour    = input.int(20,     "Kill Hour (UTC)")
fridayCutoff= input.int(20,     "Friday Cutoff Hour (UTC)")

// ═══════════════════════════════════════════════════════════════════
// PRIOR DAY LOW
// ═══════════════════════════════════════════════════════════════════
pdLow = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)

// ═══════════════════════════════════════════════════════════════════
// SESSION FILTER
// ═══════════════════════════════════════════════════════════════════
utcHour = hour(time, "UTC")
inSession = utcHour >= sessStart and utcHour < sessEnd
isFridayLate = dayofweek == dayofweek.friday and utcHour >= fridayCutoff

// ═══════════════════════════════════════════════════════════════════
// ENTRY: Price touches prior day low and bounces (bull only)
// ═══════════════════════════════════════════════════════════════════
nearPDLow = math.abs(low - pdLow) <= tolerance
bounce    = close > pdLow + 1

longCondition = nearPDLow and bounce and inSession and not isFridayLate and strategy.position_size == 0

if longCondition
    entryPrice = close
    stopPrice  = entryPrice - stopPts
    targetPrice = entryPrice + (stopPts * targetR)
    
    strategy.entry("PDL_Long", strategy.long)
    strategy.exit("PDL_Exit", "PDL_Long", stop=stopPrice, limit=targetPrice)

// ═══════════════════════════════════════════════════════════════════
// TIME EXIT: Kill hour
// ═══════════════════════════════════════════════════════════════════
if strategy.position_size > 0 and utcHour >= killHour
    strategy.close("PDL_Long", comment="TimeExit")

// ═══════════════════════════════════════════════════════════════════
// VISUAL
// ═══════════════════════════════════════════════════════════════════
plot(pdLow, "Prior Day Low", color=color.new(color.orange, 30), linewidth=2, style=plot.style_stepline)
plotshape(longCondition, "Entry", shape.triangleup, location.belowbar, color.green, size=size.small)

Overview

Entries are allowed only inside a UTC session and are blocked after a Friday cutoff hour. It stays flat until the position closes. A stop is placed a fixed number of points below the entry close, and a limit sits at a chosen R multiple of that distance. Position size defaults to two percent of equity. It draws on the price chart.

Details

Published by

Grahamovernightly on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Support & resistance, Mean reversion, Sessions & time

Markets

Forex, Gold

Timeframes

M15-H1

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Topics

algorithmic-tradingbacktestingforexpythonquant-tradingtrading-strategies

Settings

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

SettingTypeDefaultVariable
Session Start Hour (UTC)int9sessStart
Session End Hour (UTC)int18sessEnd
Tolerance (pts)float3.0tolerance
Stop Loss (pts)float15.0stopPts
Target R-multiplefloat2.5targetR
Kill Hour (UTC)int20killHour
Friday Cutoff Hour (UTC)int20fridayCutoff
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

3C QFL Mean Reversal

by hasnocool
106 stars

3C QFL Mean Reversal is a strategy based on the Quickfinger Luc (QFL) trading methodology. It identifies breakdown buying opportunities below established price base levels and enters mean-reversion trades. The strategy includes multi-safety order DCA scaling,

Strategy v5 Mean reversionSupport & resistance Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 3C QFL Mean Reversal
330 stars

This strategy divides a fixed price range between an upper and a lower limit into equally spaced grid levels and plots them on the price chart. It marks a buy when price crosses down through a grid and a sell when price crosses up through a grid, using either

Strategy v5 Support & resistanceMean reversion Repaints
Updated 2 months ago · None stated GitHub repository of Grid Bot Simulator [Alorse]

This strategy builds a spot grid between user-set high and low prices and draws it on the price chart. It splits that range into ten levels and places up to five long limit orders at the lower levels, sizing each from current equity. Orders already below price

Strategy v6 Support & resistanceMean reversion Repaints
Updated 6 weeks ago · None stated GitHub repository of Grid Spot Trading Algorithm [The Quant Science]

ATOM 1m scalp HK

by dearvn
43 stars

This overlay strategy targets one-minute ATOM scalps. It tracks pivot highs and lows as resistance and support, compares a three-period EMA with a multi-stage smoothed close, and flags long or short when price crosses that curve in the matching direction. Dail

Strategy v5 ScalpingSupport & resistance Repaints
Updated 2 years ago · None stated GitHub repository of ATOM 1m scalp HK

P404 Smoke

by Musyimi97
16 stars

P404 Smoke is a price-chart strategy that sequences an optional higher-timeframe EMA bias, a liquidity range from recent pivots, a sweep of buy-side or sell-side liquidity, and a market structure shift within a set bar window. Comments state it then looks for

Strategy v5 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · MIT GitHub repository of P404 Smoke

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers