I have been debugging some strange results I was getting when I stumbled on a problem where request.security is not returning consistent results. Indeed, it is massively inconsistent. The following short code demonstrates:
//@version=6
indicator("Weekly EMA50 Consistency Test", overlay = true)
// --- Request Weekly EMA(50) ---
weekly_close = request.security(syminfo.tickerid, "W", close, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off)
weekly_ema50 = ta.ema(weekly_close, 50)
// --- Create Table ---
var table t = table.new(position.top_right, 1, 1, frame_color = color.new(color.gray, 20), frame_width = 1)
// --- Update on last bar only ---
if barstate.islast
val_txt = str.tostring(weekly_ema50, format.mintick)
table.cell(t, 0, 0, val_txt, text_color = color.white, bgcolor = color.new(color.black, 0), text_size = size.large)
This prints a single cell that contains the EMA(50) from the weekly timeframe. I would expect this number to be consistent regardless of the timeframe of the chart I am viewing it from. It isn't. I get variations of over 25% between the 5-minute chart and the 3-month chart.
Can anyone help explain what is going on and what I should do to restore consistency?
Thanks.