Chart Vision — Complete Pipeline
Overview
Unified skill covering the entire chart image pipeline in one place:
- Rendering — produce high-quality candlestick chart images from OHLCV data
- Preprocessing — clean, denoise, and normalize raw chart screenshots
- Candlestick Vision — detect single and multi-candle patterns from images
- Chart Pattern Vision — detect H&S, triangles, wedges, double tops from images
- Pattern Scanner — algorithmic classical pattern detection from price data
- Trendline & S/R Vision — detect trendlines, channels, S/R zones from images
- Annotation Overlay — draw all analysis results back onto the chart image
Pipeline Order
chart-vision-renderer → render OHLCV to PNG
chart-image-preprocessor → clean, denoise, extract ROI
chart-pattern-vision → detect candle + chart patterns from image
trendline-sr-vision → detect S/R and trendlines from image
chart-pattern-scanner → detect patterns from price data (no image needed)
chart-annotation-overlay → draw everything back onto chart ← final step
Reference Files
| File |
Contents |
references/rendering.md |
Chart renderer: mplfinance + matplotlib, indicators, dark/light themes |
references/preprocessing.md |
Image preprocessing: denoise, ROI extract, grid removal, contrast, color analysis |
references/pattern-vision.md |
CV candlestick detection + classical chart pattern detection from images |
references/trendline-sr.md |
Hough transforms, LSD, horizontal projection, S/R clustering, channels |
references/scanner-and-annotation.md |
Price-data pattern scanner (swing-based) + annotation overlay drawing engine |
Stack
- mplfinance — candlestick rendering
- matplotlib 3.10 — rendering engine
- OpenCV 4.13 — all CV operations (Hough, LSD, morphology, edge detection, drawing)
- scikit-image 0.26 — region props, probabilistic Hough, restoration
- scipy 1.17 — peak finding, signal processing, clustering
- Pillow 12.1 — text rendering, image post-processing
- numpy 2.4 — array operations
- sklearn — RandomForest, GradientBoosting, calibration, TimeSeriesSplit (AI signal aggregation & ML)
- statsmodels — ADF, Granger causality (statistical analysis)
Quick Usage Examples
Render a chart from OHLCV data
import mplfinance as mpf
import pandas as pd
df = pd.read_csv("ohlcv.csv", index_col="date", parse_dates=True)
mpf.plot(df, type="candle", style="charles", volume=True,
mav=(20, 50), savefig="chart.png", figsize=(14, 8))
Preprocess a chart screenshot
import cv2
import numpy as np
img = cv2.imread("screenshot.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Remove grid lines
denoised = cv2.fastNlMeansDenoising(gray, h=15)
# Enhance edges for pattern detection
edges = cv2.Canny(denoised, 50, 150)
# Extract ROI (crop to chart area)
contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
largest = max(contours, key=cv2.contourArea)
x, y, w, h = cv2.boundingRect(largest)
chart_roi = img[y:y+h, x:x+w]
Detect support/resistance from image
from scipy.signal import find_peaks
# Project pixel intensities horizontally to find price levels
projection = np.mean(gray, axis=1)
peaks, props = find_peaks(-projection, distance=20, prominence=10)
sr_levels = peaks # pixel y-coordinates of S/R lines
# Draw detected levels
for level in sr_levels:
cv2.line(img, (0, level), (img.shape[1], level), (0, 255, 0), 1)
Annotate chart with analysis
from PIL import Image, ImageDraw, ImageFont
img = Image.open("chart.png")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("arial.ttf", 14)
# Draw buy signal
draw.text((entry_x, entry_y - 20), "BUY", fill="green", font=font)
draw.rectangle([sl_x-2, sl_y-2, sl_x+2, sl_y+2], fill="red")
draw.text((sl_x + 5, sl_y), f"SL: {sl_price:.5f}", fill="red", font=font)
draw.text((tp_x + 5, tp_y), f"TP: {tp_price:.5f}", fill="green", font=font)
img.save("annotated_chart.png")
1---2name: chart-vision3description: Complete chart vision pipeline — render charts, preprocess images, detect candlestick patterns, detect classical chart patterns, detect trendlines and S/R levels, and annotate results back onto charts. Use this skill for ANY chart image task: "render a chart", "create chart image", "screenshot chart", "generate candlestick chart", "draw chart with indicators", "produce chart for analysis", "make a chart PNG", "render OHLCV", "chart to image", "visual chart output", "clean chart image", "preprocess chart", "enhance chart", "remove grid from chart", "prepare chart for analysis", "normalize chart image", "read candles from image", "what candlestick pattern is this", "analyze candles in screenshot", "identify candle pattern from chart", "visual candle detection", "find patterns in chart image", "what chart pattern is this", "pattern recognition from screenshot", "detect triangle from chart image", "visual pattern scan", "AI chart pattern detection", "head and shoulders from image", "detect double top from screens4---56# Chart Vision — Complete Pipeline78## Overview9Unified skill covering the entire chart image pipeline in one place:10111. **Rendering** — produce high-quality candlestick chart images from OHLCV data122. **Preprocessing** — clean, denoise, and normalize raw chart screenshots133. **Candlestick Vision** — detect single and multi-candle patterns from images144. **Chart Pattern Vision** — detect H&S, triangles, wedges, double tops from images155. **Pattern Scanner** — algorithmic classical pattern detection from price data166. **Trendline & S/R Vision** — detect trendlines, channels, S/R zones from images177. **Annotation Overlay** — draw all analysis results back onto the chart image1819## Pipeline Order20```21chart-vision-renderer → render OHLCV to PNG22chart-image-preprocessor → clean, denoise, extract ROI23chart-pattern-vision → detect candle + chart patterns from image24trendline-sr-vision → detect S/R and trendlines from image25chart-pattern-scanner → detect patterns from price data (no image needed)26chart-annotation-overlay → draw everything back onto chart ← final step27```2829## Reference Files3031| File | Contents |32|------|----------|33| `references/rendering.md` | Chart renderer: mplfinance + matplotlib, indicators, dark/light themes |34| `references/preprocessing.md` | Image preprocessing: denoise, ROI extract, grid removal, contrast, color analysis |35| `references/pattern-vision.md` | CV candlestick detection + classical chart pattern detection from images |36| `references/trendline-sr.md` | Hough transforms, LSD, horizontal projection, S/R clustering, channels |37| `references/scanner-and-annotation.md` | Price-data pattern scanner (swing-based) + annotation overlay drawing engine |3839## Stack40- **mplfinance** — candlestick rendering41- **matplotlib 3.10** — rendering engine42- **OpenCV 4.13** — all CV operations (Hough, LSD, morphology, edge detection, drawing)43- **scikit-image 0.26** — region props, probabilistic Hough, restoration44- **scipy 1.17** — peak finding, signal processing, clustering45- **Pillow 12.1** — text rendering, image post-processing46- **numpy 2.4** — array operations47- **sklearn** — RandomForest, GradientBoosting, calibration, TimeSeriesSplit (AI signal aggregation & ML)48- **statsmodels** — ADF, Granger causality (statistical analysis)4950## Quick Usage Examples5152### Render a chart from OHLCV data5354```python55import mplfinance as mpf56import pandas as pd5758df = pd.read_csv("ohlcv.csv", index_col="date", parse_dates=True)59mpf.plot(df, type="candle", style="charles", volume=True,60 mav=(20, 50), savefig="chart.png", figsize=(14, 8))61```6263### Preprocess a chart screenshot6465```python66import cv267import numpy as np6869img = cv2.imread("screenshot.png")70gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)71# Remove grid lines72denoised = cv2.fastNlMeansDenoising(gray, h=15)73# Enhance edges for pattern detection74edges = cv2.Canny(denoised, 50, 150)75# Extract ROI (crop to chart area)76contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)77largest = max(contours, key=cv2.contourArea)78x, y, w, h = cv2.boundingRect(largest)79chart_roi = img[y:y+h, x:x+w]80```8182### Detect support/resistance from image8384```python85from scipy.signal import find_peaks8687# Project pixel intensities horizontally to find price levels88projection = np.mean(gray, axis=1)89peaks, props = find_peaks(-projection, distance=20, prominence=10)90sr_levels = peaks # pixel y-coordinates of S/R lines9192# Draw detected levels93for level in sr_levels:94 cv2.line(img, (0, level), (img.shape[1], level), (0, 255, 0), 1)95```9697### Annotate chart with analysis9899```python100from PIL import Image, ImageDraw, ImageFont101102img = Image.open("chart.png")103draw = ImageDraw.Draw(img)104font = ImageFont.truetype("arial.ttf", 14)105106# Draw buy signal107draw.text((entry_x, entry_y - 20), "BUY", fill="green", font=font)108draw.rectangle([sl_x-2, sl_y-2, sl_x+2, sl_y+2], fill="red")109draw.text((sl_x + 5, sl_y), f"SL: {sl_price:.5f}", fill="red", font=font)110draw.text((tp_x + 5, tp_y), f"TP: {tp_price:.5f}", fill="green", font=font)111img.save("annotated_chart.png")112```