Master this foundational indicator in TradingView's Pine Script that identifies key potential support, resistance, and reversal levels for intraday and swing trading strategies.
Pivot Points are significant levels derived from the high, low, and closing prices of a previous trading period (e.g., previous day, week, or month). Traders use these levels to predict potential support and resistance zones for the current or upcoming trading period. They are particularly popular among intraday traders for identifying key turning points or areas where price action might react.
The core idea is that these calculated levels represent a consensus of past price action, and therefore, they are likely to influence future price movements. When price approaches a pivot point, traders watch for either a bounce (support/resistance) or a breakout (continuation).
There are several types of Pivot Points (Classic, Fibonacci, Woodie, Camarilla, Demark), each with slightly different calculation formulas. However, the Classic Pivot Points are the most widely used and provide a solid foundation for understanding the concept.
In Pine Script, Pivot Points are a powerful tool for visualizing key price levels that can inform your pine script strategies for entries, exits, and risk management.
Classic Pivot Points consist of a central Pivot Point (PP), three resistance levels (R1, R2, R3), and three support levels (S1, S2, S3). These are calculated using the previous period's (e.g., yesterday's) High, Low, and Close prices:
PP = (High[previous_period] + Low[previous_period] + Close[previous_period]) / 3R1 = (2 * PP) - Low[previous_period]S1 = (2 * PP) - High[previous_period]R2 = PP + (High[previous_period] - Low[previous_period])R2 = PP + (R1 - S1) (Alternative)S2 = PP - (High[previous_period] - Low[previous_period])S2 = PP - (R1 - S1) (Alternative)R3 = R1 + (High[previous_period] - Low[previous_period])S3 = S1 - (High[previous_period] - Low[previous_period])//@version=5
indicator("My Pivot Points", overlay=true, max_bars_back=500)
// Input for the Pivot Point calculation timeframe
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
// Input for the type of Pivot Points
pivotType = input.string("Classic", title="Pivot Type", options=["Classic", "Fibonacci", "Woodie", "Camarilla", "Demark"])
// Get the Pivot Points values using ta.pivotpoints()
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints(pivotType, pivotTimeframe, high, low, close, 1)
// Plotting the Pivot Points levels
plot(pp, title="Pivot Point", color=color.purple, linewidth=2, style=plot.style_stepline)
plot(r1, title="Resistance 1", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r2, title="Resistance 2", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r3, title="Resistance 3", color=color.red, linewidth=1, style=plot.style_stepline)
plot(s1, title="Support 1", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s2, title="Support 2", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s3, title="Support 3", color=color.green, linewidth=1, style=plot.style_stepline)
Unlike moving averages, Pivot Points are static levels for the entire trading period, calculated based on the previous period's high, low, and close. This makes them predictable.
This is the most common use of Pivot Points. Traders look for price to react to these levels, either bouncing off them or failing to break through, signaling potential reversals.
//@version=5
strategy("Pivot Point Reversal Strategy", overlay=true)
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
pivotType = input.string("Classic", title="Pivot Type", options=["Classic", "Fibonacci", "Woodie", "Camarilla", "Demark"])
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints(pivotType, pivotTimeframe, high, low, close, 1)
plot(pp, title="Pivot Point", color=color.purple, linewidth=2, style=plot.style_stepline)
plot(r1, title="Resistance 1", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r2, title="Resistance 2", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r3, title="Resistance 3", color=color.red, linewidth=1, style=plot.style_stepline)
plot(s1, title="Support 1", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s2, title="Support 2", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s3, title="Support 3", color=color.green, linewidth=1, style=plot.style_stepline)
longCondition = close > s1 and close[1] <= s1[1]
shortCondition = close < r1 and close[1] >= r1[1]
isNewPeriod = ta.change(time(pivotTimeframe))
if (longCondition and not isNewPeriod)
strategy.entry("Long Reversal S1", strategy.long)
if (shortCondition and not isNewPeriod)
strategy.entry("Short Reversal R1", strategy.short)
strategy.exit("Long Reversal S1 Exit", from_entry="Long Reversal S1", profit=r1, stop=s2)
strategy.exit("Short Reversal R1 Exit", from_entry="Short Reversal R1", profit=s1, stop=r2)
If price decisively breaks through a pivot level with strong momentum and volume, it can signal a continuation of the trend towards the next pivot level.
//@version=5
strategy("Pivot Point Breakout Strategy", overlay=true)
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
pivotType = input.string("Classic", title="Pivot Type", options=["Classic", "Fibonacci", "Woodie", "Camarilla", "Demark"])
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints(pivotType, pivotTimeframe, high, low, close, 1)
plot(pp, title="Pivot Point", color=color.purple, linewidth=2, style=plot.style_stepline)
plot(r1, title="Resistance 1", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r2, title="Resistance 2", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r3, title="Resistance 3", color=color.red, linewidth=1, style=plot.style_stepline)
plot(s1, title="Support 1", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s2, title="Support 2", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s3, title="Support 3", color=color.green, linewidth=1, style=plot.style_stepline)
longBreakoutCondition = close > r1 and close[1] <= r1[1] and volume > volume[1] * 1.5
shortBreakoutCondition = close < s1 and close[1] >= s1[1] and volume > volume[1] * 1.5
if (longBreakoutCondition)
strategy.entry("Long Breakout R1", strategy.long)
if (shortBreakoutCondition)
strategy.entry("Short Breakout S1", strategy.short)
strategy.exit("Long Breakout R1 Exit", from_entry="Long Breakout R1", profit=r2, stop=pp)
strategy.exit("Short Breakout S1 Exit", from_entry="Short Breakout S1", profit=s2, stop=pp)
The central Pivot Point (PP) can act as an excellent indicator of the intraday trend bias.
//@version=5
indicator("Pivot Point Trend Bias", overlay=true)
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
pivotType = input.string("Classic", title="Pivot Type", options=["Classic", "Fibonacci", "Woodie", "Camarilla", "Demark"])
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints(pivotType, pivotTimeframe, high, low, close, 1)
plot(pp, title="Pivot Point", color=color.purple, linewidth=2, style=plot.style_stepline)
plot(r1, title="Resistance 1", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r2, title="Resistance 2", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r3, title="Resistance 3", color=color.red, linewidth=1, style=plot.style_stepline)
plot(s1, title="Support 1", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s2, title="Support 2", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s3, title="Support 3", color=color.green, linewidth=1, style=plot.style_stepline)
isBullishBias = close > pp
isBearishBias = close < pp
bgcolor(isBullishBias ? color.new(color.teal, 95) : na, title="Bullish Intraday Bias")
bgcolor(isBearishBias ? color.new(color.maroon, 95) : na, title="Bearish Intraday Bias")
To get the most from Pivot Points in Pine Script:
Pivot Points are unique because they are fixed and known at the beginning of the trading period, allowing traders to plan their strategies in advance.
Pivot Points are a foundational and highly valued technical indicator available in Pine Script for TradingView. By providing pre-calculated levels of potential support, resistance, and reversals, they offer traders a clear framework for navigating intraday and short-term price movements. While their primary strength lies in identifying these static levels, their true power is unlocked when combined with price action, volume analysis, and other confirming indicators. By understanding their calculation, thoughtfully selecting the appropriate timeframe and type, and integrating them strategically into your pine script strategies, you can leverage Pivot Points to enhance your decision-making, improve your entry/exit timing, and better manage risk in dynamic markets.
Get a high-performance Pine Script analysis tool for actionable market insights, designed for traders on the move.
This strategy runs in live mode on TradingView, helping you identify potential opportunities.
Get Pine Script Strategy