So im trying to plot Monthly R1,S1 pivot lines. thing is while opening the ticker MSFT chart from nasdaq, on 2H chart its showing the pivot lines at a different location than what it shows on D chart. for example, look at Monthly S1 on 2H and Daily MSFT chart. its at different positions.
i cant seem to figure out where i am going wrong. If anyone can help me, that would be great. code pasted below.
//@version=6
indicator(title = 'Pivots', shorttitle = 'Pivots', overlay = true, max_lines_count = 500, max_boxes_count = 500, max_labels_count = 500)
var tf = input.string('M', 'Timeframe', options = ['W','M'])
max_plot = input.int(10, 'Max Plot')
T_w = 1
R_T = input.color(#e60b09, 'R', inline = 'T')
S_T = input.color(#07f49e, 'S', inline = 'T')
T_lns = input.string(line.style_solid, '', options = [line.style_solid, line.style_dotted, line.style_dashed], inline = 'T')
// CALC
[HIGH, LOW, CLOSE] = request.security(syminfo.tickerid, tf, [high[1], low[1], close[1]], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)
PP = (HIGH + LOW + CLOSE) / 3
R1_T = PP + PP - LOW
S1_T = PP - (HIGH - PP)
// DS
type PIVOT
line ln
label lb
// TRADITIONAL PIVOT ARRAYS
var array<PIVOT> A_R1_T = array.new<PIVOT>()
var array<PIVOT> A_S1_T = array.new<PIVOT>()
// VARs
line ln = na
label lb = na
// FNs
DELETE_PIVOT(P) =>
line.delete(P.ln)
label.delete(P.lb)
ADD_PIVOT(PA, P) =>
if array.size(PA) == max_plot
DELETE_PIVOT(array.shift(PA))
array.push(PA, P)
TEXT(txt) =>
_txt = tf + ' | ' + txt
_txt
// MAIN
if timeframe.change(tf) and timeframe.in_seconds(tf) > timeframe.in_seconds(timeframe.period)
_xloc = xloc.bar_time
_yloc = yloc.price
color_x = color.rgb(255, 255, 255, 100)
_lbs = label.style_label_right
_lbsz = size.normal
_st = time(tf)
_end = time_close(tf)
ln := line.new(_st, R1_T, _end, R1_T, _xloc, extend.none, R_T, T_lns, T_w)
lb := label.new(_st, R1_T, TEXT('R1:T'), _xloc, _yloc, color_x, _lbs, R_T, _lbsz)
ADD_PIVOT(A_R1_T, PIVOT.new(ln, lb))
ln := line.new(_st, S1_T, _end, S1_T,_xloc, extend.none, S_T, T_lns, T_w)
lb := label.new(_st, S1_T, TEXT('S1:T'), _xloc, _yloc, color_x, _lbs, S_T, _lbsz)
ADD_PIVOT(A_S1_T, PIVOT.new(ln, lb))