Indicator · Pine Script v4 · Own pane

Test 009 Stat Mining

by ricardosantos79· code credited to RicardoSantos

This statistical analysis tool mines historical relationships between RSI values and candle volatility.

View on GitHub

GitHub stars261on the repository
Pine versionv4older, still runs
Lines of code34
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago13 Nov 2021

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

34 lines of Pine Script v4 from beta/arrays/test-009-stat_mining.pinescript, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

test-009-stat_mining.pinescript
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos

//@version=4
study("test-009-stat_mining")
var label debug = label.new(x=bar_index, y=0.0, text='', style=label.style_label_right)
f_print(_A, _B, _C, _D, _label)=>
    int _size = array.size(id=_A) - 1
    string _t = ''
    if _size > 0
        for _i = _size to 0
            _t := _t + tostring(_i, '# : ') + tostring(array.get(id=_A, index=_i), '#') + ', ' + tostring(array.get(id=_B, index=_i), '#') + ', ' + tostring(array.get(id=_C, index=_i), '#') + ', ' + tostring(array.get(id=_D, index=_i), '#') + '. \n'
    label.set_xy(id=_label, x=bar_index, y=0.0)
    label.set_text(id=_label, text=_t)

var int[] r1_totals = array.new_int(size=101, initial_value=0)
var int[] r2_totals = array.new_int(size=101, initial_value=0)
var int[] r3_totals = array.new_int(size=101, initial_value=0)
var int[] r4_totals = array.new_int(size=101, initial_value=0)

int rsi = round(rsi(close, 14)[1])
float range = atr(14)
float width = abs(close-close[1]) / range

if width < 1
    array.set(id=r1_totals, index=rsi, value=array.get(id=r1_totals, index=rsi) + 1)
else if width < 2
    array.set(id=r2_totals, index=rsi, value=array.get(id=r2_totals, index=rsi) + 1)
else if width < 3
    array.set(id=r3_totals, index=rsi, value=array.get(id=r3_totals, index=rsi) + 1)
else
    array.set(id=r4_totals, index=rsi, value=array.get(id=r4_totals, index=rsi) + 1)

f_print(r1_totals, r2_totals, r3_totals, r4_totals, debug)

Overview

Test 009 Stat Mining calculates a 14-period RSI from the previous bar and normalizes absolute price change using a 14-period Average True Range (ATR). Based on the normalized movement magnitude across four threshold buckets, it increments frequency counts inside four 101-element arrays indexed by rounded RSI levels. The compiled statistical matrix displays via a dynamic text label in a separate pane.

Details

Published by

ricardosantos79 on GitHub

Code credit

RicardoSantos, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volatility & bands, Screeners & dashboards

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.

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

Market Speedometer

by TradersPost
218 stars

Market Speedometer plots a 0-100 market speed reading in a separate pane. It measures movement by bar-to-bar change, true range, or a short average of recent bars, then ranks that movement against ATR and a percentile lookback. An EMA smooths the reading, and

Indicator v6 Volatility & bandsOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Market Speedometer
41 stars

This indicator transforms standard RSI calculations into logit space, estimating rolling distributions to derive empirical z-scores mapped back to the 0–100 RSI scale. Plotted in a separate pane, it features multi-horizon central lines—fast and structural cent

Indicator v6 Oscillators & momentumVolatility & bands
Updated 2 days ago · None stated GitHub repository of Calibrated RSI Position Zones

This indicator calculates the Relative Strength Index (RSI) alongside a simple moving average to generate directional momentum signals in a separate pane. It supports Break Flip and Break Continuous scanning modes for long and short setups. A wide array of opt

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of Momentum Setup: RSI Direction Confirmation

The Adaptive Cycle Detector estimates the dominant market cycle from WaveTrend oscillator zero-crossing frequency and applies smoothing to recommend adaptive indicator lengths. Fast markets with frequent crossings receive shorter lengths while slow swing marke

Indicator v6 Oscillators & momentumVolatility & bands
Updated yesterday · MIT GitHub repository of Adaptive Cycle Detector [WavesUnchained]

Manias, Panics and Crashes

by MeridianAlgo
9 stars

Manias, Panics and Crashes is a separate-pane market regime indicator that quantifies market sentiment and systemic risk. It processes technical metrics including RSI, moving averages, and volume alongside optional intermarket data such as VIX volatility and c

Indicator v6 Oscillators & momentumVolatility & bands
Updated 4 months ago · MIT GitHub repository of Manias, Panics and Crashes

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