This indicator embed the daily, weekly and monthly pivot points with choice of their mode of calculation.
Each support and resistance of the daily, weekly and monthly pivot formulas are rendered on chart. Since pivot points indicator is a common request, I found this one to answer perfectly to a lot of them!
This code has been posted on forum by Henry, many thanks to him.
//Pivot calculation method
Once mode = 1
Once dailyPivot = undefined
Once dailyR1 = undefined
Once dailyS1 = undefined
Once dailyR2 = undefined
Once dailyS2 = undefined
Once dailyR3 = undefined
Once dailyS3 = undefined
Once lastWeekBarIndex = 0
Once weeklyHigh = undefined
Once weeklyLow = undefined
Once weeklyPivot = undefined
Once weeklyR1 = undefined
Once weeklyS1 = undefined
Once weeklyR2 = undefined
Once weeklyS2 = undefined
Once weeklyR3 = undefined
Once weeklyS3 = undefined
Once lastMonthBarIndex = 0
Once monthlyHigh = undefined
Once monthlyLow = undefined
Once monthlyPivot = undefined
Once monthlyR1 = undefined
Once monthlyS1 = undefined
Once monthlyR2 = undefined
Once monthlyS2 = undefined
Once monthlyR3 = undefined
Once monthlyS3 = undefined
If Day>Day[1] then
If mode = 0 then
dailyPivot = (DHigh(1) + DLow(1) + Close[1]) / 3
Elsif mode = 1 then
dailyPivot = (Open + DHigh(1) + DLow(1) + Close[1]) / 4
Elsif mode = 2 then
dailyPivot = (DHigh(1) + DLow(1) + Close[1]*2) / 4
Else
dailyPivot = (Open*2 + DHigh(1) + DLow(1)) / 4
Endif
dailyR1 = 2*dailyPivot - DLow(1)
dailyS1 = 2*dailyPivot - DHigh(1)
dailyR2 = dailyPivot + (DHigh(1) - DLow(1))
dailyS2 = dailyPivot - (DHigh(1) - DLow(1))
dailyR3 = dailyR1 + (DHigh(1) - DLow(1))
dailyS3 = dailyS1 - (DHigh(1) - DLow(1))
Endif
If DayOfWeek<DayOfWeek[1] then
weeklyHigh = Highest[BarIndex - lastWeekBarIndex](High)[1]
weeklyLow = Lowest[BarIndex - lastWeekBarIndex](Low)[1]
lastWeekBarIndex = BarIndex
If mode = 0 then
weeklyPivot = (weeklyHigh + weeklyLow + Close[1]) / 3
Elsif mode = 1 then
weeklyPivot = (Open + weeklyHigh + weeklyLow + Close[1]) / 4
Elsif mode = 2 then
weeklyPivot = (weeklyHigh + weeklyLow + Close[1]*2) / 4
Else
weeklyPivot = (Open*2 + weeklyHigh + weeklyLow) / 4
Endif
weeklyR1 = 2*weeklyPivot - weeklyLow
weeklyS1 = 2*weeklyPivot - weeklyHigh
weeklyR2 = weeklyPivot + (weeklyHigh - weeklyLow)
weeklyS2 = weeklyPivot - (weeklyHigh - weeklyLow)
weeklyR3 = weeklyR1 + (weeklyHigh - weeklyLow)
weeklyS3 = weeklyS1 - (weeklyHigh - weeklyLow)
Endif
If Month<>Month[1] then
monthlyHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]
monthlyLow = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
lastMonthBarIndex = BarIndex
If mode = 0 then
monthlyPivot = (monthlyHigh + monthlyLow + Close[1]) / 3
Elsif mode = 1 then
monthlyPivot = (Open + monthlyHigh + monthlyLow + Close[1]) / 4
Elsif mode = 2 then
monthlyPivot = (monthlyHigh + monthlyLow + Close[1]*2) / 4
Else
monthlyPivot = (Open*2 + monthlyHigh + monthlyLow) / 4
Endif
monthlyR1 = 2*monthlyPivot - monthlyLow
monthlyS1 = 2*monthlyPivot - monthlyHigh
monthlyR2 = monthlyPivot + (monthlyHigh - monthlyLow)
monthlyS2 = monthlyPivot - (monthlyHigh - monthlyLow)
monthlyR3 = monthlyR1 + (monthlyHigh - monthlyLow)
monthlyS3 = monthlyS1 - (monthlyHigh - monthlyLow)
Endif
Return dailyPivot as "Daily P", dailyR1 as "Daily R1", dailyS1 as "Daily S1", dailyR2 as "Daily R2", dailyS2 as "Daily S2", dailyR3 as "Daily R3", dailyS3 as "Daily S3", weeklyPivot as "Weekly P", weeklyR1 as "Weekly R1", weeklyS1 as "Weekly S1", weeklyR2 as "Weekly R2", weeklyS2 as "Weekly S2", weeklyR3 as "Weekly R3", weeklyS3 as "Weekly S3", monthlyPivot as "Monthly P", monthlyR1 as "Monthly R1", monthlyS1 as "Monthly S1", monthlyR2 as "Monthly R2", monthlyS2 as "Monthly S2", monthlyR3 as "Monthly R3", monthlyS3 as "Monthly S3"