最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

pine script - Getting different plots for the same pivot timeframe setting on two different chart timeframes - Stack Overflow

programmeradmin3浏览0评论

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))

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论