Skip to content

Using chart.py

Benny Thadikaran edited this page Jul 13, 2026 · 5 revisions

chart.py provides a single command-line interface for viewing stock charts, reviewing market breadth, navigating symbol lists, making selections, drawing annotations, and saving charts as PNG images.

This guide focuses on day-to-day usage. Plugin indicators and configuration options are documented separately.

chart.py requires Python 3.10 or newer. The examples below use the Windows py launcher. Replace py with python where appropriate.

Contents


CLI usage

Commands in chart.py are flexible and do not require a fixed order of options.

Most charting commands require a source option to specify what to plot. The available sources are --sym, --file, --watch, and --breadth.

A typical command combines:

  • A source (what to plot)
  • Optional indicators (what to display)
  • Optional general settings (timeframe, period, saving, etc.)

For example:

py chart.py --sym reliance --sma 20 50 --tf w

Run the built-in help command to see the options available in your installation:

py chart.py -h

Choosing a chart source

Plot individual symbols

Use --sym followed by one or more symbols:

py chart.py --sym reliance tcs infy

Symbols are displayed in the order provided.

Common indices can also be entered using aliases:

py chart.py --sym n50 nbank

Run --ls to see all available index aliases.

Load symbols from a file

Use -f or --file to load symbols from any file:

py chart.py -f watch.csv

The file should contain one symbol per line:

reliance
tcs
infy

This does not register the file as a named watchlist. It is useful for temporary scans or symbol lists generated by another program.

Load a named watchlist

Use --watch to open a previously registered watchlist:

py chart.py --watch momentum

Watchlist names are not case-sensitive.

To continue from the last chart viewed in that watchlist, add --resume:

py chart.py --watch momentum --resume

The resume position is saved when the chart application is exited with Q.

Plot market breadth

Use -b or --breadth to display market-breadth charts:

py chart.py --breadth

With no values, the following breadth charts are displayed:

  • Percentage of stocks above the 50-day and 200-day moving averages
  • Net new highs
  • Advance-decline line
  • McClellan Oscillator

Specific breadth charts can be requested by name:

py chart.py --breadth sma adline

Available values are:

Value Chart
sma Percentage above the 50-day and 200-day moving averages
50 Percentage above the 50-day moving average
200 Percentage above the 200-day moving average
nethighs Cumulative net 52-week highs
adline Advance-decline line
osc McClellan Oscillator

Use -i or --index to select the index plotted alongside the breadth data:

py chart.py --breadth adline -i n50

The default breadth index is Nifty 500.

Managing watchlists and presets

Register a watchlist

Associate a name with a symbol file:

py chart.py --watch-add momentum watch.csv

You can then open it using:

py chart.py --watch momentum

Remove a watchlist

py chart.py --watch-rm momentum

Removing a watchlist removes its saved registration and resume position. It does not delete the original symbol file.

List available items

Use --ls to display:

  • Registered watchlists
  • Saved presets
  • Available index aliases
py chart.py --ls

Save and use presets

A preset stores chart display options such as the timeframe, moving averages, volume, relative strength, and support or resistance settings.

Create a preset by adding --preset-save NAME to a normal chart command. The symbol source is not stored as part of the preset.

When loading a preset, provide a source such as --sym, --watch, --file, or --breadth. Explicit CLI options override the corresponding preset settings.

For example, this loads the rs preset for the momentum watchlist and overrides its timeframe with weekly charts:

py chart.py --preset rs --watch momentum --tf w

Remove a preset with:

py chart.py --preset-rm rs

Adding indicators

Indicators can be added to any stock chart command.

Volume

py chart.py --sym reliance --volume

Short form:

py chart.py --sym reliance -v

Simple moving averages

Provide one or more periods:

py chart.py --sym reliance --sma 20 50 200

Exponential moving averages

py chart.py --sym reliance --ema 10 21

Volume moving averages

py chart.py --sym reliance --volume --vol-sma 20

Dorsey relative strength

py chart.py --sym reliance --rs

Mansfield relative strength

py chart.py --sym reliance --m-rs

Support and resistance

Use --snr for the default version:

py chart.py --sym reliance --snr

This is equivalent to --snr v1.

Use version 2 for levels based on multiple touch points:

py chart.py --sym reliance --snr v2

Delivery data

py chart.py --sym reliance --dlv

Delivery data is available only for daily charts. It cannot be used with weekly, monthly, or quarterly timeframes.

General options

Select a timeframe

Use --tf with one of the following values:

Value Timeframe
d Daily
w Weekly
m Monthly
q Quarterly

