Qstick (QSTICK)
Summary
Tushar Chande and Stanley Kroll's Qstick (The New Technical Trader, 1994): a simple moving average of the candle body, close minus open. It measures how bullish or bearish the bodies have been over the window, independently of the wicks — above zero the bodies closed up on balance, below zero they closed down, and the zero-line crossings are the signal.
Chart
Chart metadata i
Outputs
outReal:line·zero·positive·negative
Formula
body_t = close_t - open_t; QSTICK_t = ( Σ body over the last optInTimePeriod bars ) / optInTimePeriod
The moving average is a plain SMA, so there is no seeding convention and none of the cross-library divergence that comes with one. optInTimePeriod of 1 leaves the raw body.
Inputs
inOpen— Open price of each barinClose— Close price of each bar
Outputs
outReal— Average candle body over the window
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 10 | 1–100000 | Number of bars averaged. Default 10, matching Tulip Indicators and pandas-ta-classic. Other packages differ: TraderEvolution documents 1, and AmiBroker community code commonly uses 8. |
Properties
Numerical Stability: Start-Independent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double open[252]; /* your data, oldest first */
double close[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_QSTICK( 0, n - 1, open, close, 10, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%.4f, ..., %.4f]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );use ta_lib::Core;
let open = vec![0.0; 252]; // your data, oldest first
let close = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.qstick(0, open.len() - 1, &open, &close, 10, &mut out)?;
println!("{} values from bar {}: [{:.4}, ..., {:.4}]", range.count, range.beg_idx, out[0], out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
double[] open = new double[252]; // your data, oldest first
double[] close = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.qstick(0, open.length - 1, open, close, 10, out);
System.out.printf(Locale.ROOT, "%d values from bar %d: [%.4f, ..., %.4f]%n", r.count(), r.begIdx(), out[0], out[r.count() - 1]);using System;
using TALib;
var open = new double[252]; // your data, oldest first
var close = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Qstick(0, open.Length - 1, open, close, 10, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { qstick } from 'ta-lib';
const open = new Float64Array(252); // your data, oldest first
const close = new Float64Array(252); // your data, oldest first
const { begIdx, values } = qstick({ open, close }, { timePeriod: 10 });
console.log(values.length + ' values from bar ' + begIdx + ': [' + values[0].toFixed(4) + ', ..., ' + values[values.length - 1].toFixed(4) + ']');import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
open := make([]float64, 252) // your data, oldest first
close := make([]float64, 252) // your data, oldest first
out := make([]float64, 252)
core := talib.NewCore()
r, err := core.QSTICK(0, len(open)-1, open, close, 10, out)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d: [%.4f, ..., %.4f]\n", r.NBElement, r.BegIdx, out[0], out[r.NBElement-1])Implementation
Added in 0.8.1 (ta-lib-python 0.8.1).
TA-Lib Definition: qstick.c · qstick.yaml
| Native | File |
|---|---|
| C | ta_QSTICK.c |
| Rust | qstick.rs |
| Java | Core_QSTICK.java |
| C# | Core_QSTICK.cs |
| TypeScript | qstick.ts |
| Go | qstick.go |
Python: talib.QSTICK (ta-lib-python 0.8.1 or later), see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
See Also
References
- Tushar S. Chande and Stanley Kroll, The New Technical Trader, Wiley, 1994, define Qstick as an n-period moving average of
Close - Open. - Steven B. Achelis, Technical Analysis from A to Z, page 280 carries the worked example pinned in the test suite; it is exact in binary, every price on the page being a sixteenth.
- Tulip Indicators
ti_qstickand pandas-ta-classicqstickcompute the same form and both default the period to 10, which is where this default comes from. - TraderEvolution documents a default period of 1 and offers a choice of moving average; AmiBroker community code commonly cites 8. Neither is verifiable against the book, and this ships the SMA-only form the authors define.