Code Library / Support/Resistance
Pine Script Pivot Points
Auto pivot point calculator with S1-S3 and R1-R3.
Language: Pine Script · Category: Support/Resistance · Tags: pivot points, support, resistance, Pine Script, levels
Source code
//@version=5
indicator("Pivots",overlay=true)
[pH,pL,pC]=request.security(syminfo.tickerid,"D",[high[1],low[1],close[1]],lookahead=barmerge.lookahead_on)
piv=(pH+pL+pC)/3
plot(piv,"P",color.yellow,2)
plot(2*piv-pL,"R1",color.red); plot(piv+(pH-pL),"R2",color.red)
plot(2*piv-pH,"S1",color.green); plot(piv-(pH-pL),"S2",color.green)How to use this snippet
This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.