Daily is the default.

py chart.py --sym reliance --tf w

Set the number of candles

Use --period to control how many candles are displayed:

py chart.py --sym reliance --period 150

The value must be greater than zero.

End the chart at a specific date

Use -d or --date with an ISO-formatted date:

py chart.py --sym reliance --date 2026-06-30

The required format is:

YYYY-MM-DD

Resume a watchlist

--resume or -r starts a named watchlist from its last saved position:

py chart.py --watch momentum -r

This option works only with --watch.

Saving charts as images

Use -s or --save to save charts as PNG files instead of opening the interactive chart window:

py chart.py --sym reliance tcs --save

Saved images are placed in the SAVED_CHARTS directory in the project root:

SAVED_CHARTS/
├── reliance.png
└── tcs.png

When saving a named watchlist, a subdirectory is created for that watchlist:

py chart.py --watch momentum --save

The resulting files are stored under:

SAVED_CHARTS/<watch_name>/

For example:

SAVED_CHARTS/MOMENTUM/
├── reliance.png
├── tcs.png
└── infy.png

The batch-saving process reports symbols that could not be loaded or saved.


Using an interactive chart

Without --save, chart.py opens an interactive chart window.

The chart title shows the current position in the symbol list:

#4 of 30

Keyboard shortcuts

Key Action
N Open the next chart
P Open the previous chart
Number followed by J Jump to a specific chart
A Add the current symbol to the selection
D Enter or leave draw mode
Shift+H Show or hide the in-chart help
Q Save session data and exit
R Reset the chart to its original view
F Toggle fullscreen mode
G Toggle major grid lines
O Activate rectangle zoom

Use Shift+H at any time to display the available shortcuts directly on the chart.

Jumping to a specific chart

To jump directly to another position in the current symbol list:

  1. Type the chart number.
  2. Press J.

For example, to jump to chart 25:

25J

The entered number is displayed on the chart while it is being typed. The requested number must be within the current list.

Making stock selections

Press A to add the currently displayed symbol to the session selection.

A notification appears on the chart when the symbol is added. Adding the same symbol again does not create a duplicate.

Selections are written to the following file when you exit with Q:

selections.csv

The file is stored in the project root.

Selections do not persist as an active selection set between sessions. Each new run starts with an empty selection. The CSV file provides the results from the completed review session.

Use Q to close the application cleanly and save selections, drawings, and watchlist resume progress.


Drawing on charts

Drawing tools are available on stock charts and can be used to mark levels, trendlines, and chart patterns.

Entering draw mode

Press D to enter draw mode.

The chart displays DRAW MODE while drawing is active. Press D again to leave draw mode.

When a modifier key is pressed, the chart displays a hint describing the selected drawing type.

Drawing lines

Horizontal line

Left-click once at the required price level:

Left-click

The line extends across the chart.

Trendline

Hold Shift and left-click two points:

Shift + left-click first point
Shift + left-click second point

A preview line follows the pointer after the first point is selected.

Continuous segments

Hold Ctrl and left-click the starting point. Continue left-clicking while holding Ctrl to add connected segments:

Ctrl + left-click

Each new point becomes the starting point for the next segment.

Horizontal segment

Hold Ctrl+Shift and left-click two points:

Ctrl + Shift + left-click first point
Ctrl + Shift + left-click second point

The segment uses the price level of the first point.

Deleting drawings

Delete one line

Right-click directly on the line:

Right-click the line

Delete all lines for the current symbol

Hold Shift and right-click on the chart:

Shift + right-click

This removes every drawing for the currently displayed symbol and timeframe.

Drawing persistence

Drawings persist between sessions and are stored in:

data/drawings.json

They are organized by symbol and timeframe.

Drawings are saved per timeframe. A drawing made on a daily chart (--tf d) will not appear on weekly, monthly, or quarterly charts.

Drawings are saved when the application is exited with Q. Use Q rather than closing the chart window directly to ensure the current session is stored.

Migrating old drawings

If you have drawings saved from older versions (stored in pickle format), you can migrate them to the new JSON-based format.

A migration script is included with the project to convert existing drawings automatically. Run the script once, and it will read your old drawing files and write them into data/drawings.json.

After migration:

  • Your existing drawings will be available in the new format.
  • Drawings will be organized by symbol and timeframe.
  • If drawings for a symbol already exist in data/drawings.json, they will be overwritten by the migrated data for that symbol.
  • The old pickle files can be safely removed once you confirm everything has been migrated correctly.

It is recommended to keep a backup of your old drawing files before running the migration.

Clone this wiki locally