Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-qstick

$ Pinescript Qstick

Master this unique momentum indicator in TradingView's Pinescript that quantifies the strength of candlestick bodies to reveal underlying buying and selling pressure.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

What is Qstick?

Qstick is a technical indicator that measures the market's internal momentum by quantifying the strength and direction of candlestick bodies over a specified period. Developed by Tushar Chande and Stanley Kroll, Qstick essentially calculates the Simple Moving Average (SMA) of the difference between the closing price and the opening price of each candlestick. A positive Qstick value indicates that candlesticks are closing higher than they open on average, suggesting bullish momentum. Conversely, a negative value indicates bearish momentum.

In Pinescript, Qstick is a valuable tool for traders seeking a smoothed view of real body momentum, helping to identify trend changes, confirm direction, and spot divergences without the noise often found in pure price oscillators.

02

Components and Calculation

The calculation of Qstick is straightforward:

  1. Individual Bar Difference (C-O): For each bar, calculate `Close - Open`. This represents the "body" of the candlestick. A positive value means a bullish candle; a negative value means a bearish candle.
  2. Qstick Formula: Calculate the Simple Moving Average (SMA) of these `(Close - Open)` differences over a specified `length` (e.g., 10 periods).
    `Qstick = SMA( (Close - Open), length)`
03

Basic Qstick Implementation in Pinescript

pine-script@terminal
//@version=5
indicator("My Qstick Indicator", overlay=false) // overlay=false to plot in a separate pane

// Input for Qstick length
length = input.int(10, title="Qstick Length", minval=1)

// Calculate Qstick value using the built-in function
qstickValue = ta.qstick(length)

// Plot the Qstick line
plot(qstickValue, title="Qstick", color=color.blue, linewidth=2)

// Plot the Zero Line
hline(0, "Zero Line", color.gray, linestyle=hline.style_solid)

// Optional: Add bands for visual reference, although Qstick is unbounded
// (These bands are illustrative and depend on historical observation for the asset)
// hline(avg(abs(qstickValue), 50), "Upper Ref", color=color.red, linestyle=hline.style_dashed)
// hline(-avg(abs(qstickValue), 50), "Lower Ref", color=color.green, linestyle=hline.style_dashed)
$ ✓ Compiled successfully
04

Candlestick Body Focus

Candlestick Body Focus

Qstick filters out the noise from wicks and focuses solely on the strength of the candle's real body, providing a smoother momentum signal.

05

Practical Qstick Trading Strategies

06

1. Zero Line Crossover (Momentum Shift)

pine-script@terminal
//@version=5
strategy("Qstick Zero Line Crossover Strategy", overlay=true)

// Input for Qstick length
length = input.int(10, title="Qstick Length", minval=1)
zeroLine = 0.0

// Calculate Qstick
qstickValue = ta.qstick(length)

// Plot Qstick in a separate pane for visualization
plot(qstickValue, "Qstick", color.blue, display=display.pane_only)
hline(zeroLine, "Zero Line", color.gray, linestyle=hline.style_solid, display=display.pane_only)

// Define conditions for entries
longSignal = ta.crossover(qstickValue, zeroLine)
shortSignal = ta.crossunder(qstickValue, zeroLine)

// Strategy entries/exits
if (longSignal)
    strategy.entry("Long", strategy.long)

if (shortSignal)
    strategy.entry("Short", strategy.short)
$ ✓ Compiled successfully
07

2. Trend Confirmation and Strength

pine-script@terminal
//@version=5
strategy("Qstick Trend Strength Confirmation", overlay=true)

length = input.int(10, title="Qstick Length", minval=1)

qstickValue = ta.qstick(length)

plot(qstickValue, "Qstick", color.blue, display=display.pane_only)
hline(0, "Zero Line", color.gray, linestyle=hline.style_solid, display=display.pane_only)

// Using a simple threshold for strength, adjust based on asset
bullishStrengthThreshold = input.float(0.5, title="Bullish Strength Threshold", step=0.1)
bearishStrengthThreshold = input.float(-0.5, title="Bearish Strength Threshold", step=0.1)

// Long entry: Qstick is positive and above a certain strength threshold
longConfirm = qstickValue > bullishStrengthThreshold and qstickValue > qstickValue[1]

// Short entry: Qstick is negative and below a certain strength threshold
shortConfirm = qstickValue < bearishStrengthThreshold and qstickValue < qstickValue[1]

if (longConfirm)
    strategy.entry("TrendLong", strategy.long)

if (shortConfirm)
    strategy.entry("TrendShort", strategy.short)

