Indicator · Pine Script v6 · Own pane

Qstick Indicator

by mihakralj

This indicator calculates the Qstick value as a simple or exponential moving average of the difference between a chosen close source and open source.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code62
Settings4inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

62 lines of Pine Script v6 from lib/dynamics/qstick/qstick.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

qstick.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Qstick Indicator", "QSTICK", overlay=false)

//@function Calculates Qstick (moving average of close-open difference)
//@param source_close Closing price series
//@param source_open Opening price series
//@param length Lookback period for moving average
//@param use_ema Use EMA (true) or SMA (false)
//@returns Qstick value
qstick(series float source_close, series float source_open, simple int length, simple bool use_ema) =>
    if length <= 0
        runtime.error("Length must be greater than 0")
    
    float diff = source_close - source_open
    
    float result = 0.0
    if use_ema
        float alpha = 2.0 / (length + 1)
        var float ema = 0.0
        ema := alpha * (diff - ema) + ema
        result := ema
    else
        var int count = 0
        var float sum = 0.0
        var int head = 0
        var array<float> buffer = array.new_float(length, na)
        
        float oldest = array.get(buffer, head)
        if not na(oldest)
            sum -= oldest
        else
            count += 1
        
        float current = nz(diff)
        sum += current
        array.set(buffer, head, current)
        head := (head + 1) % length
        
        result := sum / math.max(1, count)
    
    result

// ---------- Main loop ----------

// Inputs
i_length = input.int(14, "Length", minval=1, tooltip="Lookback period for moving average calculation")
i_ma_type = input.string("SMA", "MA Type", options=["SMA", "EMA"], tooltip="Simple (SMA) or Exponential (EMA) moving average")
i_source_close = input.source(close, "Close Source", tooltip="Source for closing price")
i_source_open = input.source(open, "Open Source", tooltip="Source for opening price")

// Calculation
bool use_ema = i_ma_type == "EMA"
qstick_value = qstick(i_source_close, i_source_open, i_length, use_ema)

// Plot
plot(qstick_value, "Qstick", color=color.yellow, linewidth=2)
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dashed)

// Color fill for positive/negative regions
bgcolor(qstick_value > 0 ? color.new(color.green, 90) : color.new(color.red, 90), title="Background")

Overview

Qstick Indicator plots that oscillator in a separate pane as a yellow line, draws a dashed zero line, and shades the background green when the value is above zero and red when it is below. Length, moving-average type, and both price sources are user inputs. It does not generate trade entries, exits, or stops.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Candlestick patterns

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Lengthint14i_length
MA TypestringSMAi_ma_type
Close Sourcesourceclosei_source_close
Open Sourcesourceopeni_source_open
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Commitment Gauge

by harryguiacorn
219 stars

This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete

Indicator v4 VolumeCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Commitment Gauge
24 stars

This indicator plots a Cipher B-style oscillator in a separate pane and can source its calculations from Heikin Ashi candles when that option is on. It draws WaveTrend lines with optional buy, gold, sell, and divergence dots, plus overbought and oversold level

Indicator v5 Oscillators & momentumDivergence
Updated 4 years ago · MPL-2.0 GitHub repository of Cipher B Heikin Ashi

The Candle Pressure Index measures buying versus selling pressure from candle geometry and relative volume. Each bar combines close location, body ratio, and volume rank into a raw pressure value. An exponential moving average of that pressure forms the CPI os

Indicator v6 Oscillators & momentumVolume
Updated yesterday · MIT GitHub repository of Candle Pressure Index [WavesUnchained]

Heikin Ashi Delta Smoothed

by lunarticktrading
7 stars

This indicator calculates the difference between Heikin-Ashi close and open values to quantify directional candle spread. It smooths this delta value using a simple moving average and plots the resulting oscillator as a line in a separate pane. Traders can cus

Indicator v6 Oscillators & momentumCandlestick patterns
Updated 2 weeks ago · None stated GitHub repository of Heikin Ashi Delta Smoothed
285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

Raschke Patterns

by TradersPost
218 stars

This overlay indicator marks Linda Raschke short-term bar setups on the price chart. It flags Turtle Soup and Turtle Soup plus one false breakouts of a prior extreme, 80-20 bars, inside bars, failed inside-bar breakouts, outside up and down bars, NR4 and NR7 c

Indicator v6 Candlestick patternsBreakout Repaints
Updated 3 months ago · None stated GitHub repository of Raschke Patterns

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers