Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:TA Lib Ta lib python CDL Signal Interpretation

From Leeroopedia


Knowledge Sources
Domains Technical_Analysis, Pattern_Recognition
Last Updated 2026-02-09 22:00 GMT

Overview

Concrete pattern for interpreting the integer output arrays (-100, 0, +100) from CDL pattern recognition functions.

Description

This is a Pattern Doc documenting how to interpret CDL function outputs. All CDL functions use make_int_array internally to create int32 output arrays. The C library writes -100, 0, or +100 values, which users filter to find pattern occurrences.

Usage

After calling any CDL function, filter the output for non-zero values to identify pattern locations and directions.

Code Reference

Source Location

  • Repository: ta-lib-python
  • File: talib/_func.pxi (all CDL functions use make_int_array and return outinteger)
  • Tests: tests/test_func.py:L146-155 (test_CDL3BLACKCROWS validates -100 bearish signal)

Signature

# Signal interpretation patterns (not a function signature)

# Pattern 1: Find all occurrences
indices = np.where(signal != 0)[0]

# Pattern 2: Separate bullish and bearish
bullish = np.where(signal > 0)[0]
bearish = np.where(signal < 0)[0]

# Pattern 3: Boolean mask
has_pattern = signal != 0

Import

import numpy as np
import talib

I/O Contract

Inputs

Name Type Required Description
signal np.ndarray (int32) Yes Output from any CDL pattern function

Outputs

Name Type Description
occurrences np.ndarray (int) Array indices where patterns were detected
direction int +100 for bullish, -100 for bearish

Usage Examples

Basic Signal Interpretation

import numpy as np
import talib

# Assume OHLC data is available
doji = talib.CDLDOJI(open_p, high, low, close)

# Find all doji patterns
doji_indices = np.where(doji != 0)[0]
for idx in doji_indices:
    direction = "Bullish" if doji[idx] > 0 else "Bearish"
    print(f"Doji at index {idx}: {direction}")

Aggregate Multiple Patterns

# Sum multiple pattern signals for composite scoring
signals = np.zeros(len(close), dtype=int)
signals += talib.CDLDOJI(open_p, high, low, close)
signals += talib.CDLENGULFING(open_p, high, low, close)
signals += talib.CDLMORNINGSTAR(open_p, high, low, close)

# Composite signal: higher positive = stronger bullish
strong_bullish = np.where(signals >= 200)[0]

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment