Sei sulla pagina 1di 3

CPR1

//@version=3
study(title="Floor Pivots With CPR", shorttitle="Floor Pivots With CPR",
overlay=true)
defaultTimeFrame = ((isintraday) ? "D" : ((isdaily) ? "W" : ((isweekly) ? "M" :
"3M")))
inputTimeFrame = input(title="Time Frame", type=string, defval="Default")
chosenTimeFrame = (inputTimeFrame == "Default") ? defaultTimeFrame :
inputTimeFrame
getSeries(e, timeFrame) => security(tickerid, timeFrame, e,
lookahead=barmerge.lookahead_on)

H = getSeries(high[1], 'D')
L = getSeries(low[1], 'D')
C = getSeries(close[1], 'D')
// Main Pivot
P = (H + L + C) / 3
BC = (H + L)/2
TC = (P - BC) + P
// Resistence Levels
R3 = H + 2*(P - L)
R2 = P + (H - L)
R1 = (P * 2) - L
// Support Levels
S1 = (P * 2) - H
S2 = P - (H - L)
S3 = L - 2*(H - P)

//UX Input Arguments


pColor = blue
rColor = red
sColor = green
myWidthMainLevels = input(title="Line width for Main levels", type=integer,
defval=2, minval=1)
myStyle = stepline

plot(R3, title="R3", color=rColor, linewidth=myWidthMainLevels, style=myStyle)


plot(R2, title="R2", color=rColor, linewidth=myWidthMainLevels, style=myStyle)
plot(R1, title="R1", color=rColor, linewidth=myWidthMainLevels, style=myStyle)

plot(P, title="P", color=pColor, linewidth=myWidthMainLevels, style=myStyle)


p1 = plot(BC, title="BC", color=pColor, linewidth=myWidthMainLevels,
style=myStyle)
p2 = plot(TC, title="TC", color=pColor, linewidth=myWidthMainLevels,
style=myStyle)
plot(S1, title="S1", color=sColor, linewidth=myWidthMainLevels, style=myStyle)
plot(S2, title="S2", color=sColor, linewidth=myWidthMainLevels, style=myStyle)
plot(S3, title="S3", color=sColor, linewidth=myWidthMainLevels, style=myStyle)
fill(p1, p2, color=yellow, transp=60)

// Weekly Pivots
WH = getSeries(high[1], 'W')
WL = getSeries(low[1], 'W')
WC = getSeries(close[1], 'W')

// Main Pivot
WP = (WH + WL + WC) / 3
WBC = (WH + WL)/2
WTC = (WP - WBC) + WP

Page 1
CPR1
// Resistence Levels
WR3 = WH + 2*(WP - WL)
WR2 = WP + (WH - WL)
WR1 = (WP * 2) - WL
// Support Levels
WS1 = (WP * 2) - WH
WS2 = WP - (WH - WL)
WS3 = WL - 2*(WH - WP)
wStyle = circles
wWidthMainLevels = 2
plot(WR3, title="WR3", color=rColor, linewidth=wWidthMainLevels, style=wStyle)
plot(WR2, title="WR2", color=rColor, linewidth=wWidthMainLevels, style=wStyle)
plot(WR1, title="WR1", color=rColor, linewidth=wWidthMainLevels, style=wStyle)
plot(WP, title="WP", color=pColor, linewidth=myWidthMainLevels, style=cross)
wp1 = plot(WBC, title="WBC", color=pColor, linewidth=myWidthMainLevels,
style=cross)
wp2 = plot(WTC, title="WTC", color=pColor, linewidth=myWidthMainLevels,
style=cross)
plot(WS1, title="WS1", color=sColor, linewidth=wWidthMainLevels, style=wStyle)
plot(WS2, title="WS2", color=sColor, linewidth=wWidthMainLevels, style=wStyle)
plot(WS3, title="WS3", color=sColor, linewidth=wWidthMainLevels, style=wStyle)

fill(wp1, wp2, color=aqua, transp=60)

// Monthly Pivots
MH = getSeries(high[1], 'M')
ML = getSeries(low[1], 'M')
MC = getSeries(close[1], 'M')
// Main Pivot
MP = (MH + ML + MC) / 3
MBC = (MH + ML)/2
MTC = (MP - MBC) + MP

// Resistence Levels
MR3 = MH + 2*(MP - ML)
MR2 = MP + (MH - ML)
MR1 = (MP * 2) - ML
// Support Levels
MS1 = (MP * 2) - MH
MS2 = MP - (MH - ML)
MS3 = ML - 2*(MH - MP)
mStyle = cross
mWidthMainLevels = 2
plot(MR3, title="MR3", color=rColor, linewidth=mWidthMainLevels, style=mStyle)
plot(MR2, title="MR2", color=rColor, linewidth=mWidthMainLevels, style=mStyle)
plot(MR1, title="MR1", color=rColor, linewidth=mWidthMainLevels, style=mStyle)
plot(MP, title="MP", color=pColor, linewidth=myWidthMainLevels, style=stepline)
mp1 = plot(MBC, title="MBC", color=pColor, linewidth=myWidthMainLevels,
style=stepline)
mp2 = plot(MTC, title="MTC", color=pColor, linewidth=myWidthMainLevels,
style=stepline)
plot(MS1, title="MS1", color=sColor, linewidth=mWidthMainLevels, style=mStyle)
plot(MS2, title="MS2", color=sColor, linewidth=mWidthMainLevels, style=mStyle)
plot(MS3, title="MS3", color=sColor, linewidth=mWidthMainLevels, style=mStyle)
fill(mp1, mp2, color=purple, transp=80)

// EMA
Page 2
CPR1
emainterval = input(title="EMA Interval", type=integer, defval=20)
plot(ema(close, emainterval), color=blue, linewidth=2)
// Previous day high low
plot(isintraday ? security(tickerid, 'D', high) : na, title="Daily High",
color=black, linewidth=2, style=dashed)
plot(isintraday ? security(tickerid, 'D', low) : na, title="Daily Low",
color=black, linewidth=2, style=dashed)

Page 3

Potrebbero piacerti anche