This is a snippet from the code:
Length = (20)
dhigh = request.security(syminfo.tickerid, "1D", high)
dlow = request.security(syminfo.tickerid, "1D", low)
ADR = request.security(syminfo.tickerid, "1D", 100 * (ta.sma(dhigh/dlow, Length) - 1))
I later display ADR value in the table. It should be a constant value on all timeframes, but it is not - it is the same on all below daily timeframes, but not weekly, for example.
How do I make it constant across ALL timeframes? Please, help.
I read manual and could't find answer to that. I also googled for similar issues online, but could not find ideas to try out.
The security() function was designed to request data of a timeframe higher than the current chart timeframe.
If you want to get data from lower timeframes, you should use request.security_lower_tf() function.
Example:
//@version=5
indicator("`request.security_lower_tf()` Example")
float travel = math.abs(high - low)
float[] ltfTravelArray = request.security_lower_tf(syminfo.tickerid, "1", travel)
float volatility = nz(array.sum(ltfTravelArray) / travel)
plot(volatility)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.