Skip to content

A Python CLI tool to scan, detect, and plot stock chart patterns

License

Notifications You must be signed in to change notification settings

BennyThadikaran/stock-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock-Pattern

A Python CLI scanner to detect and plot common chart patterns

Supports Python >= 3.8

UPDATE: v3.2.2 adds support for trendline detection and AB=CD harmonic pattern (Experimental work-in-progress)

If you ❤️ my work so far, please 🌟 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

  1. Clone or download the repo:

    git clone https://github.com/BennyThadikaran/stock-pattern.git
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Setup configuration file with setup-config.py and answer the questions to generate a user.json

    py setup-config.py
    • Use direction keys to select a choice and press ENTER.
    • TAB key can be used to autocomplete filepaths. Use forward slashes / regardless of your OS to specify filepaths.
    • By default, filepath is mapped to your home folder /home/YourUsername on mac/linux and C:/Users/YourUsername on Windows.
    • You can use ../../ to go to C drive.

    Alternatively, I've written step by step instructions to create user.json manually

Usage

See Quick usage summary

See Usage instructions

See Configuration

For backtest.py usage, see wiki backtest

Notes on structure of OHLC data

  • The following columns are expected: Open, High, Low, Close, Volume. Additonal columns may exist.

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.