Hi all,
I was wondering whether there is a way to screen for monthly pivots rather than for the default daily.
I’ve been trying few things I’ve found on this blog but nothing seems to work properly.
Your help would be much appreciated.
Renzo
There you go (thanks to Nicolas’ post https://www.prorealcode.com/prorealtime-indicators/daily-weekly-monthly-pivot-points/):
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"
name it “MonthlyPivots”, then call it in your screener:
monthlyPivot,monthlyR1,monthlyS1,monthlyR2,monthlyS2,monthlyR3,monthlyS3 = CALL "MonthlyPivots"
it will return the 7 variables representing Monthly:
- Pivot
- Resistance1
- Support1
- Resistance2
- Support2
- resistance3
- Support3