Pin Bar Candle ?????????????????????
Pin Bar (Pinocchio Bar) ????????????????????????????????????????????????????????? (candlestick pattern) ??????????????????????????????????????????????????????????????????????????????????????? (reversal signal) ????????????????????????????????????????????? ????????? (shadow/wick) ?????????????????????????????????????????????????????????????????????????????? (body) ?????????????????????????????????????????? reject ????????????????????????????????????????????????????????????????????????
??????????????????????????? Pin Bar ??????????????? ????????????????????????????????????????????? 2/3 ???????????????????????????????????????????????????????????????????????????????????????, ????????????????????? (body) ?????????????????????????????????????????????????????????????????????, ??????????????????????????????????????????????????????????????????????????????????????????, ???????????????????????????????????? Support/Resistance ???????????????, ?????? Volume ?????????????????????????????????
Pin Bar ???????????? price action pattern ???????????????????????????????????????????????????????????????????????????????????????????????? Forex, ????????????, Crypto ???????????????????????????????????????????????????????????????????????????????????? risk/reward ratio ??????????????? ????????????????????????????????? Stop Loss ??????????????????????????? (??????????????????????????????)
??????????????????????????? Pin Bar
Pin Bar ???????????????????????? 2 ??????????????????????????????
# === Pin Bar Types ===
cat > pin_bar_types.yaml << 'EOF'
pin_bar_types:
bullish_pin_bar:
name: "Bullish Pin Bar (Hammer)"
description: "???????????????????????????????????????????????????"
characteristics:
- "??????????????????????????????????????? (lower shadow)"
- "???????????????????????????????????????????????????????????????"
- "???????????????????????????????????????????????????????????????"
- "??????????????????????????????????????? (Support)"
- "??????????????????????????????????????????????????????????????????????????????????????????"
interpretation: "????????????????????? (Bulls) ??????????????????????????? ????????? ????????????????????????????????????????????????????????????????????????"
entry: "Buy ??????????????????????????????????????? high ????????? Pin Bar"
stop_loss: "????????? low ????????? Pin Bar"
take_profit: "2-3 ????????????????????? Stop Loss (R:R 1:2 - 1:3)"
bearish_pin_bar:
name: "Bearish Pin Bar (Shooting Star)"
description: "?????????????????????????????????????????????"
characteristics:
- "????????????????????????????????? (upper shadow)"
- "?????????????????????????????????????????????????????????????????????"
- "?????????????????????????????????????????????????????????????????????"
- "?????????????????????????????????????????? (Resistance)"
- "??????????????????????????????????????????????????????????????????????????????????????????"
interpretation: "?????????????????? (Bears) ??????????????????????????? ????????????????????????????????????????????????????????????????????????"
entry: "Sell ??????????????????????????????????????? low ????????? Pin Bar"
stop_loss: "??????????????? high ????????? Pin Bar"
take_profit: "2-3 ????????????????????? Stop Loss (R:R 1:2 - 1:3)"
quality_scoring:
excellent:
score: "A+"
criteria:
- "????????? >= 75% ???????????????????????????????????????????????????"
- "????????????????????? key S/R level"
- "Trend ??????????????????????????????????????????"
- "Volume ????????????????????? average"
- "Pin Bar size ???????????????????????? average candle"
good:
score: "A"
criteria:
- "????????? >= 66% ???????????????????????????????????????????????????"
- "???????????????????????? S/R level"
- "?????? confluence ????????? indicator ????????????"
average:
score: "B"
criteria:
- "????????? >= 50% ???????????????????????????????????????????????????"
- "??????????????????????????????????????? key level"
- "???????????????????????????????????????????????????"
EOF
echo "Pin Bar types documented"
??????????????????????????? Pin Bar ???????????? Python
Python script ????????????????????? Pin Bar ???????????????????????????
#!/usr/bin/env python3
# pin_bar_detector.py ??? Pin Bar Detection & Analysis
import json
import logging
from typing import Dict, List
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("pinbar")
class PinBarDetector:
"""Detect and analyze Pin Bar candlestick patterns"""
def __init__(self, tail_ratio=0.66, body_ratio=0.33):
self.tail_ratio = tail_ratio
self.body_ratio = body_ratio
def detect(self, candle):
"""Detect if candle is a Pin Bar"""
o, h, l, c = candle["open"], candle["high"], candle["low"], candle["close"]
total_range = h - l
if total_range == 0:
return None
body = abs(c - o)
upper_shadow = h - max(o, c)
lower_shadow = min(o, c) - l
body_pct = body / total_range
upper_pct = upper_shadow / total_range
lower_pct = lower_shadow / total_range
# Bullish Pin Bar: long lower shadow
if lower_pct >= self.tail_ratio and body_pct <= self.body_ratio:
return {
"type": "bullish",
"signal": "BUY",
"tail_pct": round(lower_pct * 100, 1),
"body_pct": round(body_pct * 100, 1),
"entry": h, # Buy above high
"stop_loss": l, # Stop below low
"risk": round(h - l, 4),
"tp1": round(h + (h - l) * 2, 4), # 1:2 R:R
"tp2": round(h + (h - l) * 3, 4), # 1:3 R:R
}
# Bearish Pin Bar: long upper shadow
if upper_pct >= self.tail_ratio and body_pct <= self.body_ratio:
return {
"type": "bearish",
"signal": "SELL",
"tail_pct": round(upper_pct * 100, 1),
"body_pct": round(body_pct * 100, 1),
"entry": l, # Sell below low
"stop_loss": h, # Stop above high
"risk": round(h - l, 4),
"tp1": round(l - (h - l) * 2, 4), # 1:2 R:R
"tp2": round(l - (h - l) * 3, 4), # 1:3 R:R
}
return None
def scan_data(self, candles):
"""Scan multiple candles for Pin Bars"""
signals = []
for i, candle in enumerate(candles):
result = self.detect(candle)
if result:
result["index"] = i
result["date"] = candle.get("date", f"candle-{i}")
signals.append(result)
return signals
def quality_score(self, pin_bar, avg_range, volume, avg_volume):
"""Score Pin Bar quality"""
score = 0
# Tail length
if pin_bar["tail_pct"] >= 75:
score += 3
elif pin_bar["tail_pct"] >= 66:
score += 2
else:
score += 1
# Body size (smaller = better)
if pin_bar["body_pct"] <= 15:
score += 2
elif pin_bar["body_pct"] <= 25:
score += 1
# Candle size vs average
if pin_bar["risk"] > avg_range * 1.5:
score += 2
elif pin_bar["risk"] > avg_range:
score += 1
# Volume
if volume > avg_volume * 1.5:
score += 2
elif volume > avg_volume:
score += 1
grade = "A+" if score >= 8 else "A" if score >= 6 else "B" if score >= 4 else "C"
return {"score": score, "grade": grade, "max_score": 9}
# Demo
detector = PinBarDetector()
# Sample OHLC data
candles = [
{"date": "2024-06-01", "open": 1.0850, "high": 1.0870, "low": 1.0780, "close": 1.0860}, # Bullish Pin
{"date": "2024-06-02", "open": 1.0870, "high": 1.0900, "low": 1.0860, "close": 1.0880}, # Normal
{"date": "2024-06-03", "open": 1.0900, "high": 1.0980, "low": 1.0890, "close": 1.0895}, # Bearish Pin
{"date": "2024-06-04", "open": 1.0890, "high": 1.0920, "low": 1.0850, "close": 1.0910}, # Normal
{"date": "2024-06-05", "open": 1.0910, "high": 1.0920, "low": 1.0830, "close": 1.0915}, # Bullish Pin
]
signals = detector.scan_data(candles)
print(f"Pin Bar Scanner Results ({len(signals)} found):")
for sig in signals:
print(f"\n {sig['date']} ??? {sig['type'].upper()} Pin Bar")
print(f" Signal: {sig['signal']}, Entry: {sig['entry']}, SL: {sig['stop_loss']}")
print(f" TP1 (1:2): {sig['tp1']}, TP2 (1:3): {sig['tp2']}")
print(f" Tail: {sig['tail_pct']}%, Body: {sig['body_pct']}%")
?????????????????????????????????????????????????????? Pin Bar
Trading strategies ?????????????????? Pin Bar
#!/usr/bin/env python3
# pin_bar_strategy.py ??? Pin Bar Trading Strategies
import json
import logging
from typing import Dict, List
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("strategy")
class PinBarStrategy:
"""Pin Bar Trading Strategies"""
def __init__(self):
pass
def strategy_at_support_resistance(self):
return {
"name": "Pin Bar at Key Levels",
"description": "???????????? Pin Bar ??????????????????????????? Support/Resistance ???????????????",
"rules": {
"entry": [
"???????????? key Support/Resistance levels (Daily/Weekly)",
"?????? Pin Bar ???????????????????????????????????????????????????????????????",
"Bullish Pin Bar ????????? Support ??? Buy",
"Bearish Pin Bar ????????? Resistance ??? Sell",
"Entry: 50% retracement ????????? Pin Bar ???????????? breakout of high/low",
],
"stop_loss": "?????????/??????????????? ????????? Pin Bar + buffer 5-10 pips",
"take_profit": "Next S/R level ???????????? R:R 1:2 minimum",
"risk_management": "Risk 1-2% ????????? trade",
},
"win_rate": "55-65%",
"avg_rr": "1:2 - 1:3",
}
def strategy_with_trend(self):
return {
"name": "Pin Bar with Trend",
"description": "???????????? Pin Bar ????????? trend ???????????? (higher probability)",
"rules": {
"trend_identification": [
"????????? EMA 50 + EMA 200 ??????????????? trend",
"Price above EMA 50 > EMA 200 = Uptrend",
"Price below EMA 50 < EMA 200 = Downtrend",
],
"entry": [
"Uptrend: ??????????????????????????? Bullish Pin Bar (buy the dip)",
"Downtrend: ??????????????????????????? Bearish Pin Bar (sell the rally)",
"Pin Bar ???????????????????????????????????? EMA 50 (dynamic support/resistance)",
],
"filters": [
"Pin Bar body ???????????????????????????????????? trend direction",
"Volume ????????????????????????????????? 20-period average",
"????????????????????????????????? major news events",
],
},
"win_rate": "60-70%",
"avg_rr": "1:2",
}
def risk_management(self):
return {
"position_sizing": {
"rule": "Risk 1-2% per trade",
"formula": "Position Size = (Account * Risk%) / (Entry - Stop Loss)",
"example": {
"account": 100000,
"risk_pct": 1,
"entry": 1.0860,
"stop_loss": 1.0780,
"risk_per_trade": 1000,
"pip_risk": 80,
"position_size": "12,500 units (0.125 lots)",
},
},
"rules": [
"?????????????????????????????????????????? 3 positions ????????????????????????",
"????????? risk ????????????????????? 5% ?????????????????????",
"Move SL to breakeven ??????????????? price ????????? 1:1 R:R",
"Trail stop ??????????????? trend ??????????????????",
"????????? revenge trade ???????????? loss",
],
}
strategy = PinBarStrategy()
sr = strategy.strategy_at_support_resistance()
print(f"Strategy: {sr['name']}")
print(f" Win Rate: {sr['win_rate']}, R:R: {sr['avg_rr']}")
for rule in sr["rules"]["entry"]:
print(f" - {rule}")
rm = strategy.risk_management()
ex = rm["position_sizing"]["example"]
print(f"\nRisk Management Example:")
print(f" Account: ")
print(f" Risk: {ex['risk_pct']}% = ")
print(f" Entry: {ex['entry']}, SL: {ex['stop_loss']}")
print(f" Position: {ex['position_size']}")
Pin Bar ????????? Indicators ????????????
????????? Pin Bar ????????????????????? technical indicators
# === Pin Bar + Indicators Confluence ===
cat > confluence_strategies.yaml << 'EOF'
pin_bar_confluence:
with_fibonacci:
description: "Pin Bar ????????? Fibonacci Retracement levels"
best_levels: ["38.2%", "50%", "61.8%"]
example:
setup: "Uptrend ??? Pullback to 61.8% Fib ??? Bullish Pin Bar"
entry: "Buy above Pin Bar high"
stop: "Below Pin Bar low (also below 78.6% Fib)"
target: "Previous swing high ???????????? 161.8% extension"
win_rate_boost: "+5-10% vs standalone Pin Bar"
with_moving_averages:
description: "Pin Bar ????????? EMA/SMA levels"
best_mas: ["EMA 21", "EMA 50", "SMA 200"]
example:
setup: "Price bounces off EMA 50 with Bullish Pin Bar"
confirmation: "Pin Bar close above EMA 50"
win_rate_boost: "+5-8%"
with_rsi:
description: "Pin Bar ????????? RSI Oversold/Overbought"
conditions:
bullish: "RSI < 30 + Bullish Pin Bar = Strong buy signal"
bearish: "RSI > 70 + Bearish Pin Bar = Strong sell signal"
note: "RSI divergence + Pin Bar = highest probability setup"
win_rate_boost: "+8-12%"
with_volume:
description: "Pin Bar ??????????????? Volume ?????????"
conditions:
high_volume: "Volume > 1.5x average = Strong signal"
low_volume: "Volume < average = Weak signal (avoid)"
note: "High volume confirms institutional participation"
with_bollinger_bands:
description: "Pin Bar ????????? Bollinger Band extremes"
conditions:
bullish: "Pin Bar ????????? lower band = Bounce signal"
bearish: "Pin Bar ????????? upper band = Reversal signal"
note: "Band squeeze + Pin Bar breakout = Explosive move"
multi_confluence:
description: "3+ confluences = High probability trade"
example:
confluences:
- "Bullish Pin Bar at key support"
- "RSI < 35 (oversold)"
- "Price at EMA 200"
- "Fibonacci 61.8% level"
expected_win_rate: "70-80%"
note: "???????????? confluence ????????? ?????????????????????????????????????????????"
EOF
python3 -c "
import yaml
with open('confluence_strategies.yaml') as f:
data = yaml.safe_load(f)
print('Pin Bar Confluence Strategies:')
for name, info in data['pin_bar_confluence'].items():
boost = info.get('win_rate_boost', info.get('expected_win_rate', 'N/A'))
print(f' {name}: {info[\"description\"]} ({boost})')
"
echo "Confluence strategies documented"
Backtesting Pin Bar Strategy
??????????????? strategy ????????????????????????
#!/usr/bin/env python3
# backtest.py ??? Pin Bar Strategy Backtester
import json
import logging
import random
from typing import Dict, List
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("backtest")
class PinBarBacktester:
"""Backtest Pin Bar trading strategies"""
def __init__(self, initial_balance=100000, risk_pct=1):
self.initial_balance = initial_balance
self.balance = initial_balance
self.risk_pct = risk_pct
self.trades = []
def simulate_trades(self, num_trades, win_rate=0.60, avg_rr=2.0):
"""Simulate Pin Bar trading results"""
random.seed(42)
for i in range(num_trades):
risk_amount = self.balance * self.risk_pct / 100
is_win = random.random() < win_rate
if is_win:
pnl = risk_amount * avg_rr
result = "WIN"
else:
pnl = -risk_amount
result = "LOSS"
self.balance += pnl
self.trades.append({
"trade_num": i + 1,
"result": result,
"pnl": round(pnl, 2),
"balance": round(self.balance, 2),
})
return self.trades
def statistics(self):
"""Calculate trading statistics"""
wins = [t for t in self.trades if t["result"] == "WIN"]
losses = [t for t in self.trades if t["result"] == "LOSS"]
total_profit = sum(t["pnl"] for t in wins)
total_loss = sum(t["pnl"] for t in losses)
# Max drawdown
peak = self.initial_balance
max_dd = 0
for t in self.trades:
if t["balance"] > peak:
peak = t["balance"]
dd = (peak - t["balance"]) / peak * 100
if dd > max_dd:
max_dd = dd
# Consecutive losses
max_consecutive_loss = 0
current_streak = 0
for t in self.trades:
if t["result"] == "LOSS":
current_streak += 1
max_consecutive_loss = max(max_consecutive_loss, current_streak)
else:
current_streak = 0
return {
"total_trades": len(self.trades),
"wins": len(wins),
"losses": len(losses),
"win_rate": round(len(wins) / len(self.trades) * 100, 1),
"total_profit": round(total_profit, 2),
"total_loss": round(total_loss, 2),
"net_profit": round(total_profit + total_loss, 2),
"profit_factor": round(abs(total_profit / total_loss), 2) if total_loss != 0 else 0,
"max_drawdown_pct": round(max_dd, 2),
"max_consecutive_losses": max_consecutive_loss,
"final_balance": round(self.balance, 2),
"return_pct": round((self.balance - self.initial_balance) / self.initial_balance * 100, 2),
}
# Run backtest
bt = PinBarBacktester(initial_balance=100000, risk_pct=1)
bt.simulate_trades(num_trades=200, win_rate=0.60, avg_rr=2.0)
stats = bt.statistics()
print("Pin Bar Strategy Backtest Results (200 trades):")
print(f" Win Rate: {stats['win_rate']}%")
print(f" Profit Factor: {stats['profit_factor']}")
print(f" Net Profit: ")
print(f" Return: {stats['return_pct']}%")
print(f" Max Drawdown: {stats['max_drawdown_pct']}%")
print(f" Max Consecutive Losses: {stats['max_consecutive_losses']}")
print(f" Final Balance: ")
FAQ ??????????????????????????????????????????
Q: Pin Bar ????????? Doji ???????????????????????????????????????????
A: Pin Bar ??????????????????????????????????????????????????? (upper ???????????? lower) ?????????????????????????????????????????????????????????????????????????????????????????? ????????? directional signal ?????????????????? (bullish ???????????? bearish) Doji ???????????????????????????????????????????????? (???????????? = ????????? ???????????????????????????????????????) ????????????????????? 2 ?????????????????????????????????????????? ???????????? indecision (??????????????????????????????????????????????????????) ?????????????????? confirmation candle ??????????????? Pin Bar ???????????????????????????????????? actionable ????????????????????? Doji ????????????????????? directional bias ?????????????????? Doji ???????????? combine ????????? context (S/R levels, trend, volume) ?????????????????????????????????????????????
Q: Timeframe ?????????????????????????????????????????? Pin Bar?
A: Pin Bar ????????????????????????????????? timeframe ??????????????????????????????????????????????????????????????? Daily (D1) ???????????????????????? ????????????????????????????????????????????????????????????????????? noise ???????????? ??????????????? swing trading, H4 ??????????????? balance ????????????????????? signal quality ????????? trading frequency, H1 ?????????????????? ????????? noise ????????????????????? ???????????? filter ???????????? higher timeframe trend, M15/M5 noise ????????? false signals ???????????? ???????????? experienced trader ????????? Multiple Timeframe Analysis ??????????????? ?????? trend ?????? Daily ??????????????? direction ?????? H4 ?????? Pin Bar entry ?????? H1 fine-tune entry point
Q: Pin Bar ????????????????????????????????????????
A: Pin Bar ???????????? tool ?????????????????? holy grail ?????????????????????????????????????????? Context ????????????????????????????????? key levels (S/R, Fibonacci, EMA) ??????????????????????????? Pin Bar ?????? work, Confluence ???????????? confluences ????????? win rate ????????????????????? (RSI + S/R + Pin Bar), Risk Management ???????????? risk 1-2% per trade ????????? R:R ??????????????????????????? 1:2, Discipline ??????????????????????????? rules ????????? revenge trade ??????????????????????????? backtesting ?????????????????? Pin Bar ????????? key levels win rate 55-65%, ????????????????????? trend win rate 60-70%, ???????????? R:R 1:2 profit factor ?????????????????? 1.5-2.0 ?????????????????????????????????????????????????????????????????? ???????????? practice ????????? disciplined execution
Q: ????????? Pin Bar ????????? Crypto ???????????????????
A: ????????? Pin Bar ???????????????????????????????????????????????????????????? OHLC data ?????????????????? Crypto (BTC, ETH) ?????????????????????????????????????????????????????????????????? Crypto Volatility ????????????????????? Forex/Stock ????????? Pin Bar ??????????????? range ???????????? ???????????? adjust position size, 24/7 market ??????????????? gap ?????????????????????????????? Pin Bar ??????????????????????????? context ?????????????????????, Manipulation ???????????? Crypto ?????? manipulation ????????????????????? ??????????????? fake Pin Bars ????????? stop hunting, Timeframe ??????????????? H4 ???????????????????????????????????? Crypto timeframe ????????????????????? noise ?????????, Liquidity ??????????????????????????? Crypto ??????????????? volume ????????? (BTC, ETH) ?????????????????????????????? low-cap tokens
