What are Tom DeMark Pivots?
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:
- Identify precise turning points: DeMark levels are often seen as more predictive of exact reversal zones.
- Anticipate trend exhaustion: Price reaching certain DeMark levels might signal that the current trend is overextended.
- Set entry and exit points: Providing clear, actionable levels for trades.
In Pine Script, implementing Tom DeMark Pivots involves understanding their unique conditional calculation, making them a powerful tool for sophisticated pine script strategies focused on timing reversals.
Components and Calculation (Tom DeMark Pivots)
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`).
Let `H`, `L`, `C`, `O` be the previous period's High, Low, Close, and Open.
- Calculate 'X': This is the core difference in DeMark's methodology.
- If `C < O` (previous close was lower than previous open): `X = H + (L * 2) + C`
- If `C > O` (previous close was higher than previous open): `X = (H * 2) + L + C`
- If `C == O` (previous close was equal to previous open): `X = H + L + (C * 2)`
- Central Pivot (TD Price Flip or Setup Reference Point):
`PP = X / 4` - First Resistance (R1):
`R1 = X / 2 - L` - First Support (S1):
`S1 = X / 2 - H` - Second Resistance (R2):
`R2 = PP + (R1 - S1)` (This is less common, DeMark usually focuses on R1, S1 and the PP as primary levels) - Second Support (S2):
`S2 = PP - (R1 - S1)`
Similar to other pivot points, these levels are fixed for the current trading period (usually daily) and are recalculated at the start of the next period.
Basic Tom DeMark Pivots Implementation in Pine Script
Pine Script v5 makes implementing DeMark Pivots straightforward using its built-in `ta.pivotpoints()` function with the "Demark" type. This function correctly handles the conditional 'X' calculation.
//@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)
Practical Tom DeMark Pivots Trading Strategies
1. Reversal Trading at TD S1/R1
DeMark's S1 and R1 are often used for potential reversals. Traders look for price to react to these levels, signaling a bounce or rejection.
- Buy Signal (Reversal): Price declines and approaches TD S1, then shows signs of reversal (e.g., bullish candlestick, bounce off S1, or closes back above S1). This suggests S1 is acting as support.
- Sell Signal (Reversal): Price rallies and approaches TD R1, then shows signs of reversal (e.g., bearish candlestick, rejection from R1, or closes back below R1). This suggests R1 is acting as resistance.
- Confluence: These signals are strengthened when S1/R1 align with other support/resistance zones (e.g., trendlines, moving averages).
//@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)
2. Trend Continuation / Breakout (Beyond R1 or S1)
While often used for reversals, DeMark levels can also indicate strong trend continuation if price decisively breaks beyond R1 or S1.
- Buy Signal (Breakout): Price breaks decisively above TD R1 with strong momentum and ideally, increased volume. This suggests the trend has enough strength to continue.
- Sell Signal (Breakout): Price breaks decisively below TD S1 with strong momentum and ideally, increased volume. This suggests the downtrend has strong conviction.
//@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)
3. TD Price Flip as Trend Gauge
The central TD Price Flip (PP) can act as a crucial reference for the prevailing short-term bias. Its calculation adapts to recent price action, making it more dynamic than a simple average.
- Bullish Bias: If the current price is consistently trading above the TD Price Flip (PP), it suggests a bullish short-term bias.
- Bearish Bias: If the current price is consistently trading below the TD Price Flip (PP), it suggests a bearish short-term bias.
- Flip Signal: A crossover of the current price over/under the TD Price Flip can indicate a shift in the immediate trend bias.
//@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])
Optimizing Tom DeMark Pivots Performance
To get the most from Tom DeMark Pivots in Pine Script:
- Timeframe Alignment: DeMark Pivots are most effective for intraday trading or short-term swing trading. Using them on daily or weekly charts might provide less relevant signals as their precision on smaller timeframes is key. Ensure your chart timeframe is lower (e.g., 5-min, 15-min, 1-hour) than the pivot calculation timeframe (typically "D").
- Confirmation is Paramount: DeMark levels offer potential turning points, but always seek confirmation. This could be from:
- Candlestick patterns: Bullish/bearish reversal patterns forming at the levels.
- Volume: Increased volume on a breakout or rejection.
- Other indicators: Confluence with momentum oscillators (RSI, Stochastic) or trend indicators (Moving Averages).
- Price Action Interaction: Observe how price reacts to the DeMark levels. Does it stall, consolidate, or reverse? Is it a quick spike and retreat, or a sustained breakout?
- Context Matters: Understand the broader market trend. In a strong uptrend, bullish signals at S1 are higher probability than bearish signals at R1.
- Adaptive Nature: Recognize that the "X" value, and thus the levels, adjust dynamically based on the previous bar's open/close relationship. This is a strength but means the levels are not as static as Classic Pivots.
Common Tom DeMark Pivots Pitfalls
- Complexity: The conditional calculation of DeMark Pivots can be more complex to grasp initially compared to simpler pivot methods.
- False Signals/Whipsaws: Like any indicator, DeMark Pivots can generate false signals in choppy or non-trending markets, or during periods of high volatility.
- Over-Reliance: Using DeMark Pivots as the sole decision-making tool without additional confirmation can lead to significant losses. They are best used as part of a comprehensive strategy.
- Gap Risk: Large overnight gaps can cause the current day's trading to occur far away from the calculated DeMark levels, making them less immediately relevant.
- Limited Levels: While TD Price Flip, R1, and S1 are primary, higher R2/S2/R3/S3 levels might not always be consistently generated or as reliable as in other pivot systems.
Conclusion
Tom DeMark Pivots are a sophisticated and highly dynamic set of potential support and resistance levels available in Pine Script 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 pine script 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.