I am making a code in pine editor of tradingview in which i want to calculate important pivot point on daily basis.These points are very critical for my strategies.
In after market, the code works perfectly fine with stable lines on daily basis as required. Image of stable lines
But in live market these points keep on changing with passage of time. image in live market
I am confused, what exactly is missing in my code. Pl help.
My code is a simple one:
// @version=4
strategy("RCR GCR", overlay=true)
/////////////////////////Pivot Points//////////////////////////////
// CPR
PP = (high + low + close ) / 3.0
tc = (high + low ) / 2.0
bc = (PP - tc) + PP
//Daily Pivot Range
dtime_pivot = security(syminfo.tickerid, 'D', PP)
dtime_bc = security(syminfo.tickerid, 'D', bc)
dtime_tc = security(syminfo.tickerid, 'D', tc)
plot(dtime_pivot, color=color.purple,linewidth=3)
plot(dtime_bc, color=color.blue,linewidth=3)
plot(dtime_tc, color=color.blue,linewidth=3)
That's because you are using values like close
, high
and low
which change during the realtime bar. This way of calling security()
tells it to use only confirmed prices, so your lines will only move in the realtime bar when a daily bar ends. See How to avoid repainting when using security() - PineCoders FAQ for more info.
// @version=4
strategy("RCR GCR", overlay=true)
/////////////////////////Pivot Points//////////////////////////////
// CPR
PP = (high + low + close ) / 3.0
tc = (high + low ) / 2.0
bc = (PP - tc) + PP
//Daily Pivot Range
dtime_pivot = security(syminfo.tickerid, 'D', PP[1], lookahead = barmerge.lookahead_on)
dtime_bc = security(syminfo.tickerid, 'D', bc[1], lookahead = barmerge.lookahead_on)
dtime_tc = security(syminfo.tickerid, 'D', tc[1], lookahead = barmerge.lookahead_on)
plot(dtime_pivot, color=color.purple,linewidth=3)
plot(dtime_bc, color=color.blue,linewidth=3)
plot(dtime_tc, color=color.blue,linewidth=3)
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.