You are on page 1of 2

//Plots VWAP and MVWAP for intraday trading.

Useful to avoid whipsaws


//Market structure is important to take any trades
//Avoid taking trades close to support and resistance
// Update August 23 Added Daily and weekly pivot support. For intraday use daily
pivots on lower time frme charts.
//For positional trades use Daily chart with weekly pivots.
//Added support for pivot range
//Credit Chris moody script for Pivot Point calculations
study("VWAP MVWAP with pivot points", overlay = true)
avlen = input(50)
color1 = blue
color2 = black
mvwap = ema(vwap,avlen)
plot(vwap,linewidth = 2,style = circles, color = color2)
plot(mvwap,color= color1)

sd = input(true, title="Show Daily Pivots?")


sw = input(false, title="Show Weekly Pivots?")
//sm = input(false, title="Show Monthly Pivots?")
//sq = input(false, title="Show Quarterly Pivots?")
//sy = input(false, title="Show Yearly Pivots?")
sh3 = input(false, title="Show R3 & S3?")
shprange = input( true, title = "Show Pivot Range ?")

//Classic Pivot Calculations


pivot = (high + low + close ) / 3.0
r1 = pivot + (pivot - low)
s1 = pivot - (high - pivot)
r2 = pivot + (high - low)
s2 = pivot - (high - low)
r3 = sh3 and r1 + (high - low) ? r1 + (high - low) : na
s3 = sh3 and s1 - (high - low) ? s1 - (high - low) : na

bc = (high + low ) / 2.0


tc = (pivot - bc) + pivot

//Daily Pivot Range


dtime_pivot = security(tickerid, 'D', pivot[1])
dtime_bc = security(tickerid, 'D', bc[1])
dtime_tc = security(tickerid, 'D', tc[1])

//Daily Pivots
//dtime_pivot = security(tickerid, 'D', pivot[1])
dtime_r1 = security(tickerid, 'D', r1[1])
dtime_s1 = security(tickerid, 'D', s1[1])
dtime_r2 = security(tickerid, 'D', r2[1])
dtime_s2 = security(tickerid, 'D', s2[1])
dtime_r3 = security(tickerid, 'D', r3[1])
dtime_s3 = security(tickerid, 'D', s3[1])

offs_daily = 0
plot(sd and dtime_pivot ? dtime_pivot : na, title="Daily Pivot",style=circles,
color=fuchsia,linewidth=2)
plot(sd and dtime_r1 ? dtime_r1 : na, title="Daily R1",style=circles,
color=#DC143C,linewidth=2)
plot(sd and dtime_s1 ? dtime_s1 : na, title="Daily S1",style=circles,
color=lime,linewidth=2)
plot(sd and dtime_r2 ? dtime_r2 : na, title="Daily R2",style=circles,
color=maroon,linewidth=2)
plot(sd and dtime_s2 ? dtime_s2 : na, title="Daily S2",style=circles,
color=#228B22,linewidth=2)
plot(sd and dtime_r3 ? dtime_r3 : na, title="Daily R3",style=circles,
color=#FA8072,linewidth=2)
plot(sd and dtime_s3 ? dtime_s3 : na, title="Daily S3",style=circles,
color=#CD5C5C,linewidth=2)

plot(shprange and dtime_bc ? dtime_bc : na, title="Daily BC",style=circles,


color=blue,linewidth=2)
plot(shprange and dtime_tc ? dtime_tc : na, title="Daily TC",style=circles,
color=blue,linewidth=2)

//Weekly Pivots
wtime_pivot = security(tickerid, 'W', pivot[1])
wtime_R1 = security(tickerid, 'W', r1[1])
wtime_S1 = security(tickerid, 'W', s1[1])
wtime_R2 = security(tickerid, 'W', r2[1])
wtime_S2 = security(tickerid, 'W', s2[1])
wtime_R3 = security(tickerid, 'W', r3[1])
wtime_S3 = security(tickerid, 'W', s3[1])

plot(sw and wtime_pivot ? wtime_pivot : na, title="Weekly Pivot",style=circles,


color=fuchsia,linewidth=4)
plot(sw and wtime_R1 ? wtime_R1 : na, title="Weekly R1",style=circles,
color=#DC143C,linewidth=4)
plot(sw and wtime_S1 ? wtime_S1 : na, title="Weekly S1",style=circles,
color=lime,linewidth=4)
plot(sw and wtime_R2 ? wtime_R2 : na, title="Weekly R2",style=circles,
color=maroon,linewidth=4)
plot(sw and wtime_S2 ? wtime_S2 : na, title="Weekly S2",style=circles,
color=#228B22,linewidth=4)
plot(sw and wtime_R3 ? wtime_R3 : na, title="Weekly R3",style=circles,
color=#FA8072,linewidth=4)
plot(sw and wtime_S3 ? wtime_S3 : na, title="Weekly S3",style=circles,
color=#CD5C5C,linewidth=4)

You might also like