Skip to content

Plot.py ‐ Basic Usage

Benny Thadikaran edited this page Aug 16, 2023 · 23 revisions

15th Aug 2023 WIP: New plot.py is ready and will be pushed in a day or two. Just updating documentation ahead of time

Plot.py has been rewritten to provide improved, customizable charts and new indicators for analysis. It works like any command line application with options.

Plotting a chart

To plot a single chart, use the --sym option providing the symbol name. You can also provide multiple symbols but for now lets stick to one.

py plot.py --sym tcs

TCS basic chart

Press 'q' to quit the chart.

By default, plot.py uses the daily timeframe. To display weekly timeframe charts, use --tf option passing the 'weekly' argument.

py plot.py --sym tcs --tf weekly

Chart Indicators

Volume

To add volume, use -v or --volume

py plot.py --sym sunpharma -v

Sunpharma chart with volume

Moving Averages

To add Simple moving average to the chart, use --sma.

py plot.py --sym icicibank --sma 50

To add Exponential moving average, use --ema.

py plot.py --sym icicibank --ema 30

EMA is calculated exactly the same as TradingView. (Switch on adjusted prices to compare)

To add multiple moving averages, use space separated values.

py plot.py --sym icicibank --sma 50 100 200

Icicibank chart with 50, 100 and 200 sma

Dorsey Relative Strength

This is calculated by dividing the stock closing price by the index closing price. It uses 'Nifty 50' by default but can be configured to use any index.

A rising RS indicates the stock is outperforming the index and vice versa. You can read this excellent article on Dorsey Relative Strength - chartmill.com for more info.

To add this indicator to chart, use --rs option

py plot.py --sym escorts --rs

Escorts chart with Dorsey Relative strength indicator

Manfeild Relative Strength

I read about this indicator in Stan Weinstein's book 'Secrets For Profiting in Bull and Bear Markets'. I highly recommend you to read the book.

The Manfeild Relative Strength (MRS) is calculated by dividing the regular RS by its 52 period moving average.

MRS = ( RS / SMA(RS, 52) - 1 ) * 100

This essentially compares the RS to its 52 period moving average.

  • MRS is 0, if RS is exactly equal to its moving average.
  • MRS is below 0, if RS is below its moving average.
  • MRS is above 0, if RS is above its moving average.

This is the same as Dorsey RS with the additional MA comparison.

You can read more on Manfeild Relative Strength - chartmill.com. Also read Stan Weinstein's book which provides numerous examples on using this indicator.

To add this indicator to chart, use --m-rs option. It is best used with the weekly chart.

py plot.py --sym 'm&m' --tf weekly --m-rs

Take note 'm&m' in single quotes. Stocks with '&' and <space> characters in the name must be quoted to avoid errors.

Other examples would be 'nifty 50', 'il&fseng'.

M&M weekly chart with Manfield relative strength indicator

Notice the helpful zero line (dashed line) on the indicator in the chart above.

To replicate the charts from Stan Weinstein's book, see below

py plot.py --sym tcs --tf weekly -v --m-rs --sma 30

TCS weekly chart with 30 Week MA, Manfield RS and volume

Support and Resistance

We can plot support and resistance lines on chart with the --snr option.

  • A resistance level is marked when, 2 candles with successive highs are followed by 2 candles with successive lows.
  • A support level is marked when, 2 candles with successive lows are followed by 2 candles with successive highs.

To simplify, its a 4 bar V shaped price rejection. It's not perfect but does its job reasonably well. See the chart below.

Ratnamani weekly chart with support and resistance

You don't have to type all these options every time. I will show you an easier way in the next section.

Play around with these options and familiarize yourself before moving to the next section.

Next we work with watchlists and presets.