Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to group indicators on one chart? #1045

Answered by peacerider
lapitskaya38 asked this question in Q&A
Discussion options

Hi!
I have four indicators (marked in red "V" in the screenshot) Is it possible to group these indicators on one chart, outside the chart with candles?
image

You must be logged in to vote

Hi,

Following discussion is may be helpful.
#195

Example

import talib as ta
self.sma1_ = ta.SMA(close, timeperiod=25)
self.sma2_ = ta.SMA(close, timeperiod=45)
self.sma3_ = ta.SMA(close, timeperiod=75)
self.sma1, self.sma2. self.sma3 = self.I(lambda: (self.sma1_, self.sma2_, self.sma3_), name="sma")

Replies: 3 comments 4 replies

Comment options

Hi,

Following discussion is may be helpful.
#195

Example

import talib as ta
self.sma1_ = ta.SMA(close, timeperiod=25)
self.sma2_ = ta.SMA(close, timeperiod=45)
self.sma3_ = ta.SMA(close, timeperiod=75)
self.sma1, self.sma2. self.sma3 = self.I(lambda: (self.sma1_, self.sma2_, self.sma3_), name="sma")
You must be logged in to vote
2 replies
Comment options

Thanks a lot.
Have also used this #382

Perfect:
image

Comment options

Hi,

It was very nice.
Until now, I didn't care about legends, but I took this opportunity to try it.

image

Succeeded!
Thank you so much.

self.ema1, self.ema2 = self.I(my_ema, close, self.n1, self.n2, overlay=False, legends=['ema1', 'ema2'])

I used the code below.
zlpatel@a95c555

If you don't mind, could you tell me the code you used?

Answer selected by kernc
Comment options

self.M5_ADX_ind, self.M5_MINUS_DI_ind, self.M5_PLUS_DI_ind, self.M5_MA_Tvalue = self.I(lambda: (self.M5_ADX_, self.M5_MINUS_DI_, self.M5_PLUS_DI_, self.M5_MA_), legends=["ADX","MINUS_DI", "PLUS_DI", "Пороговое значение" ], overlay=False)

You must be logged in to vote
2 replies
Comment options

Thanks!

Comment options

Thanks, very nice. I will definitely use this.

Comment options

The cool thing I messed with was dynamic re-scaling of the y-axis. I wanted to plot relative volume, so I created a new plot section, made it a bar chart, added it to the figs_above_ohlc list and then used the CustomJS callback.

The section code is below the _plot_volume_section() function. Code is:

def _plot_rvol_section(): """RVOL section""" fig = new_indicator_figure(y_axis_label="RVOL") fig.height=70 fig.xaxis.visible = False temp = df.copy(deep=True) temp = ut.df_flip_caps(df_in=temp, caps=False) kwargs = {'fill_method': 'bfill'} rvol = rv.ta_rvol(_df=temp, length=50, ma_type='sma', **kwargs) rvol = rvol[rvol.columns[0]] fig.y_range = DataRange1d(bounds=(0, max(rvol))) source.add(rvol.values, name= 'RVOL') r = fig.vbar('index', BAR_WIDTH, 'RVOL', source=source, color=inc_cmap) set_tooltips(fig, [('RVOL', '@RVOL{0.0}')], renderers=[r]) fig.yaxis.formatter = NumeralTickFormatter(format="0 a") return fig

The callback code looked like this:
callback = CustomJS(args={'y_range': fig_rvol.y_range, 'source': source}, code=''

 clearTimeout(window._autoscale_timeout);
 var Index = source.data.index, rvol = source.data.RVOL, start = cb_obj.start, end = cb_obj.end, min = 0, max = -Infinity;
 for (var i=0; i < Index.length; ++i) {
 if (start <= Index[i] && Index[i] <= end) {
 max = Math.max(rvol[i], max); min = Math.min(rvol[i], min);
 } 
 } 
 var pad = (max - min) * .09;
 window._autoscale_timeout = setTimeout(function() {
 y_range.start = min - pad; y_range.end = max + pad; 
 });
 '''.replace('\n', '').replace('\t', '')
 )`

Voila! y-axis now re-sizes dynamically!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /