I'm trying to plotshape() with multiple conditions from 2 or more timeframe and it's not working IF there are 2 or more conditions from the other timeframe which data pulled with request.security().
Please see code with comments on what works and what doesn't, and advise if my code is wrong or this is plotshape() bug. Pine script v5
Thanks, Om
//////// Long and Short Signals by MACD Histogram,
//////// 2 minutes(indicator) AND 5 minutes(through request.security()
indicator(title="Moving Average Convergence Divergence Cross w/ Fill & Signal", shorttitle="MACD Cross w/ Fill & Signal")
// Calculate 2 Min MACD
fast_ma = fast_ma_type == "SMA" ? ta.sma(src, fast_len) : ta.ema(src, fast_len)
slow_ma = fast_ma_type == "SMA" ? ta.sma(src, slow_len) : ta.ema(src, slow_len)
macd = fast_ma - slow_ma
signal = slow_ma_type == "SMA" ? ta.sma(macd, signal_len) : ta.ema(macd, signal_len)
hist = macd - signal
// Get 5 Min Histogram Data
[_, _, hist5] = ta.macd(src, fast_len, slow_len, signal_len)
hist5Min = request.security(syminfo.tickerid, "5", hist5, gaps = barmerge.gaps_off)
// Go Long conditions
go_long2 = hist > hist[1]
go_long5A = hist5Min > hist5Min[1]
go_long5B = hist5Min[1] < hist5Min[2]
// Go Short conditions
go_short2 = hist < hist[1]
go_short5A = hist5Min < hist5Min[1]
go_short5B = hist5Min[1] > hist5Min[2]
// Plots
// This works
plot_shape_condition = timeframe.period == "2"
plotshape((plot_shape_condition and hist < 0 and go_long2 and go_long5A) ? hist:na, style=shape.labelup, color=color.new(color.green, 90), text="⬆", textcolor=color.new(color.green, 0), size=size.tiny, location=location.bottom)
// This DOESN'T work, doesn't plot any shape at all
plotshape((plot_shape_condition and hist < 0 and go_long2 and go_long5A and go_long5B) ? hist:na, style=shape.labelup, color=color.new(color.green, 90), text="⬆", textcolor=color.new(color.green, 0), size=size.tiny, location=location.bottom)
// These works, so there's data for Hist5Min[1] and [2]
plot(hist5Min, color=color.red)
plot(hist5Min[1], color=color.green)
plot(hist5Min[2], color=color.blue)