matplotlib / matplotlib/mplfinance

Feature Request: Moving Average on Volume panel

Open
#216 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
4.4k
Forks
678
PR merge metrics
No merged PRs in 30d

Description

How to add moving average on Volume Panel (panel = 1) if volume is set to True.
I have plotted mav(9,26) in Panel 0 using 'mav' function
If I edit and enter Volume = False and add Volume in Panel 1 using addplot funtion. Color of the volume candles becomes solid blue irrespective of the color of the candle in Panel '0'

EDIT:
here is a part of the code

#chart style parameters and plotting function
mc = mpf.make_marketcolors(up='g',down='r',
edge='inherit',
wick='black',
volume='in',
ohlc='i')
s = mpf.make_mpf_style(marketcolors=mc)
apc = [mpf.make_addplot(stck['rsi'].iloc[170:],panel=2,color='g',type = 'line',ylabel='RSI'),
mpf.make_addplot(stck['rsi_overbought'].iloc[170:], panel=2,color='blue',type = 'line',linestyle='-.',secondary_y=False),
mpf.make_addplot(stck['rsi_oversold'].iloc[170:], panel=2,color='red',type = 'line',linestyle='-.', secondary_y=False),
mpf.make_addplot(stck['Volume'].iloc[170:],panel =1,type = 'bar', mav = 10,color = 'in')]

mpf.plot(stck.iloc[170:], type='candlestick', volume=False,title = ticker, tight_layout=True, hlines=ml_results,
mav=(9,26), style = s, returnfig=True,addplot = apc)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the make_addplot call for the volume series and the mpf.plot invocation shown in the issue, focusing on panel 1 with volume=False. Trace how the volume bar colors and moving-average option are handled for an addplot, then verify that the volume panel displays the requested moving average and preserves the intended candle colors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.