-
Notifications
You must be signed in to change notification settings - Fork 44
Using chart.py
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.pyrequires Python 3.10 or newer. The examples below use the Windowspylauncher. Replacepywithpythonwhere appropriate.
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 -hUse --sym followed by one or more symbols:
py chart.py --sym reliance tcs infySymbols are displayed in the order provided.
Common indices can also be entered using aliases:
py chart.py --sym n50 nbankRun --ls to see all available index aliases.
Use -f or --file to load symbols from any file:
py chart.py -f watch.csvThe 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.
Use --watch to open a previously registered watchlist:
py chart.py --watch momentumWatchlist names are not case-sensitive.
To continue from the last chart viewed in that watchlist, add --resume:
py chart.py --watch momentum --resumeThe resume position is saved when the chart application is exited with Q.
Use -b or --breadth to display market-breadth charts:
py chart.py --breadthWith 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 adlineAvailable 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 n50The default breadth index is Nifty 500.
Associate a name with a symbol file:
py chart.py --watch-add momentum watch.csvYou can then open it using:
py chart.py --watch momentumpy chart.py --watch-rm momentumRemoving a watchlist removes its saved registration and resume position. It does not delete the original symbol file.
Use --ls to display:
- Registered watchlists
- Saved presets
- Available index aliases
py chart.py --lsA 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 wRemove a preset with:
py chart.py --preset-rm rsIndicators can be added to any stock chart command.
py chart.py --sym reliance --volumeShort form:
py chart.py --sym reliance -vProvide one or more periods:
py chart.py --sym reliance --sma 20 50 200py chart.py --sym reliance --ema 10 21py chart.py --sym reliance --volume --vol-sma 20py chart.py --sym reliance --rspy chart.py --sym reliance --m-rsUse --snr for the default version:
py chart.py --sym reliance --snrThis is equivalent to --snr v1.
Use version 2 for levels based on multiple touch points:
py chart.py --sym reliance --snr v2py chart.py --sym reliance --dlvDelivery data is available only for daily charts. It cannot be used with weekly, monthly, or quarterly timeframes.
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 wUse --period to control how many candles are displayed:
py chart.py --sym reliance --period 150The value must be greater than zero.
Use -d or --date with an ISO-formatted date:
py chart.py --sym reliance --date 2026-06-30The required format is:
YYYY-MM-DD
--resume or -r starts a named watchlist from its last saved position:
py chart.py --watch momentum -rThis option works only with --watch.
Use -s or --save to save charts as PNG files instead of opening the interactive chart window:
py chart.py --sym reliance tcs --saveSaved 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 --saveThe 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.
Without --save, chart.py opens an interactive chart window.
The chart title shows the current position in the symbol list:
#4 of 30
| 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.
To jump directly to another position in the current symbol list:
- Type the chart number.
- 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.
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
Qto close the application cleanly and save selections, drawings, and watchlist resume progress.
Drawing tools are available on stock charts and can be used to mark levels, trendlines, and chart patterns.
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.
Left-click once at the required price level:
Left-click
The line extends across the chart.
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.
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.
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.
Right-click directly on the line:
Right-click the line
Hold Shift and right-click on the chart:
Shift + right-click
This removes every drawing for the currently displayed symbol and timeframe.
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.
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.