Once mode = 0
////ONCE PIVOT TRIMESTRIAL////
Once lasttrimestrialBarIndex = 0
Once trimestrialHigh = undefined
Once trimestrialLow = undefined
Once trimestrialPivot = undefined
Once trimestrialR1 = undefined
Once trimestrialS1 = undefined
Once trimestrialR2 = undefined
Once trimestrialS2 = undefined
Once trimestrialR3 = undefined
Once trimestrialS3 = undefined
////PIVOT TRIMESTRIAL////
If month<>month[1] then
if month=4 or month=7 or month=10 or month= 0 then
trimestrialHigh = Highest[BarIndex - lasttrimestrialBarIndex](High)[1]
trimestrialLow = Lowest[BarIndex - lasttrimestrialBarIndex](Low)[1]
lasttrimestrialBarIndex = BarIndex
If mode = 0 then
trimestrialPivot = (trimestrialHigh + trimestrialLow + Close[1]) / 3
Elsif mode = 1 then
trimestrialPivot = (Open + trimestrialHigh + trimestrialLow + Close[1]) / 4
Elsif mode = 2 then
trimestrialPivot = (trimestrialHigh + trimestrialLow + Close[1]*2) / 4
Else
trimestrialPivot = (Open*2 + trimestrialHigh + trimestrialLow) / 4
Endif
trimestrialR1 = 2*trimestrialPivot - trimestrialLow
trimestrialS1 = 2*trimestrialPivot - trimestrialHigh
trimestrialR2 = trimestrialPivot + (trimestrialHigh - trimestrialLow)
trimestrialS2 = trimestrialPivot - (trimestrialHigh - trimestrialLow)
trimestrialR3 = trimestrialR1 + (trimestrialHigh - trimestrialLow)
trimestrialS3 = trimestrialS1 - (trimestrialHigh - trimestrialLow)
endif
endif
Return trimestrialPivot coloured(217, 255, 3) as "Monthly P", trimestrialR1 coloured(46, 134, 193) as "Monthly R1", trimestrialS1 coloured(46, 134, 193) as "Monthly S1", trimestrialR2 coloured(0,0,0) as "Monthly R2", trimestrialS2 coloured(0,0,0) as "Monthly S2", trimestrialR3 coloured(250, 47, 47) as "Monthly R3", trimestrialS3 coloured(250, 47, 47) as "Monthly S3"