OPEN-SOURCE SCRIPT

GStrategy 1000Pepe 15m

601
Trend Following Candlestick Strategy with EMA Filter and Exit Delay

Strategy Concept

This strategy combines candlestick patterns with EMA trend filtering to identify high-probability trade entries, featuring:

Entry Signals: Hammer and Engulfing patterns confirmed by EMA trend
Trend Filter: Fast EMA (20) vs Slow EMA (50) crossover system
Risk Management: 5% stop-loss + 1% trailing stop
Smart Exit: 2-bar delay after exit signals to avoid whipsaws
Key Components

Trend Identification:
Uptrend: Fast EMA > Slow EMA AND rising
Downtrend: Fast EMA < Slow EMA AND falling
Entry Conditions:
pinescript
// Bullish Entry (Long)
longCondition = (Hammer OR Bullish Engulfing)
AND Uptrend
AND no existing position

// Bearish Entry (Short)
shortCondition = Bearish Engulfing
AND Downtrend
AND no existing position
Exit Mechanics:
Primary Exit: EMA crossover (Fast crosses Slow)
Delayed Execution: Waits 2 full candles after signal
Emergency Exits:
5% fixed stop-loss
1% trailing stop
Visual Dashboard:
Colored EMA lines (Blue=Fast, Red=Slow)
Annotated candlestick patterns
Background highlighting for signals
Distinct markers for entries/exits
Unique Features

Pattern Recognition:
Enhanced Hammer detection (strict body/wick ratios)
Multi-candle engulfing confirmation
Trend-Confirmation:
Requires price and EMA alignment
Filters counter-trend patterns
Exit Optimization:
pinescript
// Delay implementation
if exit_signal_triggered
counter := 2 // Start countdown
else if counter > 0
counter -= 1 // Decrement each bar

exit_trade = (counter == 1) // Execute on final bar
Risk Parameters

Parameter Value Description
Stop Loss 5% Fixed risk per trade
Trailing Stop 1% Locks in profits
Exit Delay 2 bars Reduces false exits
Position Size 100% No pyramiding
Visualization Examples

🟢 Green Triangle: Bullish entry
🔴 Red Triangle: Bearish entry
⬇️ Blue X: Long exit (after delay)
⬆️ Green X: Short exit (after delay)
🎯 Pattern Labels: Identifies hammer/engulfing
Recommended Use

Timeframes: 1H-4H (reduces noise)
Markets: Trend-prone assets (FX, indices)
Best Conditions: Strong trending markets
Avoid: Choppy/Ranging markets

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.