// Example exit: if Qstick crosses zero or reverses strongly
strategy.close("TrendLong", when=qstickValue < 0)
strategy.close("TrendShort", when=qstickValue > 0)
$ ✓ Compiled successfully
08

3. Qstick Divergence Strategy

pine-script@terminal
//@version=5
indicator("Qstick Divergence Scanner", overlay=true)

length = input.int(10, title="Qstick Length", minval=1)

qstickValue = ta.qstick(length)

plot(qstickValue, "Qstick", color.blue)
hline(0, "Zero Line", color.gray, linestyle=hline.style_solid)

// Simple divergence detection (conceptual, robust detection requires advanced pivot logic)
// This is a simplified example focusing on price vs Qstick divergence.

// Bullish Divergence (Price lower low, Qstick higher low)
bullishDivergence = close[2] > close[1] and close[1] > close and qstickValue[2] < qstickValue[1] and qstickValue[1] < qstickValue

// Bearish Divergence (Price higher high, Qstick lower high)
bearishDivergence = close[2] < close[1] and close[1] < close and qstickValue[2] > qstickValue[1] and qstickValue[1] > qstickValue

plotshape(bullishDivergence, title="Bullish Divergence", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(bearishDivergence, title="Bearish Divergence", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)

alertcondition(bullishDivergence, "Bullish Qstick Divergence", "Potential bullish reversal based on Qstick divergence.")
alertcondition(bearishDivergence, "Bearish Qstick Divergence", "Potential bearish reversal based on Qstick divergence.")
$ ✓ Compiled successfully
09

Optimizing Qstick Performance

To get the most from Qstick in Pinescript:

  • Parameter Tuning: The `length` parameter is crucial. A shorter length (e.g., 5 periods) will make Qstick more sensitive and reactive to immediate candlestick momentum, while a longer length (e.g., 20 periods) will provide a smoother, less noisy signal for longer-term trends. Experiment to find the optimal setting for your trading style and the asset's typical behavior.
  • Combine with Trend Filters: While Qstick indicates momentum, it can be prone to false signals in choppy or non-trending markets. Always use it in conjunction with a separate trend-following indicator (e.g., a longer-period EMA or ADX) on the price chart to confirm the broader trend direction. Use Qstick for timing entries/exits within that confirmed trend.
  • Confluence with Price Action: Always look for Qstick signals to be confirmed by actual price action. For instance, a bullish Qstick zero-line crossover is stronger if the price is also breaking above a short-term resistance or forming a bullish candlestick pattern.
  • Divergence Reliability: Pay special attention to divergence signals. Because Qstick focuses on the real body, divergence can be a powerful indicator of waning conviction behind a price move.
  • Volume Analysis: Strong Qstick readings (high positive or low negative) are often accompanied by significant volume, which can add further conviction to the momentum signal.
10

Smoothed Candle Momentum

Smoothed Candle Momentum

Qstick offers a unique perspective by averaging the strength of bullish and bearish candlestick bodies, providing a clearer signal of who's in control on a bar-by-bar basis.

11

Common Qstick Pitfalls

  • Whipsaws in Sideways Markets: In choppy or range-bound markets, Qstick can frequently cross the zero line, leading to numerous false signals. It performs best when there is clear directional momentum.
  • Lag: As Qstick uses a Simple Moving Average, it has some inherent lag and will not perfectly pinpoint exact tops or bottoms.
  • Unbounded Nature: Unlike some oscillators, Qstick has no fixed upper or lower limits. This means interpreting "overbought" or "oversold" requires historical observation of an asset's typical extreme Qstick values, rather than relying on universal thresholds like 70/30 for RSI.
  • Requires Clear Candlestick Bodies: On assets with very small or inconsistent candlestick bodies, Qstick might not provide clear signals.
  • Not a Standalone Indicator: Qstick should always be used as part of a broader trading system, complementing other indicators and price action analysis for comprehensive decision-making and risk management.
12

Conclusion

Conclusion

Qstick is an insightful technical indicator in Pinescript for TradingView that offers a unique perspective on market momentum by quantifying the strength of candlestick bodies. By smoothing the difference between open and close prices, it helps traders identify shifts in underlying buying and selling pressure. Whether used for identifying trend changes through zero-line crossovers, confirming trend strength, or spotting powerful reversals through divergence, Qstick provides valuable insights into market dynamics. By understanding its calculation, thoughtfully tuning its parameters, and integrating it strategically with other technical analysis tools, you can leverage Qstick to enhance your trading decisions and gain a clearer understanding of market conviction.

Enhance Your Trading

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