im trying to get the ema value of 4 hours rsi in different timeframes, but its returning different data in 4h timeframe and daily for example.
OBS: its working fine on intraday timeframes.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jeckwilke
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jeckwilke
//@version=5
indicator("My script")
rsi = request.security(syminfo.tickerid, str.tostring("240"), ta.rsi(close,14), lookahead = barmerge.lookahead_on)
rsiMa = request.security(syminfo.tickerid, "240", ta.ema(rsi, 7))
plot(rsiMa[1])
plot(rsiMa[2], color = color.purple)
When using request.security()
your chart time has to be equal or lower the timeframe you put into request.*()
.
To compensate this problem you need to use request.security.lower_tf()
instead. In this case your chart time has to be equal or higher than the timeframe you put into request.*()
.
You can read about using other timeframes HERE.