Master this unique pivot point system in TradingView's Pinescript, known for identifying precise potential turning points and trend exhaustion based on specific price relationships.
Tom DeMark Pivots, often referred to as TD Pivots or DeMark Points, are a distinct set of support and resistance levels that aim to predict price reversals. Unlike traditional pivot points (Classic, Woodie, Camarilla) that use a fixed formula for their central pivot, DeMark's methodology employs a conditional approach based on the relationship between the previous period's open, high, low, and close. This makes DeMark Pivots highly adaptive and often results in levels that are more precise and dynamic, frequently indicating potential turning points with higher accuracy.
The core philosophy of DeMark Pivots is that price tends to find support or resistance at specific levels derived from previous price action, especially in relation to where the market closed relative to its open and high/low. These pivots are not just static levels but are signals for potential reversals or exhaustion points.
DeMark Pivots typically consist of a calculated "X" value which forms the basis for the central pivot (referred to as "TD Price Flip") and subsequent support (S1, S2) and resistance (R1, R2) levels. They are primarily used by traders to:
The calculation of Tom DeMark Pivots is highly conditional. It starts by determining an intermediate value, "X", based on the comparison of the previous period's closing price (`C`) to its opening price (`O`) and high (`H`) or low (`L`).
//@version=5
indicator("My Tom DeMark Pivots", overlay=true, max_bars_back=500) // overlay=true to plot on price chart.
// Input for the Pivot Point calculation timeframe
// DeMark pivots are predominantly used for intraday trading, so "D" (Daily) is most common.
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
// Get the Pivot Points values using ta.pivotpoints() with "Demark" type
// This function returns a tuple: [pp, r1, r2, r3, s1, s2, s3]
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints("Demark", pivotTimeframe, high, low, close, 1, open) // Pass 'open' as well
// Plotting the DeMark Levels
plot(pp, title="TD Price Flip", color=color.purple, linewidth=2, style=plot.style_stepline)
plot(r1, title="TD Resistance 1", color=color.red, linewidth=1, style=plot.style_stepline)
plot(s1, title="TD Support 1", color=color.green, linewidth=1, style=plot.style_stepline)
// For DeMark, R2/R3 and S2/S3 are less commonly focused on or directly derived.
plot(r2, title="TD Resistance 2", color=color.red, linewidth=1, style=plot.style_stepline)
plot(r3, title="TD Resistance 3", color=color.new(color.red, 50), linewidth=1, style=plot.style_stepline) // Lighter for less focus
plot(s2, title="TD Support 2", color=color.green, linewidth=1, style=plot.style_stepline)
plot(s3, title="TD Support 3", color=color.new(color.green, 50), linewidth=1, style=plot.style_stepline) // Lighter for less focus
// Optional: Add labels to the pivot lines for clarity (only on the first bar of a new period)
var label pp_label = na
var label r1_label = na
var label r2_label = na
var label r3_label = na
var label s1_label = na
var label s2_label = na
var label s3_label = na
// Check if it's the first bar of the new period (e.g., new day)
isNewPeriod = ta.change(time(pivotTimeframe))
if isNewPeriod
label.delete(pp_label)
label.delete(r1_label)
label.delete(r2_label)
label.delete(r3_label)
label.delete(s1_label)
label.delete(s2_label)
label.delete(s3_label)
pp_label := label.new(bar_index, pp, text="TD PP", style=label.style_label_left, color=color.new(color.purple, 70), textcolor=color.white)
r1_label := label.new(bar_index, r1, text="TD R1", style=label.style_label_left, color=color.new(color.red, 70), textcolor=color.white)
s1_label := label.new(bar_index, s1, text="TD S1", style=label.style_label_left, color=color.new(color.green, 70), textcolor=color.white)
// Only plot labels for R2/R3/S2/S3 if they are meaningfully calculated (not NA)
if not na(r2)
r2_label := label.new(bar_index, r2, text="TD R2", style=label.style_label_left, color=color.new(color.red, 80), textcolor=color.white)
if not na(r3)
r3_label := label.new(bar_index, r3, text="TD R3", style=label.style_label_left, color=color.new(color.red, 90), textcolor=color.white)
if not na(s2)
s2_label := label.new(bar_index, s2, text="TD S2", style=label.style_label_left, color=color.new(color.green, 80), textcolor=color.white)
if not na(s3)
s3_label := label.new(bar_index, s3, text="TD S3", style=label.style_label_left, color=color.new(color.green, 90), textcolor=color.white)
// Extend labels horizontally
label.set_x(pp_label, bar_index)
label.set_x(r1_label, bar_index)
label.set_x(r2_label, bar_index)
label.set_x(r3_label, bar_index)
label.set_x(s1_label, bar_index)
label.set_x(s2_label, bar_index)
label.set_x(s3_label, bar_index)
DeMark Pivots are known for their conditional calculation, which can make them more predictive of exact turning points and trend exhaustion than other static pivot methods.
//@version=5
strategy("TD Pivots Reversal Strategy", overlay=true)
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints("Demark", pivotTimeframe, high, low, close, 1, open)
// Plotting (simplified for strategy example)
plot(r1, title="TD R1", color=color.red, linewidth=1, style=plot.style_stepline)
plot(s1, title="TD S1", color=color.green, linewidth=1, style=plot.style_stepline)
// Long entry: Price bounces from TD S1
longCondition = close > s1 and close[1] <= s1[1]
// Short entry: Price rejects from TD R1
shortCondition = close < r1 and close[1] >= r1[1]
if (longCondition)
strategy.entry("Long TD S1", strategy.long)
if (shortCondition)
strategy.entry("Short TD R1", strategy.short)
// Basic exit: fixed profit/loss or target PP
profitTargetFactor = input.float(0.5, title="Profit Target (Ratio to S/R)", minval=0.1, maxval=1.0, step=0.1)
stopLossFactor = input.float(0.5, title="Stop Loss (Ratio to S/R)", minval=0.1, maxval=1.0, step=0.1)
// Calculate dynamic profit/stop targets
longProfitTarget = pp
longStopLoss = s2
shortProfitTarget = pp
shortStopLoss = r2
strategy.exit("Long TD S1 Exit", from_entry="Long TD S1", profit=longProfitTarget, stop=longStopLoss)
strategy.exit("Short TD R1 Exit", from_entry="Short TD R1", profit=shortProfitTarget, stop=shortStopLoss)
//@version=5
strategy("TD Pivots Breakout Strategy", overlay=true)
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints("Demark", pivotTimeframe, high, low, close, 1, open)
// Plotting (simplified for strategy example)
plot(r1, title="TD R1", color=color.red, linewidth=1, style=plot.style_stepline)
plot(s1, title="TD S1", color=color.green, linewidth=1, style=plot.style_stepline)
// Breakout logic: Price closes decisively above/below R1 or S1
longBreakoutCondition = close > r1 and close[1] <= r1[1]
shortBreakoutCondition = close < s1 and close[1] >= s1[1]
// Optional: Add volume confirmation for breakouts
volumeFactor = input.float(1.5, title="Volume Confirmation Factor", minval=1.0, step=0.1)
avgVolume = ta.sma(volume, 20) // Simple average volume for comparison
isHighVolume = volume > avgVolume * volumeFactor
if (longBreakoutCondition and isHighVolume)
strategy.entry("Long TD R1 Breakout", strategy.long)
if (shortBreakoutCondition and isHighVolume)
strategy.entry("Short TD S1 Breakout", strategy.short)
// Exit: Fixed profit/loss or target next potential levels (e.g., R2/S2 if valid)
atrLength = input.int(14, title="ATR Length for Exits", minval=1)
atrValue = ta.atr(atrLength)
profitMultiplier = input.float(1.5, title="Profit Target (ATR)", minval=0.5, step=0.1)
stopLossMultiplier = input.float(0.75, title="Stop Loss (ATR)", minval=0.1, step=0.1)
strategy.exit("Long TD R1 Breakout Exit", from_entry="Long TD R1 Breakout",
profit=strategy.position_avg_price + atrValue * profitMultiplier,
stop=strategy.position_avg_price - atrValue * stopLossMultiplier)
strategy.exit("Short TD S1 Breakout Exit", from_entry="Short TD S1 Breakout",
profit=strategy.position_avg_price - atrValue * profitMultiplier,
stop=strategy.position_avg_price + atrValue * stopLossMultiplier)
//@version=5
indicator("TD Price Flip Trend Gauge", overlay=true)
pivotTimeframe = input.string("D", title="Pivot Timeframe", options=["D", "W", "M"])
[pp, r1, r2, r3, s1, s2, s3] = ta.pivotpoints("Demark", pivotTimeframe, high, low, close, 1, open)
// Plotting (simplified for trend gauge example)
plot(pp, title="TD Price Flip", color=color.purple, linewidth=2, style=plot.style_stepline)
// Determine intraday bias based on price relative to TD Price Flip
isBullishBias = close > pp
isBearishBias = close < pp
// Color background to easily visualize bias
bgcolor(isBullishBias ? color.new(color.teal, 95) : na, title="Bullish TD Bias")
bgcolor(isBearishBias ? color.new(color.maroon, 95) : na, title="Bearish TD Bias")
// Plot arrows on price crossing PP to show bias shift
plotarrow(ta.crossover(close, pp) ? close : na, title="Bias Shift Up", colorarrow=color.new(color.aqua, 0), style=plot.style_circles, offset=-bar_index+bar_index[1])
plotarrow(ta.crossunder(close, pp) ? close : na, title="Bias Shift Down", colorarrow=color.new(color.orange, 0), style=plot.style_circles, offset=-bar_index+bar_index[1])
To get the most from Tom DeMark Pivots in Pinescript:
DeMark Pivots adjust their calculation based on the prior bar's open-close relationship, offering a dynamic and often more precise identification of potential turning points.
Tom DeMark Pivots are a sophisticated and highly dynamic set of potential support and resistance levels available in Pinescript for TradingView. By employing a unique conditional calculation based on the previous period's price relationships, they aim to provide more precise and often more predictive turning points than traditional pivot systems. While requiring a deeper understanding of their underlying logic and diligent confirmation from other technical analysis tools, mastering Tom DeMark Pivots can significantly enhance your Pinescript strategies. By understanding their calculation, applying them to appropriate timeframes, and integrating them strategically into your overall trading plan, you can leverage these powerful levels to improve your entry/exit timing and better capitalize on market opportunities, particularly in identifying potential trend reversals.
Get a high-performance Pinescript 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 Pinescript Strategy