← กลับหน้ารายการ

Engulfing & Pin Bar Breakout Strategy

Strategy ผู้เขียน: Punisher1on1 Profit Factor: 2.196

ลิงก์ TradingView

เปิดใน TradingView

Equity Chart

Equity chart

เปิดรูปเต็มขนาด

คำอธิบาย

Overview
This strategy automates a classic, powerful trading methodology based on identifying key candlestick reversal patterns and trading the subsequent price breakout. It is designed to be a complete, "set-and-go" system with built-in risk and position size management.

The core logic operates on the 1-Hour timeframe, scanning for four distinct high-probability reversal signals: two bullish and two bearish. An entry is only triggered when the market confirms the signal by breaking a key price level, aiming to capture momentum following a potential shift in market sentiment.

The Strategy Logic
The system is composed of two distinct modules: Bullish (Long) and Bearish (Short).

🐂 Bullish (Long) Setup
The script initiates a long trade based on the following strict criteria:

Signal: Identifies either a Hammer or a Bullish Engulfing pattern. These patterns often indicate that sellers are losing control and buyers are stepping in.

Confirmation: Waits for the very next candle after the signal.

Entry Trigger: A long position is automatically opened as soon as the price breaks above the high of the signal candle.

Stop Loss: Immediately set just below the low of the signal candle.

Take Profit: A fixed target is placed at a 1:5 Risk/Reward Ratio.

🐻 Bearish (Short) Setup
The script initiates a short trade based on the following strict criteria:

Signal: Identifies either a Shooting Star or a Bearish Engulfing pattern. These patterns suggest buying pressure is fading and sellers are taking over.

Confirmation: Waits for the very next candle after the signal.

Entry Trigger: A short position is automatically opened as soon as the price breaks below the low of the signal candle.

Stop Loss: Immediately set just above the high of the signal candle.

Take Profit: A fixed target is placed at a 1:4 Risk/Reward Ratio.

Key Feature: Automated Risk Management
This strategy is designed for disciplined trading. You do not need to calculate position sizes manually.

Fixed Risk: The script automatically calculates the correct position size to risk exactly 2% of your total account equity on every single trade.

Dynamic Sizing: The position size will adjust based on the distance between your entry price and your stop loss for each specific setup, ensuring a consistent risk profile.

How To Use
Apply the script to your chosen chart (e.g., BTC/USD).

Crucially, set your chart's timeframe to 1-Hour (H1). The strategy is specifically calibrated for this interval.

Navigate to the "Strategy Tester" tab below your chart to view backtest results, including net profit, win rate, and individual trades.

Disclaimer: This script is provided for educational and informational purposes only. It is not financial advice. All trading involves substantial risk, and past performance is not indicative of future results. Please use this tool responsibly and at your own risk.

รูป Preview

Preview

Pine Script Source

//@version=6
// --- FIXED PARAMETER STRATEGY ---
// This is a finished script with pre-set values as requested.
// Initial Capital: $1,000
// Risk Per Trade: 2% of Equity
// Bullish R/R: 1:5 | Bearish R/R: 1:4

strategy("Fixed Candlestick Breakout Strategy",
         overlay=true,
         initial_capital=1000,
         commission_value=0.075, // Realistic commission for crypto exchanges
         commission_type=strategy.commission.percent)

// --- Fixed Parameters (No Inputs) ---
longProfitRatio = 5.0
shortProfitRatio = 4.0
riskPercent = 0.02 // 2% risk per trade

// --- Candlestick Pattern Detection ---
bodySize = math.abs(close - open)
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low

// Bullish Signal Logic: Hammer OR Bullish Engulfing
isHammer = lowerWick > bodySize * 2 and upperWick < bodySize * 0.5
isBullishEngulfing = close > open and close[1] < open[1] and close > open[1] and open < close[1]
isBullishSignal = isHammer or isBullishEngulfing

// Bearish Signal Logic: Shooting Star OR Bearish Engulfing
isShootingStar = upperWick > bodySize * 2 and lowerWick < bodySize * 0.5
isBearishEngulfing = close < open and close[1] > open[1] and close < open[1] and open > close[1]
isBearishSignal = isShootingStar or isBearishEngulfing

// --- State Management ---
// We use 'var' to track the signal candle's data and wait for a breakout
var bool waitingForBullishEntry = false
var bool waitingForBearishEntry = false
var float signalHigh = na
var float signalLow = na

// Set the state when a signal candle is identified
if isBullishSignal
    waitingForBullishEntry := true
    waitingForBearishEntry := false
    signalHigh := high
    signalLow := low

if isBearishSignal
    waitingForBearishEntry := true
    waitingForBullishEntry := false
    signalHigh := high
    signalLow := low

// --- Entry and Exit Logic ---
// Only look for entries if we are flat (no open position)
if strategy.position_size == 0
    // Bullish Entry: Trigger on the candle AFTER the signal candle
    if waitingForBullishEntry[1] and high > signalHigh[1]
        entryPrice = signalHigh[1]
        stopLossPrice = signalLow[1]
        riskPerUnit = entryPrice - stopLossPrice

        // Position Size Calculation (2% Risk)
        capitalToRisk = strategy.equity * riskPercent
        positionSize = riskPerUnit > 0 ? capitalToRisk / riskPerUnit : 0

        if positionSize > 0
            takeProfitPrice = entryPrice + (riskPerUnit * longProfitRatio)
            strategy.entry("Long", strategy.long, qty=positionSize, stop=entryPrice)
            strategy.exit("Long Exit", from_entry="Long", loss=stopLossPrice, limit=takeProfitPrice)
            waitingForBullishEntry := false // Reset state

    // Bearish Entry: Trigger on the candle AFTER the signal candle
    if waitingForBearishEntry[1] and low < signalLow[1]
        entryPrice = signalLow[1]
        stopLossPrice = signalHigh[1]
        riskPerUnit = stopLossPrice - entryPrice

        // Position Size Calculation (2% Risk)
        capitalToRisk = strategy.equity * riskPercent
        positionSize = riskPerUnit > 0 ? capitalToRisk / riskPerUnit : 0

        if positionSize > 0
            takeProfitPrice = entryPrice - (riskPerUnit * shortProfitRatio)
            strategy.entry("Short", strategy.short, qty=positionSize, stop=entryPrice)
            strategy.exit("Short Exit", from_entry="Short", loss=stopLossPrice, limit=takeProfitPrice)
            waitingForBearishEntry := false // Reset state

// Invalidate the signal if a breakout doesn't happen on the next candle
if waitingForBullishEntry and not isBullishSignal
    waitingForBullishEntry := false
if waitingForBearishEntry and not isBearishSignal
    waitingForBearishEntry := false

// --- Visuals ---
// Plot markers on the chart for identified signal candles
plotshape(isBullishSignal, "Bullish Signal", shape.triangleup, location.belowbar, color.new(color.green, 20), size=size.small)
plotshape(isBearishSignal, "Bearish Signal", shape.triangledown, location.abovebar, color.new(color.red, 20), size=size.small)