Strategy · Pine Script v6 · On the chart

Linda Raschke Setup [JR]

by jayadevrana

This strategy implements Linda Raschke's classic trend pullback setup.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code98
Settings13inputs
LicenceMPL-2.0
Last update2 days ago26 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 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

98 lines of Pine Script v6 from scripts/linda-raschke-holy-grail.pine.txt, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

linda-raschke-holy-grail.pine.txt
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © JayadevRana
//@version=6
// Linda Bradford Raschke — the "Holy Grail" setup from Street Smarts (Raschke & Connors, 1995):
// a strong trend (ADX above 30, +DI above -DI for longs) pulls back to the 20 EMA; buy stop above the high
// of the bar that touched the EMA, stop below the pullback low, target the recent swing high.
// Defaults = the one setting that held on hourly Bank Nifty 2021-2026 after training on 2015-2020 (ADX 35, 10 EMA, trailing exit, long only);
// the textbook values are ADX 30, 20 EMA, swing target, both directions.
strategy("Holy Grail (Linda Raschke) [JR]", shorttitle = "Holy Grail", overlay = true,
     initial_capital = 100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100,
     commission_type = strategy.commission.percent, commission_value = 0.02, slippage = 2,
     margin_long = 0, margin_short = 0, process_orders_on_close = false, pyramiding = 0)

G1 = "1 · Trend strength"
adxLen = input.int(14, "ADX / DMI length", minval = 5, group = G1)
adxMin = input.float(35, "ADX must be above", minval = 10, step = 1, group = G1)
adxRising = input.bool(false, "ADX must be rising at the setup", group = G1)
G2 = "2 · Pullback and entry"
emaLen  = input.int(10, "EMA length", minval = 5, group = G2)
touchPct = input.float(0.0, "Touch tolerance (% of price)", minval = 0, step = 0.05, group = G2)
armBars = input.int(3, "Buy stop stays live for N bars", minval = 1, maxval = 10, group = G2)
dirMode = input.string("Long only", "Direction", options = ["Both", "Long only", "Short only"], group = G2)
G3 = "3 · Exit"
tpMode  = input.string("Trail EMA", "Target", options = ["Swing high/low", "Risk multiple", "Trail EMA"], group = G3)
swingN  = input.int(20, "Swing lookback (bars)", minval = 5, group = G3)
rr      = input.float(2.0, "Risk multiple (R)", minval = 0.5, step = 0.25, group = G3)
G4 = "4 · Test window"
fromT = input.time(timestamp("2000-01-01T00:00:00"), "Trade from", group = G4)
toT   = input.time(timestamp("2100-01-01T00:00:00"), "Trade until", group = G4)
showLv = input.bool(true, "Show EMA and setups", group = G4)

inWin = time >= fromT and time <= toT
[diPlus, diMinus, adx] = ta.dmi(adxLen, adxLen)
ema = ta.ema(close, emaLen)
tol = close * touchPct / 100
strong  = adx > adxMin and (not adxRising or adx > adx[1])
setupL  = dirMode != "Short only" and strong and diPlus > diMinus and low <= ema + tol and close >= ema - 2 * tol
setupS  = dirMode != "Long only"  and strong and diMinus > diPlus and high >= ema - tol and close <= ema + 2 * tol

lo3 = ta.lowest(low, 3)
hi3 = ta.highest(high, 3)
swHi = ta.highest(high, swingN)
swLo = ta.lowest(low, swingN)
var float trigL = na
var float stopL = na
var float tgtL = na
var int   armL = 0
var float trigS = na
var float stopS = na
var float tgtS = na
var int   armS = 0
if setupL
    trigL := high
    stopL := lo3
    tgtL := swHi
    armL := armBars
if setupS
    trigS := low
    stopS := hi3
    tgtS := swLo
    armS := armBars

flat = strategy.position_size == 0
strategy.cancel_all()
if flat and inWin
    if armL > 0
        strategy.entry("HG L", strategy.long, stop = trigL + syminfo.mintick)
    if armS > 0
        strategy.entry("HG S", strategy.short, stop = trigS - syminfo.mintick)
armL := math.max(armL - 1, 0)
armS := math.max(armS - 1, 0)

