CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-ta-lib

Python wrapper for TA-LIB providing 175+ technical analysis indicators for financial market data

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

pattern-recognition.mddocs/

Pattern Recognition

Candlestick pattern recognition functions that identify traditional Japanese candlestick patterns for technical analysis and trading signals. These functions analyze OHLC data to detect specific candlestick formations that may indicate potential price reversals or continuation patterns.

All pattern recognition functions return integer arrays where:

  • 100: Bullish pattern detected
  • -100: Bearish pattern detected
  • 0: No pattern detected

Capabilities

Basic Candlestick Patterns

def CDLDOJI(open, high, low, close):
    """
    Doji - Indecision pattern where open and close are nearly equal
    
    Parameters:
    - open: array-like, open prices
    - high: array-like, high prices  
    - low: array-like, low prices
    - close: array-like, close prices
    
    Returns:
    numpy.ndarray[int32]: Pattern signals (100, -100, or 0)
    """

def CDLHAMMER(open, high, low, close):
    """
    Hammer - Bullish reversal pattern with small body and long lower shadow
    """

def CDLHANGINGMAN(open, high, low, close):
    """
    Hanging Man - Bearish reversal pattern with small body and long lower shadow
    """

def CDLINVERTEDHAMMER(open, high, low, close):
    """
    Inverted Hammer - Bullish reversal pattern with small body and long upper shadow
    """

def CDLSHOOTINGSTAR(open, high, low, close):
    """
    Shooting Star - Bearish reversal pattern with small body and long upper shadow
    """

Doji Variations

def CDLDOJISTAR(open, high, low, close):
    """
    Doji Star - Doji that gaps away from previous candle
    """

def CDLDRAGONFLYDOJI(open, high, low, close):
    """
    Dragonfly Doji - Doji with long lower shadow, no upper shadow
    """

def CDLGRAVESTONEDOJI(open, high, low, close):
    """
    Gravestone Doji - Doji with long upper shadow, no lower shadow
    """

def CDLLONGLEGGEDDOJI(open, high, low, close):
    """
    Long Legged Doji - Doji with both long upper and lower shadows
    """

Engulfing Patterns

def CDLENGULFING(open, high, low, close):
    """
    Engulfing Pattern - Large candle completely engulfs previous candle
    """

Star Patterns

def CDLMORNINGSTAR(open, high, low, close, penetration=0):
    """
    Morning Star - Three-candle bullish reversal pattern
    
    Parameters:
    - penetration: float, penetration threshold (default: 0)
    """

def CDLEVENINGSTAR(open, high, low, close, penetration=0):
    """
    Evening Star - Three-candle bearish reversal pattern
    """

def CDLMORNINGDOJISTAR(open, high, low, close, penetration=0):
    """
    Morning Doji Star - Morning star with doji middle candle
    """

def CDLEVENINGDOJISTAR(open, high, low, close, penetration=0):
    """
    Evening Doji Star - Evening star with doji middle candle
    """

Three-Candle Patterns

def CDL3BLACKCROWS(open, high, low, close):
    """
    Three Black Crows - Bearish reversal pattern with three consecutive black candles
    """

def CDL3WHITESOLDIERS(open, high, low, close):
    """
    Three Advancing White Soldiers - Bullish reversal with three consecutive white candles
    """

def CDL3INSIDE(open, high, low, close):
    """
    Three Inside Up/Down - Three-candle reversal pattern
    """

def CDL3OUTSIDE(open, high, low, close):
    """
    Three Outside Up/Down - Three-candle reversal pattern
    """

def CDL3LINESTRIKE(open, high, low, close):
    """
    Three-Line Strike - Four-candle continuation pattern
    """

def CDLIDENTICAL3CROWS(open, high, low, close):
    """
    Identical Three Crows - Bearish pattern with three identical black candles
    """

def CDL3STARSINSOUTH(open, high, low, close):
    """
    Three Stars In The South - Bullish reversal pattern
    """

Harami Patterns

def CDLHARAMI(open, high, low, close):
    """
    Harami Pattern - Small candle contained within large candle's body
    """

def CDLHARAMICROSS(open, high, low, close):
    """
    Harami Cross Pattern - Harami with doji as second candle
    """

Gap Patterns

def CDLGAPSIDESIDEWHITE(open, high, low, close):
    """
    Up/Down-gap side-by-side white lines
    """

def CDL2CROWS(open, high, low, close):
    """
    Two Crows - Bearish reversal pattern
    """

def CDLUPSIDEGAP2CROWS(open, high, low, close):
    """
    Upside Gap Two Crows - Bearish reversal pattern
    """

def CDLXSIDEGAP3METHODS(open, high, low, close):
    """
    Upside/Downside Gap Three Methods - Continuation pattern
    """

Complex Patterns

def CDLDARKCLOUDCOVER(open, high, low, close, penetration=0):
    """
    Dark Cloud Cover - Bearish reversal pattern
    """

def CDLPIERCING(open, high, low, close):
    """
    Piercing Pattern - Bullish reversal pattern
    """

def CDLABANDONEDBABY(open, high, low, close, penetration=0):
    """
    Abandoned Baby - Rare reversal pattern with gaps
    """

def CDLMATHOLD(open, high, low, close, penetration=0):
    """
    Mat Hold - Bullish continuation pattern
    """

Marubozu Patterns

def CDLMARUBOZU(open, high, low, close):
    """
    Marubozu - Candle with no shadows (open/close at high/low)
    """

def CDLCLOSINGMARUBOZU(open, high, low, close):
    """
    Closing Marubozu - Marubozu that closes at high or low
    """

Additional Patterns

def CDLADVANCEBLOCK(open, high, low, close):
    """Advance Block - Bearish reversal pattern"""

def CDLBELTHOLD(open, high, low, close):
    """Belt-hold - Single candle reversal pattern"""

def CDLBREAKAWAY(open, high, low, close):
    """Breakaway - Five-candle reversal pattern"""

def CDLCONCEALBABYSWALL(open, high, low, close):
    """Concealing Baby Swallow - Bullish reversal pattern"""

def CDLCOUNTERATTACK(open, high, low, close):
    """Counterattack - Reversal pattern"""

def CDLHIGHWAVE(open, high, low, close):
    """High-Wave Candle - Indecision pattern with long shadows"""

def CDLHIKKAKE(open, high, low, close):
    """Hikkake Pattern - Inside day breakout pattern"""

def CDLHIKKAKEMOD(open, high, low, close):
    """Modified Hikkake Pattern - Enhanced version of Hikkake"""

def CDLHOMINGPIGEON(open, high, low, close):
    """Homing Pigeon - Bullish reversal pattern"""

def CDLINNECK(open, high, low, close):
    """In-Neck Pattern - Bearish continuation pattern"""

def CDLKICKING(open, high, low, close):
    """Kicking - Strong reversal pattern with gaps"""

def CDLKICKINGBYLENGTH(open, high, low, close):
    """Kicking - bull/bear determined by the longer marubozu"""

def CDLLADDERBOTTOM(open, high, low, close):
    """Ladder Bottom - Bullish reversal pattern"""

def CDLLONGLINE(open, high, low, close):
    """Long Line Candle - Candle with unusually long body"""

def CDLMATCHINGLOW(open, high, low, close):
    """Matching Low - Bullish reversal pattern"""

def CDLONNECK(open, high, low, close):
    """On-Neck Pattern - Bearish continuation pattern"""

def CDLRICKSHAWMAN(open, high, low, close):
    """Rickshaw Man - Indecision pattern similar to long-legged doji"""

def CDLRISEFALL3METHODS(open, high, low, close):
    """Rising/Falling Three Methods - Continuation pattern"""

def CDLSEPARATINGLINES(open, high, low, close):
    """Separating Lines - Continuation pattern"""

def CDLSHORTLINE(open, high, low, close):
    """Short Line Candle - Candle with unusually short body"""

def CDLSPINNINGTOP(open, high, low, close):
    """Spinning Top - Indecision pattern with small body and shadows"""

def CDLSTALLEDPATTERN(open, high, low, close):
    """Stalled Pattern - Bearish reversal in uptrend"""

def CDLSTICKSANDWICH(open, high, low, close):
    """Stick Sandwich - Bullish reversal pattern"""

def CDLTAKURI(open, high, low, close):
    """Takuri (Dragonfly Doji with very long lower shadow)"""

def CDLTASUKIGAP(open, high, low, close):
    """Tasuki Gap - Continuation pattern"""

def CDLTHRUSTING(open, high, low, close):
    """Thrusting Pattern - Bearish continuation pattern"""

def CDLTRISTAR(open, high, low, close):
    """Tristar Pattern - Rare reversal pattern with three doji"""

def CDLUNIQUE3RIVER(open, high, low, close):
    """Unique 3 River - Bullish reversal pattern"""

Usage Examples

import talib
import numpy as np

# Sample OHLC data
open_prices = np.array([100.0, 101.0, 102.0, 101.5, 103.0])
high_prices = np.array([100.5, 102.0, 102.5, 102.0, 103.5])
low_prices = np.array([99.5, 100.5, 101.0, 100.8, 102.5])
close_prices = np.array([100.2, 101.8, 101.2, 102.2, 103.2])

# Detect various candlestick patterns
doji = talib.CDLDOJI(open_prices, high_prices, low_prices, close_prices)
hammer = talib.CDLHAMMER(open_prices, high_prices, low_prices, close_prices)
engulfing = talib.CDLENGULFING(open_prices, high_prices, low_prices, close_prices)

# Check for patterns in the last period
if doji[-1] != 0:
    print("Doji pattern detected")
if hammer[-1] == 100:
    print("Bullish hammer detected")
elif hammer[-1] == -100:
    print("Bearish hammer detected")

# Morning star with custom penetration threshold
morning_star = talib.CDLMORNINGSTAR(open_prices, high_prices, low_prices, close_prices, penetration=0.3)

Install with Tessl CLI

npx tessl i tessl/pypi-ta-lib

docs

abstract-streaming.md

cycle-indicators.md

index.md

math-operations.md

momentum-indicators.md

overlap-studies.md

pattern-recognition.md

price-transform.md

statistical-functions.md

volatility-indicators.md

volume-indicators.md

tile.json