0% found this document useful (0 votes)
58 views

Central Pivot Range

Uploaded by

shanmugam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Central Pivot Range

Uploaded by

shanmugam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//@version=4

study(title="CENTRAL PIVOT RANGE", shorttitle="CPR", overlay=true)


showlastSR = input(title = "Show Only Last Period SR", defval = true)

// is this last bar for HTF?


islastSR = showlastSR ? security(syminfo.tickerid, 'D', barstate.islast, lookahead
= true) : true

//Get Candle and Time frameDatabase


pivotType = input(title="CPR TIME FRAME", defval='D')

getSeries(e, timeFrame) =>security(syminfo.tickerid, timeFrame, e,


lookahead=barmerge.lookahead_on)

//Colors
cprColor = color.blue
rColor = color.green
sColor = color.red
phColor = color.navy
plColor = color.maroon

//Line Style & Transparency


lStyle = plot.style_stepline
lTransp = 0

//Fill Transparency
fTransp = 99

//Switches
switch1 = input(title="DAILY CPR", type=input.bool, defval=true)
switch6 = input(title="PREVIOUS DAY HIGH & LOW", type=input.bool, defval=true)

//Main Pivot Data


H = getSeries(high[1], 'D')
L = getSeries(low[1], 'D')
C = getSeries(close[1], 'D')

//Central Pivot Range


P = (H + L + C) / 3
BC = (H + L) / 2
TC = P - BC + P

//Resistance Levels
R1 = P * 2 - L
R2 = P + H - L
R3 = H + 2 * (P - L)
R4 = R3 + R2 - R1

//Support Levels
S1 = P * 2 - H
S2 = P - (H - L)
S3 = L - 2 * (H - P)
S4 = S3 - (S1 - S2)

plot(islastSR and switch1 ? R4 : na, title="R4", color=rColor, transp=lTransp,


style=lStyle)
plot(islastSR and switch1 ? R3 : na, title="R3", color=rColor, transp=lTransp,
style=lStyle)
plot(islastSR and switch1 ? R2 : na, title="R2", color=rColor, transp=lTransp,
style=lStyle)
plot(islastSR and switch1 ? R1 : na, title="R1", color=rColor, transp=lTransp,
style=lStyle)

p1 = plot(islastSR and switch1 ? TC : na, title="TC", color=cprColor,


transp=lTransp, style=lStyle)
plot(islastSR and switch1 ? P : na, title="PIVOT", color=cprColor, transp=lTransp,
style=plot.style_circles)
p2 = plot(islastSR and switch1 ? BC : na, title="BC", color=cprColor,
transp=lTransp, style=lStyle)

plot(islastSR and switch1 ? S1 : na, title="S1", color=sColor, transp=lTransp,


style=lStyle)
plot(islastSR and switch1 ? S2 : na, title="S2", color=sColor, transp=lTransp,
style=lStyle)
plot(islastSR and switch1 ? S3 : na, title="S3", color=sColor, transp=lTransp,
style=lStyle)
plot(islastSR and switch1 ? S4 : na, title="S4", color=sColor, transp=lTransp,
style=lStyle)

//Fill Transparency in CPR


fill(p1, p2, color=color.blue, transp=fTransp)

//Previous Day High and Low


prev_day_high = security(syminfo.tickerid, "D", high[1],
lookahead=barmerge.lookahead_on)
prev_day_low = security(syminfo.tickerid, "D", low[1],
lookahead=barmerge.lookahead_on)

plot(islastSR and switch6 ? prev_day_high : na, title="PDH", color=phColor,


transp=lTransp, linewidth=1, style=lStyle)
plot(islastSR and switch6 ? prev_day_low : na, title="PDL", color=plColor,
transp=lTransp, linewidth=1, style=lStyle)

//Cpr Alert
cprlong=crossover(close,R1)
cprshort=crossunder(close,S1)

//Plot Cpr Alert


plotshape(cprlong, title="R1 Crossing Up", style=shape.triangleup, size=size.tiny,
location=location.belowbar, color=color.green, transp=0)
plotshape(cprshort, title="S1 Crossing Down", style=shape.triangledown,
size=size.tiny, location=location.abovebar, color=color.red, transp=0)

//Previous Day High and Low Alert


pdhlong=crossover(close,prev_day_high)
pdlshort=crossunder(close,prev_day_low)

//Plot Previous Day High and Low Alert


plotshape(pdhlong, title="PDH Crossing Up", style=shape.triangleup, size=size.tiny,
location=location.belowbar, color=color.green, transp=0)
plotshape(pdlshort, title="PDL Crossing Down", style=shape.triangledown,
size=size.tiny, location=location.abovebar, color=color.red, transp=0)

You might also like