Seungchan
Seungchan

Reputation: 3

Pinescript: Pivot line plotting issue

Photo

Hi I have written this code to display pivot, but pivot lines (red,orange,yellow) on the current bar seem weird like the photo above, and I want to make it straight or continued just as the pivot lines on the previous bars. Their values just suddenly change from the previous to the current bar. My intention is displaying pivots from the yesterday's data throughout the bars today. Could anyone please help me to fix this, please? The version is @5.

pma = request.security(syminfo.tickerid, 'D', hlc3[1])
diff = request.security(syminfo.tickerid, 'D', hl2[1])
pr = pma-diff
ph = pma+pr
pl = pma-pr
plot(pma, linewidth=2, color=color.new(color.orange, 0))
plot(ph, linewidth=2, color=color.new(color.red,0))
plot(pl, linewidth=2, color=color.new(color.yellow,0))

Upvotes: 0

Views: 264

Answers (1)

Dave
Dave

Reputation: 865

Use the lookahead parameter

pma = request.security(syminfo.tickerid, 'D', hlc3[1],barmerge.gaps_off, barmerge.lookahead_on)
diff = request.security(syminfo.tickerid, 'D', hl2[1], barmerge.gaps_off, barmerge.lookahead_on)

Source: https://www.tradingview.com/pine-script-reference/v5/#fun_request{dot}security

Upvotes: 0

Related Questions