Strategy · Pine Script v5 · On the chart

WKL — Prior Week Level Retest (Bull)

by Grahamovernightly

This strategy enters long positions when price tests and bounces off the prior week's low level within an allowed point tolerance during designated UTC trading hours.

View on GitHub

GitHub stars5on the repository
Pine versionv5runs as is
Lines of code56
Settings5inputs
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

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

WKL_prior_week_level_retest.pine
//@version=5
strategy("WKL — Prior Week 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 91.7, PF 3.23)
// DO NOT TUNE THESE WITHOUT PYTHON VALIDATION
// ═══════════════════════════════════════════════════════════════════

// Parameters
tolerance   = input.float(5.0,  "Tolerance (pts)")
stopPts     = input.float(20.0, "Stop Loss (pts)")
targetR     = input.float(2.25, "Target R-multiple")
killHour    = input.int(20,     "Kill Hour (UTC)")
fridayCutoff= input.int(20,     "Friday Cutoff Hour (UTC)")

// ═══════════════════════════════════════════════════════════════════
// PRIOR WEEK LOW
// ═══════════════════════════════════════════════════════════════════
pwLow = request.security(syminfo.tickerid, "W", low[1], lookahead=barmerge.lookahead_on)

// ═══════════════════════════════════════════════════════════════════
// SESSION FILTER (07:00-17:00 UTC)
// ═══════════════════════════════════════════════════════════════════
utcHour = hour(time, "UTC")
inSession = utcHour >= 7 and utcHour < 17
isFridayLate = dayofweek == dayofweek.friday and utcHour >= fridayCutoff

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

longCondition = nearPWLow 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("WKL_Long", strategy.long)
    strategy.exit("WKL_Exit", "WKL_Long", stop=stopPrice, limit=targetPrice)

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

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

Overview

WKL — Prior Week Level Retest (Bull) requires the bar low to approach the prior week low and the close to rebound above it while filtering out late Friday sessions. Trades are submitted with a fixed point stop loss and a take-profit target calculated as an R-multiple of the risk. It operates directly on the price chart and incorporates a time-based exit cutoff.

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

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-tradingbacktestingforexpythonquant-tradingtrading-strategies

Settings

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

SettingTypeDefaultVariable
Tolerance (pts)float5.0tolerance
Stop Loss (pts)float20.0stopPts
Target R-multiplefloat2.25targetR
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