var float sl = na
var float tp = na
if strategy.position_size > 0 and strategy.position_size[1] <= 0
    sl := stopL
    risk = strategy.position_avg_price - sl
    tp := tpMode == "Risk multiple" ? strategy.position_avg_price + rr * risk : tpMode == "Swing high/low" ? math.max(tgtL, strategy.position_avg_price + risk) : na
if strategy.position_size < 0 and strategy.position_size[1] >= 0
    sl := stopS
    risk = sl - strategy.position_avg_price
    tp := tpMode == "Risk multiple" ? strategy.position_avg_price - rr * risk : tpMode == "Swing high/low" ? math.min(tgtS, strategy.position_avg_price - risk) : na
if strategy.position_size > 0
    if tpMode == "Trail EMA"
        sl := math.max(sl, ema - tol)
    strategy.exit("HG L x", "HG L", stop = sl, limit = tpMode == "Trail EMA" ? na : tp)
if strategy.position_size < 0
    if tpMode == "Trail EMA"
        sl := math.min(sl, ema + tol)
    strategy.exit("HG S x", "HG S", stop = sl, limit = tpMode == "Trail EMA" ? na : tp)
if not inWin and not flat
    strategy.close_all(comment = "window end")

plot(showLv ? ema : na, "20 EMA", color.new(color.orange, 0), 2)
plotshape(showLv and setupL, "Long setup", shape.triangleup, location.belowbar, color.new(color.teal, 0), size = size.tiny)
plotshape(showLv and setupS, "Short setup", shape.triangledown, location.abovebar, color.new(color.red, 0), size = size.tiny)
plot(strategy.position_size != 0 ? sl : na, "Stop", color.new(color.red, 0), 2, plot.style_linebr)
plot(strategy.position_size != 0 ? tp : na, "Target", color.new(color.teal, 0), 2, plot.style_linebr)

Overview

Linda Raschke Setup [JR] measures market trend strength using the ADX indicator and identifies pullbacks to an Exponential Moving Average (EMA). When ADX exceeds a specified threshold and price touches the EMA, a pending stop order is armed above the setup candle high for longs or below for shorts. Positions use a stop loss based on recent swing extremes and exit via trailing EMA, fixed risk multiples, or recent swing highs and lows. Inputs allow customization of ADX thresholds, EMA lengths, and direction filters. It plots directly on the main price chart.

Details

Published by

jayadevrana on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Trend, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

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-tradingbacktestingema-crossoverpine-scriptpine-script-v6pinescriptrsitechnical-analysistrading-automationtrading-indicators

Settings

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

SettingTypeDefaultVariable
ADX / DMI lengthint14adxLen
ADX must be abovefloat35adxMin
ADX must be rising at the setupboolfalseadxRising
EMA lengthint10emaLen
Touch tolerance (% of price)float0.0touchPct
Buy stop stays live for N barsint3armBars
DirectionstringLong onlydirMode
TargetstringTrail EMAtpMode
Swing lookback (bars)int20swingN
Risk multiple (R)float2.0rr
Trade fromtimetimestamp("2000-01-01T00:00:00")fromT
Trade untiltimetimestamp("2100-01-01T00:00:00")toT
Show all 13 settings
SettingTypeDefaultVariable
Show EMA and setupsbooltrueshowLv
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

Doge SMA

by hackingthemarkets
474 stars

Doge SMA is a long-only moving-average crossover strategy drawn on the price chart. It calculates a fast and a slow simple moving average of close and enters a long position when the fast average crosses above the slow average, but only inside a user-defined s

Strategy v4 TrendMoving averages
Updated 4 years ago · None stated GitHub repository of Doge SMA

This strategy calculates and plots a fast Exponential Moving Average (EMA) and a slow EMA directly on the main price chart. It enters long trades when the fast EMA crosses above the slow EMA and exits when the fast EMA crosses below the slow EMA. Inputs allow

Strategy v6 TrendMoving averages
Updated today · AGPL-3.0 GitHub repository of Forven S01508 — Simple EMA20/50 Cross
330 stars

2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the

Strategy v4 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of 2 EMA/SMA + RSI Strategy [Alorse]

Acrypto - Weighted Strategy

by AlbertoCuadra
318 stars

This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy
257 stars

This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross

Strategy v5 TrendSupport & resistance Repaints
Updated 6 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar

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