Once Mode = 1 //0, 1, 2 or 3
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 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 monthlyPivot coloured(0,0,255) as "mP",monthlyR1 coloured(0,0,255) as "mR1", monthlyS1 coloured(0,0,255) as "mS1", monthlyR2 coloured(0,0,255) as "mR2", monthlyS2 coloured(0,0,255) as "mS2", monthlyR3 coloured(0,0,255) as "mR3", monthlyS3 coloured(0,0,255) as "mS3"