-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
How to group indicators on one chart? #1045
-
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
Beta Was this translation helpful? Give feedback.
All reactions
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
-
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")
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
-
Beta Was this translation helpful? Give feedback.
All reactions
-
😄 1 -
👀 1
-
Hi,
It was very nice.
Until now, I didn't care about legends, but I took this opportunity to try it.
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?
Beta Was this translation helpful? Give feedback.
All reactions
-
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)
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Thanks, very nice. I will definitely use this.
Beta Was this translation helpful? Give feedback.
All reactions
-
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!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1 -
👀 1