OPEN-SOURCE SCRIPT

Statistical Candle Patterns [QuantRegime]

746
## Overview

Most candle pattern indicators just label patterns on your chart. This one goes further โ€” it **backtests every pattern against the actual chart history** and shows you the **real win rate** for each pattern on the specific instrument and timeframe you're trading.

A "Bullish Engulfing" might have a 68% win rate on BTC 4H but only 42% on EUR/USD 15m. This indicator tells you the difference. **Stop guessing which patterns work โ€” measure them.**

## 12 Patterns Detected

| Pattern | Type | What It Signals |
|---------|------|----------------|
| **Bullish Engulfing** | Bullish | New candle fully engulfs previous bearish candle |
| **Bearish Engulfing** | Bearish | New candle fully engulfs previous bullish candle |
| **Hammer** | Bullish | Long lower wick, small body at top โ€” rejection of lows |
| **Shooting Star** | Bearish | Long upper wick, small body at bottom โ€” rejection of highs |
| **Doji** | Neutral | Tiny body โ€” indecision, potential reversal |
| **Morning Star** | Bullish | 3-bar reversal: down โ†’ indecision โ†’ up |
| **Evening Star** | Bearish | 3-bar reversal: up โ†’ indecision โ†’ down |
| **Three White Soldiers** | Bullish | 3 consecutive strong green candles |
| **Three Black Crows** | Bearish | 3 consecutive strong red candles |
| **Inside Bar** | Neutral | Current bar fits inside previous bar โ€” consolidation |
| **Bullish Marubozu** | Bullish | Strong green candle with almost no wicks |
| **Bearish Marubozu** | Bearish | Strong red candle with almost no wicks |

## How Win Rates Are Calculated

For each pattern occurrence in the lookback window:
1. Record the close price at the pattern
2. Look forward N bars (default: 5)
3. **Bullish patterns "win"** if the highest high in those N bars > pattern close
4. **Bearish patterns "win"** if the lowest low in those N bars < pattern close
5. Win Rate = wins / total occurrences ร— 100

This is a real backtest on the actual chart data โ€” not some theoretical "textbook" win rate.

## The Statistics Dashboard

The bottom-right dashboard shows all 12 patterns with:
- **Win %** โ€” Historical win rate on THIS symbol, THIS timeframe
- **Count** โ€” How many times the pattern appeared
- **Type** โ€” Bullish, Bearish, or Neutral

Win rates are color-coded:
- ๐ŸŸข 60%+ = Strong edge
- ๐ŸŸก 50-60% = Moderate
- ๐Ÿ”ด Below 50% = Pattern doesn't work here โ€” skip it

## Smart Filtering

Labels only appear on the chart when:
- The pattern has appeared at least N times (configurable, default 3)
- The historical win rate exceeds your threshold (configurable, default 50%)

This means **you only see patterns that have actually worked** on this chart. Low-probability patterns are automatically hidden.

## Key Features

- **12 classic candle patterns** detected automatically
- **Real win rates** calculated from actual chart history โ€” not theory
- **Smart filtering** hides unreliable patterns
- **Full statistics dashboard** with pattern-by-pattern breakdown
- **Customizable detection** โ€” adjust body ratios, wick ratios, lookback windows
- **Toggle individual patterns** on/off
- **11 alert conditions** โ€” one for each pattern type
- **Works on any market, any timeframe**

## Recommended Settings

| Style | Lookback | Outcome Bars | Min Win Rate |
|-------|----------|-------------|-------------|
| Scalping (1-5m) | 200-300 | 3 | 55% |
| Day Trading (15m-1H) | 500 | 5 | 50% |
| Swing (4H-Daily) | 500 | 5-10 | 50% |
| Position (Weekly) | 250 | 3-5 | 45% |

## Important Notes

- Win rates are calculated from historical data and **do not guarantee future results**
- Low occurrence counts (< 5) produce unreliable statistics โ€” increase lookback or use a higher timeframe
- Some patterns (like Doji) are very common โ€” consider raising the min body ratio to filter for higher-quality dojis
- The outcome window matters: 3 bars is aggressive, 10 bars gives more room
- Computing intensive on lower timeframes with high lookback โ€” reduce lookback if the indicator loads slowly

## Disclaimer

This indicator is for educational and analytical purposes only. Past pattern win rates do not guarantee future performance. Always use proper risk management and never rely solely on candle patterns for trading decisions.

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.