Skip to content

Commit 709906d

Browse files
increase mav limit from 3 to 7 different mavs
1 parent 5a373b6 commit 709906d

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ For more examples of using mplfinance, please see the jupyter notebooks in the `
536536

537537
| Version | Description | Release Date |
538538
|----------|--------------|----------------|
539+
| 0.12.0a3 | Increase mav limit from 3 to 7 different mavs | 2020-01-16 |
539540
| 0.12.0a2 | Ability to save plot to a file (pdf, svg, png, jpg, ...) | 2020-01-14 |
540541
| 0.12.0a1 | Ability to plot arbitrary user data (in addition to basic OHLCV data).<br> - both line and scatter plots available.<br> - optionally plot on either the "main" or "lower" (aka "volume") axis. | 2020-01-09 |
541542
| 0.11.x | Basic Plotting from Pandas DataFrame of OHLC bars and candlesticks.<br> - optional display of volume<br> - optional display of (up to 3 different) moving averages.<br> - old API still available by importing from "mplfinance/original_flavor" | 2019-12-20 |

src/mplfinance/_arg_validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def _mav_validator(mav_value):
4242
'''
4343
Value for mav (moving average) keyword may be:
4444
scalar int greater than 1, or tuple of ints, or list of ints (greater than 1).
45-
tuple or list limited to length of 3 moving averages (to keep the plot clean).
45+
tuple or list limited to length of 7 moving averages (to keep the plot clean).
4646
'''
4747
if isinstance(mav_value,int) and mav_value > 1:
4848
return True
4949
elif not isinstance(mav_value,tuple) and not isinstance(mav_value,list):
5050
return False
5151

52-
if not len(mav_value) < 4:
52+
if not len(mav_value) < 8:
5353
return False
5454
for num in mav_value:
5555
if not isinstance(num,int) and num > 1:

src/mplfinance/plotting.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,11 @@ def plot( data, **kwargs ):
260260
if mavgs is not None:
261261
if isinstance(mavgs,int):
262262
mavgs = mavgs, # convert to tuple
263-
if len(mavgs) > 3:
264-
mavgs = mavgs[0:3] # take at most 3
265-
mavcolors=['turquoise','magenta','gold']
266-
jj = 0
263+
if len(mavgs) > 7:
264+
mavgs = mavgs[0:7] # take at most 7
267265
for mav in mavgs:
268-
mavprices = data['Close'].rolling(mav).mean().values
269-
ax1.plot(xdates, mavprices, color=mavcolors[jj])
270-
jj+=1
266+
mavprices = data['Close'].rolling(mav).mean().values
267+
ax1.plot(xdates, mavprices)
271268

272269
avg_dist_between_points = (xdates[-1] - xdates[0]) / float(len(xdates))
273270
minx = xdates[0] - avg_dist_between_points

0 commit comments

Comments
 (0)