Tradehook — Trading Automation Service
mediumpatternPattern-Based

PinBarAlgo

The Pin Bar Algorithm identifies high-probability rejection candles—also known as hammers, shooting stars, or pin bars—that signal failed attempts to push price in one direction. These patterns represent aggressive rejection of price levels and often precede significant reversals.

TradingView Preview
See this algorithm in action on real charts
PinBarAlgo TradingView chart
Performance Metrics
Historical backtesting results
55.3%
Win Rate
1.19
Profit Factor
12.6%
Max Drawdown
$116
Avg Trade
Based on 304 trades

About This Algorithm

PIN BAR REJECTION STRATEGY

Quick Facts:

  • Category: Candlestick Pattern Recognition
  • Markets: All liquid markets
  • Timeframes: 15min, 1H, 4H, Daily

Overview

The Pin Bar Algorithm identifies high-probability rejection candles—also known as hammers, shooting stars, or pin bars—that signal failed attempts to push price in one direction. These patterns represent aggressive rejection of price levels and often precede significant reversals.

A pin bar is characterized by a small real body with a long rejection wick pointing in the direction of the failed move. The algorithm uses precise geometric ratios to identify valid pin bars while filtering out weak formations.


How It Works

GEOMETRIC ANALYSIS Each candle is analyzed for pin bar characteristics:

  • Body Size: |Close - Open|
    • Upper Wick: High - Max(Open, Close)
    • Lower Wick: Min(Open, Close) - Low
    • Total Range: High - Low
    • Body Position: Where the body sits within the candle range

BULLISH PIN BAR (Hammer) DETECTION Signals rejection of lower prices:

  1. Lower wick >= Body × wickToBodyRatio [default: 2.0]
  2. Upper wick <= Body × maxNoseRatio (small or no "nose")
  3. Body is in upper portion of candle (bodyPositionPct check)
  4. Total range >= ATR × minRangeATR (significant size)
  5. Trend filter aligned (if enabled)

BEARISH PIN BAR (Shooting Star) DETECTION Signals rejection of higher prices:

  1. Upper wick >= Body × wickToBodyRatio [default: 2.0]
  2. Lower wick <= Body × maxNoseRatio (small or no "nose")
  3. Body is in lower portion of candle (bodyPositionPct check)
  4. Total range >= ATR × minRangeATR (significant size)
  5. Trend filter aligned (if enabled)

BODY POSITION VALIDATION Ensures the body is positioned correctly:

  • Bullish: Body must be in upper third of candle
    • Bearish: Body must be in lower third of candle
    • bodyPositionPct parameter controls threshold [default: 33%]

NOSE CONTROL The "nose" is the wick opposite the rejection wick:

  • Small or no nose indicates strong rejection
    • maxNoseRatio controls maximum allowed nose size
    • Lower values = stricter (classic pin bar appearance)

Signal Generation

LONG SIGNAL (Bullish Pin Bar): ✅ Long lower wick (rejection of lower prices) ✅ Small upper wick (no resistance above) ✅ Body in upper portion of candle ✅ Minimum ATR-based size requirement met ✅ Trend filter bullish (if enabled) ✅ VMAlgo confirmation (if enabled)

SHORT SIGNAL (Bearish Pin Bar): ✅ Long upper wick (rejection of higher prices) ✅ Small lower wick (no support below) ✅ Body in lower portion of candle ✅ Minimum ATR-based size requirement met ✅ Trend filter bearish (if enabled) ✅ VMAlgo confirmation (if enabled)


Key Parameters

GEOMETRIC RATIOS:

  • wickToBodyRatio (2.0): Minimum rejection wick to body ratio
    • maxNoseRatio (0.5): Maximum opposite wick to body ratio
    • bodyPositionPct (33): Body must be in this % of candle
    • minRangeATR (0.5): Minimum candle range as ATR multiple

TREND FILTER:

  • useTrendFilter (true): Align with higher-timeframe trend
    • trendFastEMA (8): Fast EMA period
    • trendSlowEMA (21): Slow EMA period

VMALGO INTEGRATION:

  • useVMConfirmation (true): Require momentum confirmation

Best Use Cases

✅ KEY LEVEL REJECTIONS at horizontal support/resistance ✅ MOVING AVERAGE BOUNCES (21 EMA, 50 SMA, 200 SMA) ✅ FIBONACCI LEVEL REJECTIONS (38.2%, 50%, 61.8%) ✅ TREND CONTINUATION pullback entries ✅ REVERSAL CONFIRMATION at market structure points


Optimization Tips

FOR CLASSIC PIN BARS: • wickToBodyRatio = 2.5-3.0 • maxNoseRatio = 0.25-0.3 • bodyPositionPct = 25-30 • Enable trend filter

FOR RELAXED DETECTION: • wickToBodyRatio = 1.5-2.0 • maxNoseRatio = 0.5-0.7 • bodyPositionPct = 35-40 • Use VMAlgo confirmation instead of strict geometry

FOR KEY LEVEL TRADING: • Combine with horizontal S/R levels • Increase minRangeATR to 0.7-1.0 • Require trend alignment • Consider higher timeframes (4H, Daily)

Customer Reviews

No reviews yet. Be the first to review this algorithm!
Pattern-Based
Requires Pattern-Based Plan

Subscribe to Pattern-Based or higher to access

Subscription Access

Get access to this indicator/strategy on TradingView through our invite-only system. Your TradingView account will be granted access.

One-Time Purchase

Own the complete Pine Script source code forever. Modify, customize, and use it on your own TradingView account.

$750
Subscribe to any tier to unlock one-time purchases

What you get with source code:

  • Complete Pine Script v5 source code
  • Lifetime ownership - no recurring fees
  • Full customization rights
  • Use on your own TradingView account
PlatformTradingView
Subscription AccessTradingView Invite
One-Time PurchaseSource Code
LicensePersonal Use

We Value Your Privacy

We use cookies to enhance your browsing experience, analyze site traffic, and personalize content. By clicking "Accept All", you consent to our use of cookies. Read our Privacy Policy for more information.