//@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.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Panic context timeframe
timeframe
15
htf
15m EMA length
int
34
trendEmaLen
15m lower wick max ratio
float
0.18
wickTolerance
Pinbar upper wick max ratio
float
0.15
pinbarUpperMax
Pinbar lower wick min ratio
float
0.50
pinbarLowerMin
Pinbar body max ratio
float
0.35
pinbarBodyMax
Bars after pinbar
int
5
setupWindowBars
Average body length
int
20
avgBodyLen
Large bear body factor
float
0.85
bearBodyFactor
ATR length
int
14
atrLen
Take profit R
float
1.4
takeProfitR
Stop buffer ATR
float
0.15
stopBufferAtr
Show all 13 settings
Setting
Type
Default
Variable
Max holding bars
int
12
maxHoldBars
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.
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
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
This strategy shorts the ES three-minute chart when three consecutive down candles form a triple-red pattern and price is above a Tillson-style T3 average. The average is six nested EMAs of close, combined with fixed coefficients and a user length defaulting t
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
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
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