Strategy · Pine Script v6 · On the chart

Doc04 Greed Panic Scalper - Project Adapted

by Snappni

This short-only scalping strategy combines multi-timeframe analysis to identify panic selling opportunities.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code80
Settings13inputs
LicenceMIT
Last update4 months ago6 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

80 lines of Pine Script v6 from apps/server/src/pine-corpus/strategy-collection-adapted/04_贪婪恐慌情绪剥头皮_项目适配版.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

04_贪婪恐慌情绪剥头皮_项目适配版.pine
//@version=6
strategy("Doc04 Greed Panic Scalper - Project Adapted", overlay=true, pyramiding=0, initial_capital=10000)

// Source: user-provided strategy collection - strategy 4
// Logic summary:
// 1. 15m downtrend context.
// 2. Last two 15m bars should show panic selling with almost no lower wick.
// 3. Runtime chart should be 1m. Detect a lower-wick pinbar, then two large bearish bodies.
// 4. Enter short, stop above pinbar, exit by ATR target/trailing fail-safe.
// Compile confidence: 87/100. Profit confidence: 18/100.

htf = input.timeframe("15", "Panic context timeframe")
trendEmaLen = input.int(34, "15m EMA length", minval=1)
wickTolerance = input.float(0.18, "15m lower wick max ratio", minval=0.0, maxval=0.5, step=0.01)
pinbarUpperMax = input.float(0.15, "Pinbar upper wick max ratio", minval=0.0, maxval=0.5, step=0.01)
pinbarLowerMin = input.float(0.50, "Pinbar lower wick min ratio", minval=0.1, maxval=0.9, step=0.01)
pinbarBodyMax = input.float(0.35, "Pinbar body max ratio", minval=0.05, maxval=0.8, step=0.01)
setupWindowBars = input.int(5, "Bars after pinbar", minval=2)
avgBodyLen = input.int(20, "Average body length", minval=5)
bearBodyFactor = input.float(0.85, "Large bear body factor", minval=0.5, step=0.05)
atrLen = input.int(14, "ATR length", minval=1)
takeProfitR = input.float(1.4, "Take profit R", minval=0.2, step=0.1)
stopBufferAtr = input.float(0.15, "Stop buffer ATR", minval=0.0, step=0.05)
maxHoldBars = input.int(12, "Max holding bars", minval=1)

rangeSafe(h, l) =>
    math.max(h - l, syminfo.mintick)

lowerWick(o, c, l) =>
    math.min(o, c) - l

upperWick(o, c, h) =>
    h - math.max(o, c)

hOpen1 = request.security(syminfo.tickerid, htf, open[1])
hHigh1 = request.security(syminfo.tickerid, htf, high[1])
hLow1 = request.security(syminfo.tickerid, htf, low[1])
hClose1 = request.security(syminfo.tickerid, htf, close[1])
hOpen2 = request.security(syminfo.tickerid, htf, open[2])
hHigh2 = request.security(syminfo.tickerid, htf, high[2])
hLow2 = request.security(syminfo.tickerid, htf, low[2])
hClose2 = request.security(syminfo.tickerid, htf, close[2])
hEma1 = request.security(syminfo.tickerid, htf, ta.ema(close, trendEmaLen)[1])
hEma2 = request.security(syminfo.tickerid, htf, ta.ema(close, trendEmaLen)[2])

hRange1 = rangeSafe(hHigh1, hLow1)
hRange2 = rangeSafe(hHigh2, hLow2)
hBearNoLower1 = hClose1 < hOpen1 and lowerWick(hOpen1, hClose1, hLow1) / hRange1 <= wickTolerance
hBearNoLower2 = hClose2 < hOpen2 and lowerWick(hOpen2, hClose2, hLow2) / hRange2 <= wickTolerance
hDowntrend = hClose1 < hEma1 and hClose1 < hClose2
panicContext = hDowntrend and (hBearNoLower1 or hBearNoLower2)

barRange = rangeSafe(high, low)
barBody = math.abs(close - open)
upperRatio = upperWick(open, close, high) / barRange
lowerRatio = lowerWick(open, close, low) / barRange
bodyRatio = barBody / barRange
pinbar = panicContext and upperRatio <= pinbarUpperMax and lowerRatio >= pinbarLowerMin and bodyRatio <= pinbarBodyMax

avgBody = ta.sma(math.abs(close - open), avgBodyLen)
largeBear = close < open and barBody >= avgBody * bearBodyFactor
atr = ta.atr(atrLen)

recentPinbar = pinbar[1] or pinbar[2] or pinbar[3] or pinbar[4]
pinHighRef = pinbar[1] ? high[1] : pinbar[2] ? high[2] : pinbar[3] ? high[3] : high[4]
panicContinuation = panicContext and close < open and close < close[1] and (largeBear or barBody >= avgBody * 0.65)
shortSignal = strategy.position_size == 0 and recentPinbar and panicContinuation

if shortSignal
    strategy.entry("Short", strategy.short)

shortStop = pinHighRef + atr * stopBufferAtr
shortTarget = strategy.position_avg_price - (shortStop - strategy.position_avg_price) * takeProfitR

if strategy.position_size < 0
    strategy.exit("Short Risk", "Short", stop=shortStop, limit=shortTarget)

barsSinceEntry = ta.barssince(shortSignal)
if strategy.position_size < 0 and barsSinceEntry >= maxHoldBars
    strategy.close("Short")

Overview

Doc04 Greed Panic Scalper - Project Adapted uses higher-timeframe data (15-minute by default) to establish a downtrend context characterized by strong bearish candles with minimal lower wicks. On the lower timeframe chart, it triggers short positions when a specific pinbar pattern is followed by bearish continuation candles. Positions manage risk using an ATR-buffered stop loss above the pinbar, a fixed risk-reward take profit target, and a maximum bar holding limit.

Details

Published by

Snappni on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Trend, Candlestick patterns, Scalping

Markets

Any symbol

Timeframes

M1-M5, 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.

Settings

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

SettingTypeDefaultVariable
Panic context timeframetimeframe15htf
15m EMA lengthint34trendEmaLen
15m lower wick max ratiofloat0.18wickTolerance
Pinbar upper wick max ratiofloat0.15pinbarUpperMax
Pinbar lower wick min ratiofloat0.50pinbarLowerMin
Pinbar body max ratiofloat0.35pinbarBodyMax
Bars after pinbarint5setupWindowBars
Average body lengthint20avgBodyLen
Large bear body factorfloat0.85bearBodyFactor
ATR lengthint14atrLen
Take profit Rfloat1.4takeProfitR
Stop buffer ATRfloat0.15stopBufferAtr
Show all 13 settings
SettingTypeDefaultVariable
Max holding barsint12maxHoldBars
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

257 stars

This overlay strategy marks short-term turning points on the price chart and enters SPY option-style trades from them. It plots simple moving averages of highs and lows, draws up and down reversal arrows, and colors bars when a short-term extreme coincides wit

Strategy v5 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of SPY Options Trading - Alert

DI Engulfing C003

by ruckard
13 stars

This strategy trades bullish and bearish body engulfing patterns on the price chart. It allows longs only when price is above the 200-period exponential moving average and shorts only when price is below it. A long needs three consecutive red candles followed

Strategy v5 Candlestick patternsTrend
Updated 1 year ago · None stated GitHub repository of DI Engulfing C003

Pin Bar Magic v1

by Alorse
330 stars

This strategy trades price action pin bar patterns aligned with moving average trend alignment on the main price chart. It defines uptrends or downtrends using a fan arrangement of three moving averages (6 EMA, 18 EMA, and 50 SMA). Entry conditions require a b

Strategy v4 Candlestick patternsTrend
Updated 2 months ago · None stated GitHub repository of Pin Bar Magic v1
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy
106 stars

This strategy trades the three-candle strike pattern filtered by trend direction and time sessions. It calculates market regime using linear regression and exponential or smoothed moving averages to distinguish between ranging and trending conditions. Risk man

Strategy v5 Candlestick patternsTrend
Updated 2 years ago · GPL-3.0 GitHub repository of 3 Candle Strike Strategy

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