stock-pattern icon indicating copy to clipboard operation
stock-pattern copied to clipboard

A python scanner to detect and plot common chart patterns

Stock-Pattern

A Python CLI scanner to detect and plot common chart patterns

Supports Python >= 3.8 (As of v1.1.1-alpha)

If you :heart: my work so far, please :star2: this repo.

stock-pattern-cli

These were a series of pattern scanners I wrote for experimentation and fun in 2022. My inspiration was this Medium article Algorithmically Detecting (and Trading) Technical Chart Patterns with Python

Understand how the code works: wiki Pattern Algorithms

Important Info

All patterns are detected, prior to breakout. at the last leg of the pattern. Add the stock to your watchlist and track them further.

This program does not provide any buy or sell signals. It only detects the pattern. It is upto you to decide, if a pattern is valid or tradeable.

Installation

Stock-Pattern is being constantly updated with new features and bug fixes. Run git pull to get the latest updates.

  1. Clone or download the repo:
    git clone https://github.com/BennyThadikaran/stock-pattern.git
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Run init.py. It will generate a user.json file
  4. Open user.json and edit the DATA_PATH with the folder path to your OHLC data. Files must be in CSV format in any timeframe.
    • If using EOD2 point it to src/eod2_data/daily
    • Optionally, add a SYM_LIST with a file path (CSV or TXT file) containing a list of symbols to scan. (One on each line). It will serve as a default watchlist to scan. See wiki Usage
    • Windows users: add an extra backslash for file paths to avoid JSON decode errors. \\Documents\\python\\stock-pattern
  5. See wiki Configuration for more options
{
  "DATA_PATH": "~/Documents/python/eod2/src/eod2_data/daily",
  "POST_SCAN_PLOT": true,
  "SYM_LIST": "./nifty_500.csv",
  "SAVE_STATE": false
}

Usage

See wiki Usage instructions

For backtest.py usage, see wiki backtest

Screenshots

HUDCO - Double Bottom 16th June 2022

HUDCO - Double Bottom

GRAPHITE - Bear VCP 18th Oct 2022

GRAPHITE - Bear VCP

MGL - Reverse Head & Shoulder 16th June 2022

MGL - Reverse Head & Shoulder

GSFC - Triangle 13th March 2023

GSFC - Triangle pattern

RECLTD - Double Tops 13th Oct 2021

RECLTD Double Top pattern

Disclaimer

This program identifies common chart patterns and does it reasonably well (IMHO).

Stock-Pattern is not aimed at replacing a trader's trained eye. It is merely an assistance and learning tool.

CLI options available, for you to backtest the patterns. If you intend to trade these patterns, study them well and trade at your own risk.